Back to MCP directory
publicPublicdnsLocal runtime

mcp-codebase-rag

基于PostgreSQL和Voyage嵌入模型的代码语义搜索MCP服务器,提供代码片段搜索、文件列表和内容检索功能

article

README

🚀 代码库RAG MCP服务器

本MCP服务器利用嵌入技术和PostgreSQL数据库,提供语义代码库搜索和文件检索功能。它提供了搜索代码、列出文件和检索文件内容的工具。

🚀 快速开始

本MCP服务器借助嵌入技术和PostgreSQL数据库,实现了语义代码库搜索与文件检索功能,并提供了一系列实用工具。

✨ 主要特性

  • 语义代码搜索:使用Voyage嵌入模型将查询转换为向量,并通过相似度搜索代码片段。
  • 文件列表:列出代码库中所有被跟踪的文件。
  • 文件内容检索:根据文件名获取文件的完整内容。

📚 详细文档

工具

  • search_codebase
    • 返回与查询相关的代码片段。
    • 输入:
      • query(字符串):搜索词
  • get_files
    • 列出代码库中的所有文件。
  • get_file_content
    • 返回指定文件的内容。
    • 输入:
      • filename(字符串):文件名

配置

获取Voyage API密钥

  1. 注册 Voyage API账户
  2. 从仪表盘生成API密钥

环境变量

  • DATABASE_URL:PostgreSQL连接字符串。
  • VOYAGE_API_KEY:嵌入模型的API密钥。
  • EMBEDDING_TABLE:代码嵌入的表名。
  • TRACKING_TABLE:文件跟踪的表名。

Docker

{
  "mcpServers": {
    "codebase-rag": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "DATABASE_URL",
        "-e",
        "VOYAGE_API_KEY",
        "-e",
        "EMBEDDING_TABLE",
        "-e",
        "TRACKING_TABLE",
        "-p",
        "8080:8080",
        "allentcm/mcp-codebase-rag:1.0.0"
      ],
      "env": {
        "DATABASE_URL": "postgres://cocoindex:cocoindex@localhost/cocoindex",
        "VOYAGE_API_KEY": "voyage_api_key",
        "EMBEDDING_TABLE": "codebase__code_embeddings",
        "TRACKING_TABLE": "codebase__cocoindex_tracking"
      }
    }
  }
}

📄 许可证

本MCP服务器采用MIT许可证。在遵循MIT许可证的条款和条件的前提下,您可以自由使用、修改和分发本软件。有关更多详细信息,请参阅项目仓库中的LICENSE文件。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client