代码库分析服务器

Codebase MCP Server是一个用于安全高效分析代码库的模型上下文协议服务器,提供文件管理、元数据检索和依赖分析等功能。

  • by MyunghoBae
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 MyunghoBae/codebase-mcp-server

使用说明

Codebase MCP Server

Model Context Protocol server for secure and efficient Codebase analysis

Key Features • Supported Languages • Tools • QuickStart • Build • Contributing

🌟 主要特点

  • 安全访问:将文件操作限制到预定义的根目录。
  • 高效的文件管理:提供读取和搜索文件的工具。
  • 详细元数据:检索全面的文件元数据,包括大小、创建时间、上次修改时间、权限和类型。
  • 相关性分析:遍历并分析项目中的依赖树。

📋 支持的语言

  • JavaScript/TypeScript
  • CSS/CSS预处理器

🛠️ 工具

  • get-project-basics:检索基本的项目信息,包括package.json详细信息、目录结构。
  • search-config-files:在根目录中搜索配置文件并返回其路径。
  • get-dependency-tree:根据给定的文件路径和根目录遍历依赖树,并返回遍历结果。
  • list-directory:列出指定目录的内容,区分文件和目录。
  • read-file-with-metadata:读取指定文件的内容并检索其元数据。

🚀 快速启动

先决条件

  • Node.js v18或更高版本
  • 与LLM通信的代码库

安装

首先,在客户端上安装Codebase MCP服务器。典型的配置如下:

{
  "mcpServers": {
    "Codebase": {
      "command": "npx",
      "args": ["codebase-mcp-server@latest", "/path/to/your/codebase"]
    }
  }
}

或者,您可以使用Docker安装Codebase MCP服务器。

克隆此存储库后,构建Docker镜像:

docker build -t mcp/codebase -f .

然后将以下内容添加到MCP服务器文件中:

{
  "mcpServers": {
    "Codebase": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--mount",
        "type=bind,src=/path/to/your/codebase/dir,dst=/projects/path/to/your/codebase/dir,ro",
        "--mount",
        "type=bind,src=/path/to/some/file.txt,dst=/projects/path/to/some/file.txt",
        "mcp/codebase",
        "/projects"
      ]
    }
  }
}
Install in VS Code You can install the Codebase MCP server using the VS Code CLI:
# For VS Code
code --add-mcp '{"name":"Codebase","command":"npx","args":["codebase-mcp-server@latest"]}'

安装后,Codebase MCP服务器将可用于VS Code中的GitHub Copilot代理。

Install in Cursor Go to Cursor Settings -> MCP -> Add new MCP Server. Use following configuration:
{
  "mcpServers": {
    "Codebase": {
      "command": "npx",
      "args": ["codebase-mcp-server@latest"]
    }
  }
}
Install in Windsurf

遵循Windsuff MCP文档。使用以下配置:

{
  "mcpServers": {
    "Codebase": {
      "command": "npx",
      "args": ["codebase-mcp-server@latest"]
    }
  }
}
Install in Claude Desktop

遵循MCP安装指南,使用以下配置:

{
  "mcpServers": {
    "Codebase": {
      "command": "npx",
      "args": ["codebase-mcp-server@latest"]
    }
  }
}

🔧 构建

地方发展建设

# Install dependencies
npm ci

# Build TypeScript
npm run build

Docker构建

# Build Docker image
docker build -t mcp/codebase -f .

# Or with specific tag
docker build -t mcp/codebase:latest -f .

🤝 贡献

欢迎投稿!请阅读我们的贡献指南,了解我们的行为准则和提交拉取请求的流程的详细信息。