代码搜索服务

一个基于Zoekt的代码搜索服务,使AI编码助手能够跨索引仓库搜索代码。

  • by jahales
  • TypeScript
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 jahales/mcp-zoekt

使用说明

mcp 搜索

MCP(模型上下文协议)服务器,使AI编码助手能够使用 正在搜索.

概述

此存储库提供:

  • zoekt-mcp/ -将AI助手(GitHub Copilot、Claude等)连接到Zoekt的TypeScript MCP服务器
  • docker/ -Docker Compose用于自托管Zoekt的基础设施,具有工作树索引和GitHub组织镜像(包括多组织)
  • zoekt/ -Git子模块引用 sourcegraph/搜索

快速开始

1. 开始寻找基础设施

cd docker

# Create a .env from the template and choose a mode via COMPOSE_PROFILES
cp .env.example .env

# For GitHub mode only: create config directory and add your GitHub token
# mkdir -p config
# echo "ghp_your_token_here" > config/github-token.txt

# Start services
docker compose up -d

2.配置您的AI助手

VS代码与GitHub Copilot -添加到 .vscode/settings.json:

{
  "github.copilot.chat.experimental.mcpServers": {
    "zoekt": {
      "command": "npx",
      "args": ["mcp-zoekt", "--url", "http://localhost:6070"]
    }
  }
}

克劳德桌面 -添加到您的配置文件中:

{
  "mcpServers": {
    "zoekt": {
      "command": "npx",
      "args": ["mcp-zoekt", "--url", "http://localhost:6070"]
    }
  }
}

3.搜索您的代码

让你的AI助手在你的索引存储库中搜索:

“在我的代码库中搜索身份验证中间件” “查找UserService类的所有用法” “演示如何实现错误处理”

MCP工具

工具 说明
search 使用Zoekt查询语法(正则表达式、文件过滤器、语言过滤器)的搜索代码
search_symbols 使用可选的类型过滤查找符号定义(函数、类、方法)
search_files 按文件名模式搜索文件
find_references 在存储库中查找符号的所有定义和用法
list_repos 列出所有具有可选筛选功能的索引存储库
file_content 从索引存储库中检索完整文件内容
get_health 检查MCP服务器和Zoekt后端的运行状况

文档

发展

# Install dependencies
cd zoekt-mcp
npm install

# Run tests
npm test              # Unit tests
npm run test:all      # All tests (requires Docker infrastructure)

# Build
npm run build

许可证

Apache许可证2.0-请参阅 许可证 了解详情。

此项目使用 正在搜索 它也由Sourcegraph在Apache 2.0下授权。