Grepai Mcp Tools

yoanbernabeu/grepai-skills/skills/integration/grepai-mcp-tools

作者 yoanbernabeu382d40261c0d41109c6e11872574ba0be9b064d0无许可证收录于 2026年10月9日更新于 2026年10月9日

Reference for all GrepAI MCP tools. Use this skill to understand available MCP tools and their parameters.

AI 生成的概览

GrepAI MCP 工具的参考文档,涵盖参数、响应与用法。

功能
该技能是一份参考文档,说明 GrepAI MCP 服务器提供的工具:语义代码搜索、调用者与被调用者追踪、调用图构建以及索引状态检查。它列出每个工具的参数、默认值、示例请求与 JSON 响应,包括紧凑输出的键名和错误码。文档还介绍 MCP 协议的请求与响应格式,以及面向 AI 集成的令牌效率建议。
适用场景
当你需要了解 GrepAI 有哪些 MCP 工具、它们接受哪些参数,或如何解读其响应时使用。它也适用于将 GrepAI 集成到 AI 助手,或排查 MCP 工具使用问题。
运行要求
仅为说明文档,不附带脚本。使用所描述的工具需要 GrepAI 命令行工具并通过 grepai mcp-serve 命令启动其 MCP 服务器,还需要已构建的代码索引以及可访问的嵌入服务提供方(如 Ollama)。

GrepAI MCP Tools Reference

This skill provides a complete reference for all tools available through GrepAI's MCP server.

When to Use This Skill

  • Understanding available MCP tools
  • Learning tool parameters and options
  • Integrating GrepAI with AI assistants
  • Debugging MCP tool usage

Starting the MCP Server

bash
grepai mcp-serve

The server exposes tools via the Model Context Protocol.

Available Tools

1. grepai_search

Semantic code search using embeddings.

Parameters
ParameterTypeRequiredDefaultDescription
querystringYes-Search query describing what to find
limitnumberNo10Maximum results to return
compactbooleanNofalseReturn compact output (no content)
formatstringNo"json"Output format: "json" or "toon" (v0.26.0+)
Example Request
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}
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}

2. grepai_trace_callers

Find all functions that call a specified symbol.

Parameters
ParameterTypeRequiredDefaultDescription
symbolstringYes-Function/method name to trace
compactbooleanNofalseReturn compact output (no context)
formatstringNo"json"Output format: "json" or "toon" (v0.26.0+)
Example Request
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"}  ]}
Response (Full)
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

Find all functions called by a specified symbol.

Parameters
ParameterTypeRequiredDefaultDescription
symbolstringYes-Function/method name to trace
compactbooleanNofalseReturn compact output (no context)
formatstringNo"json"Output format: "json" or "toon" (v0.26.0+)
Example Request
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"}  ]}

4. grepai_trace_graph

Build a complete call graph starting from a symbol.

Parameters
ParameterTypeRequiredDefaultDescription
symbolstringYes-Root function for the graph
depthnumberNo2Maximum recursion depth
compactbooleanNofalseReturn compact JSON format
formatstringNo"json"Output format: "json" or "toon" (v0.26.0+)
Example Request
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}}
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  }}

5. grepai_index_status

Check the health and status of the code index.

Parameters
ParameterTypeRequiredDefaultDescription
verbosebooleanNofalseInclude detailed information
formatstringNo"json"Output format: "json" or "toon" (v0.26.0+)
Example Request
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  }}

Compact Format Reference

When compact: true, responses use abbreviated keys:

Full KeyCompact KeyDescription
queryqSearch query or symbol
resultsrResults array
totaltTotal count
countcCount
scoresSimilarity score
filefFile path
linelLine number(s)
modemTrace mode
depthdGraph depth
namenNode name
childrencChild nodes
statssStatistics
functionfnFunction name

Token Efficiency

Compact mode reduces tokens significantly:

Response TypeFullCompactSavings
Search (5 results)~800~15081%
Trace callers (10)~600~12080%
Trace graph (depth 3)~1200~25079%

Error Responses

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"}

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"}

Best Practices for AI Integration

  1. Use compact mode: Reduces token usage by ~80%
  2. Limit results: Request only what you need
  3. Check status first: Use grepai_index_status before searches
  4. Handle errors: Check for error responses
  5. Combine tools: Search + trace for full understanding

MCP Protocol Details

Request Format

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}"      }    ]  }}

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 reduction

来源与署名

来源:yoanbernabeu/grepai-skills位于skills/integration/grepai-mcp-tools提交382d402

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架