☰
Greptile MCP 服务说明文档
2026/10/19 2:05:55 网站建设 项目流程

1. 服务概述

一句话简介:AI驱动的代码搜索和查询MCP服务器,通过Greptile API提供自然语言代码理解能力

  • 服务名称:Greptile MCP
  • 版本号:TypeScript Edition
  • 开发者/提供方:sosacrazy126
  • 协议类型:MCP (Model Context Protocol)

2. 核心功能

列出该MCP服务提供的主要功能点:

  • 自然语言查询:使用自然语言提问代码库相关问题
  • 深度代码分析:理解架构、模式和实现细节
  • 跨仓库洞察:比较多个代码库的模式和方法
  • 会话连续性:通过对话逐步构建理解
  • GitHub集成:访问和索引GitHub仓库,支持公开和私有仓库
  • GitLab集成:索引和搜索GitLab仓库
  • 零安装体验:通过NPX立即启动,无需设置
  • 流式支持:使用Server-Sent Events实时响应

3. 使用场景

描述该服务适合在什么情况下使用:

  • 代码架构理解:快速了解新项目的整体架构和设计模式
  • 代码审查:AI辅助分析代码质量和潜在问题
  • 跨项目比较:比较不同项目间的实现模式和最佳实践
  • 技术文档生成:基于代码自动生成技术文档
  • 代码搜索:使用自然语言搜索代码库中的特定功能或实现
  • 学习与探索:通过对话式交互学习代码库

4. 接入方式

4.1 服务端点

该MCP服务器通过NPX运行,支持以下方式启动:

npx greptile-mcp-server --api-key=xxx --github-token=yyy

4.2 认证与权限

使用该服务需要以下认证信息:

  • Greptile API Key:从 app.greptile.com/settings/api 获取
  • GitHub Token:从 github.com/settings/tokens 生成,需要repo权限

4.3 数据格式

服务支持以下数据格式:

  • 请求格式:JSON格式的MCP协议消息
  • 响应格式:JSON格式或流式Server-Sent Events

4.4 服务器配置

在MCP客户端配置中添加服务:

{ "mcpServers": { "greptile": { "command": "npx", "args": ["greptile-mcp-server"], "env": { "GREPTILE_API_KEY": "your_api_key", "GITHUB_TOKEN": "your_github_token" } } } }

5. 接口定义

该MCP服务器提供以下工具:

5.1 greptile_help

获取全面的文档和使用示例。

{ "name": "greptile_help" }

5.2 index_repository

索引仓库使其可搜索。

{ "name": "index_repository", "arguments": { "remote": "github", "repository": "microsoft/vscode", "branch": "main", "reload": true } }

5.3 query_repository

使用自然语言查询仓库。

{ "name": "query_repository", "arguments": { "query": "How is authentication implemented in this codebase?", "repositories": [ { "remote": "github", "repository": "microsoft/vscode", "branch": "main" } ], "stream": false, "session_id": "optional-session-id" } }

5.4 get_repository_info

获取已索引仓库的信息。

{ "name": "get_repository_info", "arguments": { "remote": "github", "repository": "microsoft/vscode", "branch": "main" } }

6. 快速开始

6.1 环境要求

  • Node.js 18+(推荐以获得最佳性能)
  • Greptile API Key
  • GitHub Token(具有repo权限)

6.2 示例代码

环境变量设置(Linux/macOS):

export GREPTILE_API_KEY="your_api_key_here" export GITHUB_TOKEN="your_github_token_here"

环境变量设置:

$env:GREPTILE_API_KEY="your_api_key_here" $env:GITHUB_TOKEN="your_github_token_here"

基本使用流程:

npx greptile-mcp-server // 在MCP客户端中索引仓库 { "tool": "index_repository", "arguments": { "remote": "github", "repository": "microsoft/vscode", "branch": "main" } } // 查询代码库 { "tool": "query_repository", "arguments": { "query": "How does VS Code handle file watching?", "repositories": [{"remote": "github", "repository": "microsoft/vscode", "branch": "main"}] } }

7. 注意事项

  • API密钥安全:妥善保管Greptile API Key和GitHub Token,不要提交到版本控制系统
  • 权限要求:GitHub Token需要具有repo权限才能访问私有仓库
  • 索引时间:小型仓库(<1000文件)通常需要1-2分钟,大型仓库可能需要10-15分钟
  • 费用说明:MCP服务器本身免费开源,但Greptile API使用可能产生费用
  • 数据安全:代码由Greptile API处理,请查阅其安全和隐私政策
  • 网络要求:需要稳定的网络连接访问Greptile API和GitHub/GitLab
  • 会话管理:使用session_id可以保持对话上下文,实现渐进式代码理解

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询