grepai-mcp-tools
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGrepAI MCP Tools Reference
GrepAI MCP工具参考文档
This skill provides a complete reference for all tools available through GrepAI's MCP server.
本技能提供了GrepAI的MCP服务器上所有可用工具的完整参考文档。
When to Use This Skill
何时使用此技能
- Understanding available MCP tools
- Learning tool parameters and options
- Integrating GrepAI with AI assistants
- Debugging MCP tool usage
- 了解可用的MCP工具
- 学习工具参数和选项
- 将GrepAI与AI助手集成
- 调试MCP工具的使用
Starting the MCP Server
启动MCP服务器
bash
grepai mcp-serveThe server exposes tools via the Model Context Protocol.
bash
grepai mcp-serve服务器通过Model Context Protocol(模型上下文协议)对外暴露工具。
Available Tools
可用工具
1. grepai_search
1. grepai_search
Semantic code search using embeddings.
使用嵌入技术的语义代码搜索。
Parameters
参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Search query describing what to find |
| number | No | 10 | Maximum results to return |
| boolean | No | false | Return compact output (no content) |
| string | No | "json" | Output format: "json" or "toon" (v0.26.0+) |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 是 | - | 描述搜索目标的查询语句 |
| number | 否 | 10 | 返回的最大结果数 |
| boolean | 否 | false | 返回精简输出(不包含内容) |
| string | 否 | "json" | 输出格式:"json" 或 "toon"(v0.26.0+) |
Example Request
请求示例
json
{
"tool": "grepai_search",
"parameters": {
"query": "user authentication middleware",
"limit": 5,
"compact": true,
"format": "toon"
}
}json
{
"tool": "grepai_search",
"parameters": {
"query": "user authentication middleware",
"limit": 5,
"compact": true,
"format": "toon"
}
}Response (Compact)
响应(精简模式)
json
{
"q": "user authentication middleware",
"r": [
{"s": 0.92, "f": "src/auth/middleware.go", "l": "15-45"},
{"s": 0.85, "f": "src/auth/jwt.go", "l": "23-55"},
{"s": 0.78, "f": "src/handlers/auth.go", "l": "10-40"}
],
"t": 3
}json
{
"q": "user authentication middleware",
"r": [
{"s": 0.92, "f": "src/auth/middleware.go", "l": "15-45"},
{"s": 0.85, "f": "src/auth/jwt.go", "l": "23-55"},
{"s": 0.78, "f": "src/handlers/auth.go", "l": "10-40"}
],
"t": 3
}Response (Full)
响应(完整模式)
json
{
"query": "user authentication middleware",
"results": [
{
"score": 0.92,
"file": "src/auth/middleware.go",
"start_line": 15,
"end_line": 45,
"content": "func AuthMiddleware() gin.HandlerFunc {\n ..."
}
],
"total": 3
}json
{
"query": "user authentication middleware",
"results": [
{
"score": 0.92,
"file": "src/auth/middleware.go",
"start_line": 15,
"end_line": 45,
"content": "func AuthMiddleware() gin.HandlerFunc {\n ..."
}
],
"total": 3
}2. grepai_trace_callers
2. grepai_trace_callers
Find all functions that call a specified symbol.
查找调用指定符号的所有函数。
Parameters
参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Function/method name to trace |
| boolean | No | false | Return compact output (no context) |
| string | No | "json" | Output format: "json" or "toon" (v0.26.0+) |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 是 | - | 要追踪的函数/方法名称 |
| boolean | 否 | false | 返回精简输出(不包含上下文) |
| string | 否 | "json" | 输出格式:"json" 或 "toon"(v0.26.0+) |
Example Request
请求示例
json
{
"tool": "grepai_trace_callers",
"parameters": {
"symbol": "Login",
"compact": true
}
}json
{
"tool": "grepai_trace_callers",
"parameters": {
"symbol": "Login",
"compact": true
}
}Response (Compact)
响应(精简模式)
json
{
"q": "Login",
"m": "callers",
"c": 3,
"r": [
{"f": "handlers/auth.go", "l": 42, "fn": "HandleAuth"},
{"f": "handlers/auth_test.go", "l": 15, "fn": "TestLoginSuccess"},
{"f": "cmd/main.go", "l": 88, "fn": "RunCLI"}
]
}json
{
"q": "Login",
"m": "callers",
"c": 3,
"r": [
{"f": "handlers/auth.go", "l": 42, "fn": "HandleAuth"},
{"f": "handlers/auth_test.go", "l": 15, "fn": "TestLoginSuccess"},
{"f": "cmd/main.go", "l": 88, "fn": "RunCLI"}
]
}Response (Full)
响应(完整模式)
json
{
"query": "Login",
"mode": "callers",
"count": 3,
"results": [
{
"file": "handlers/auth.go",
"line": 42,
"caller": "HandleAuth",
"context": "user.Login(ctx, credentials)"
}
]
}json
{
"query": "Login",
"mode": "callers",
"count": 3,
"results": [
{
"file": "handlers/auth.go",
"line": 42,
"caller": "HandleAuth",
"context": "user.Login(ctx, credentials)"
}
]
}3. grepai_trace_callees
3. grepai_trace_callees
Find all functions called by a specified symbol.
查找指定符号调用的所有函数。
Parameters
参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Function/method name to trace |
| boolean | No | false | Return compact output (no context) |
| string | No | "json" | Output format: "json" or "toon" (v0.26.0+) |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 是 | - | 要追踪的函数/方法名称 |
| boolean | 否 | false | 返回精简输出(不包含上下文) |
| string | 否 | "json" | 输出格式:"json" 或 "toon"(v0.26.0+) |
Example Request
请求示例
json
{
"tool": "grepai_trace_callees",
"parameters": {
"symbol": "ProcessOrder",
"compact": true
}
}json
{
"tool": "grepai_trace_callees",
"parameters": {
"symbol": "ProcessOrder",
"compact": true
}
}Response (Compact)
响应(精简模式)
json
{
"q": "ProcessOrder",
"m": "callees",
"c": 4,
"r": [
{"f": "services/order.go", "l": 45, "fn": "validateOrder"},
{"f": "services/order.go", "l": 48, "fn": "calculateTotal"},
{"f": "services/order.go", "l": 51, "fn": "applyDiscount"},
{"f": "services/order.go", "l": 55, "fn": "sendConfirmation"}
]
}json
{
"q": "ProcessOrder",
"m": "callees",
"c": 4,
"r": [
{"f": "services/order.go", "l": 45, "fn": "validateOrder"},
{"f": "services/order.go", "l": 48, "fn": "calculateTotal"},
{"f": "services/order.go", "l": 51, "fn": "applyDiscount"},
{"f": "services/order.go", "l": 55, "fn": "sendConfirmation"}
]
}4. grepai_trace_graph
4. grepai_trace_graph
Build a complete call graph starting from a symbol.
从指定符号开始构建完整的调用图。
Parameters
参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | Yes | - | Root function for the graph |
| number | No | 2 | Maximum recursion depth |
| boolean | No | false | Return compact JSON format |
| string | No | "json" | Output format: "json" or "toon" (v0.26.0+) |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 是 | - | 调用图的根函数 |
| number | 否 | 2 | 最大递归深度 |
| boolean | 否 | false | 返回精简JSON格式 |
| string | 否 | "json" | 输出格式:"json" 或 "toon"(v0.26.0+) |
Example Request
请求示例
json
{
"tool": "grepai_trace_graph",
"parameters": {
"symbol": "main",
"depth": 3,
"compact": true
}
}json
{
"tool": "grepai_trace_graph",
"parameters": {
"symbol": "main",
"depth": 3,
"compact": true
}
}Response (Compact)
响应(精简模式)
json
{
"q": "main",
"d": 3,
"r": {
"n": "main",
"c": [
{
"n": "initialize",
"c": [
{"n": "loadConfig"},
{"n": "connectDB"}
]
},
{
"n": "startServer",
"c": [
{"n": "registerRoutes"}
]
}
]
},
"s": {"nodes": 6, "depth": 3}
}json
{
"q": "main",
"d": 3,
"r": {
"n": "main",
"c": [
{
"n": "initialize",
"c": [
{"n": "loadConfig"},
{"n": "connectDB"}
]
},
{
"n": "startServer",
"c": [
{"n": "registerRoutes"}
]
}
]
},
"s": {"nodes": 6, "depth": 3}
}Response (Full)
响应(完整模式)
json
{
"query": "main",
"mode": "graph",
"depth": 3,
"root": {
"name": "main",
"file": "cmd/main.go",
"line": 10,
"children": [
{
"name": "initialize",
"file": "cmd/main.go",
"line": 15,
"children": [...]
}
]
},
"stats": {
"nodes": 6,
"max_depth": 3
}
}json
{
"query": "main",
"mode": "graph",
"depth": 3,
"root": {
"name": "main",
"file": "cmd/main.go",
"line": 10,
"children": [
{
"name": "initialize",
"file": "cmd/main.go",
"line": 15,
"children": [...]
}
]
},
"stats": {
"nodes": 6,
"max_depth": 3
}
}5. grepai_index_status
5. grepai_index_status
Check the health and status of the code index.
检查代码索引的健康状态。
Parameters
参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| boolean | No | false | Include detailed information |
| string | No | "json" | Output format: "json" or "toon" (v0.26.0+) |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| boolean | 否 | false | 包含详细信息 |
| string | 否 | "json" | 输出格式:"json" 或 "toon"(v0.26.0+) |
Example Request
请求示例
json
{
"tool": "grepai_index_status",
"parameters": {
"verbose": true
}
}json
{
"tool": "grepai_index_status",
"parameters": {
"verbose": true
}
}Response
响应
json
{
"status": "healthy",
"project": "/path/to/project",
"embedder": {
"provider": "ollama",
"model": "nomic-embed-text",
"status": "connected"
},
"store": {
"backend": "gob",
"location": ".grepai/index.gob"
},
"index": {
"files": 245,
"chunks": 1234,
"last_updated": "2025-01-28T10:30:00Z"
},
"daemon": {
"running": true,
"pid": 12345
}
}json
{
"status": "healthy",
"project": "/path/to/project",
"embedder": {
"provider": "ollama",
"model": "nomic-embed-text",
"status": "connected"
},
"store": {
"backend": "gob",
"location": ".grepai/index.gob"
},
"index": {
"files": 245,
"chunks": 1234,
"last_updated": "2025-01-28T10:30:00Z"
},
"daemon": {
"running": true,
"pid": 12345
}
}Compact Format Reference
精简格式参考
When , responses use abbreviated keys:
compact: true| Full Key | Compact Key | Description |
|---|---|---|
| | Search query or symbol |
| | Results array |
| | Total count |
| | Count |
| | Similarity score |
| | File path |
| | Line number(s) |
| | Trace mode |
| | Graph depth |
| | Node name |
| | Child nodes |
| | Statistics |
| | Function name |
当设置时,响应使用缩写键:
compact: true| 完整键名 | 精简键名 | 描述 |
|---|---|---|
| | 搜索查询或符号 |
| | 结果数组 |
| | 总数量 |
| | 数量 |
| | 相似度分数 |
| | 文件路径 |
| | 行号 |
| | 追踪模式 |
| | 调用图深度 |
| | 节点名称 |
| | 子节点 |
| | 统计信息 |
| | 函数名称 |
Token Efficiency
Token效率
Compact mode reduces tokens significantly:
| Response Type | Full | Compact | Savings |
|---|---|---|---|
| Search (5 results) | ~800 | ~150 | 81% |
| Trace callers (10) | ~600 | ~120 | 80% |
| Trace graph (depth 3) | ~1200 | ~250 | 79% |
精简模式可显著减少Token使用量:
| 响应类型 | 完整模式 | 精简模式 | 节省比例 |
|---|---|---|---|
| 搜索(5条结果) | ~800 | ~150 | 81% |
| 调用者追踪(10条) | ~600 | ~120 | 80% |
| 调用图追踪(深度3) | ~1200 | ~250 | 79% |
Error Responses
错误响应
Index Not Found
索引未找到
json
{
"error": "Index not found. Run 'grepai watch' first.",
"code": "INDEX_NOT_FOUND"
}json
{
"error": "Index not found. Run 'grepai watch' first.",
"code": "INDEX_NOT_FOUND"
}Embedder Connection Failed
嵌入服务连接失败
json
{
"error": "Cannot connect to embedding provider. Is Ollama running?",
"code": "EMBEDDER_UNAVAILABLE"
}json
{
"error": "Cannot connect to embedding provider. Is Ollama running?",
"code": "EMBEDDER_UNAVAILABLE"
}Symbol Not Found
符号未找到
json
{
"error": "Symbol 'FunctionName' not found in index.",
"code": "SYMBOL_NOT_FOUND"
}json
{
"error": "Symbol 'FunctionName' not found in index.",
"code": "SYMBOL_NOT_FOUND"
}Invalid Parameters
参数无效
json
{
"error": "Parameter 'query' is required.",
"code": "INVALID_PARAMETERS"
}json
{
"error": "Parameter 'query' is required.",
"code": "INVALID_PARAMETERS"
}Best Practices for AI Integration
AI集成最佳实践
- Use compact mode: Reduces token usage by ~80%
- Limit results: Request only what you need
- Check status first: Use before searches
grepai_index_status - Handle errors: Check for error responses
- Combine tools: Search + trace for full understanding
- 使用精简模式:减少约80%的Token使用量
- 限制结果数量:只请求需要的内容
- 先检查状态:在搜索前使用
grepai_index_status - 处理错误:检查错误响应
- 组合工具使用:搜索+追踪以全面了解代码
MCP Protocol Details
MCP协议细节
Request Format
请求格式
json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "grepai_search",
"arguments": {
"query": "authentication",
"limit": 5,
"compact": true
}
}
}json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "grepai_search",
"arguments": {
"query": "authentication",
"limit": 5,
"compact": true
}
}
}Response Format
响应格式
json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"q\":\"authentication\",\"r\":[...],\"t\":5}"
}
]
}
}json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"q\":\"authentication\",\"r\":[...],\"t\":5}"
}
]
}
}Output Format
输出格式
MCP tools reference summary:
📚 GrepAI MCP Tools Reference
Tools available:
1. grepai_search
- Semantic code search
- Params: query*, limit, compact
2. grepai_trace_callers
- Find function callers
- Params: symbol*, compact
3. grepai_trace_callees
- Find function callees
- Params: symbol*, compact
4. grepai_trace_graph
- Build call graph
- Params: symbol*, depth, compact
5. grepai_index_status
- Check index health
- Params: verbose
* = required parameter
Compact mode: ~80% token reductionMCP工具参考摘要:
📚 GrepAI MCP工具参考文档
可用工具:
1. grepai_search
- 语义代码搜索
- 参数:query*, limit, compact
2. grepai_trace_callers
- 查找函数调用者
- 参数:symbol*, compact
3. grepai_trace_callees
- 查找函数被调用者
- 参数:symbol*, compact
4. grepai_trace_graph
- 构建调用图
- 参数:symbol*, depth, compact
5. grepai_index_status
- 检查索引健康状态
- 参数:verbose
* = 必填参数
精简模式:约80% Token节省