<img src="https://img.shields.io/badge/MCP-Model%20Context%20Protocol-orange" alt="MCP">
<img src="https://img.shields.io/badge/AI-Ready-success" alt="AI Ready">
Acemcp 是一个高性能的 MCP(模型上下文协议)服务器,专门设计用于像 Claude、GPT 等 AI 助手,并且具有代码库索引和语义搜索的能力。通过 Acemcp,AI 助手可以:
为什么选择 Acemcp?
| 特性 | 描述 |
|---|---|
| 零配置启动 | 第一次运行时自动生成配置 |
| 增量索引 | 只处理更改过的文件,快速高效 |
| 跨平台 | 支持 Windows、Linux、macOS 和 WSL |
| 多编码支持 | 自动检测 UTF-8、GBK、GB2312、Latin-1 |
| AI 友好 | 返回格式化的代码片段,包括文件路径和行号 |
# 全局安装
npm install -g acemcp-node
# 或者本地安装到项目
npm install acemcp-node
# 克隆仓库
git clone https://github.com/yeuxuan/Ace-Mcp-Node.git
cd Ace-Mcp-Node
# 安装依赖
npm install
# 编译 TypeScript
npm run build
# 启动服务器(首次会创建配置文件)
npm start
# 或启动带 Web 界面
npm start -- --web-port 8080
访问 http://localhost:8080 查看 Web 管理界面!
npm install -g acemcp-node
# 验证安装
node -e "console.log(require('acemcp-node/package.json').version)"
# 创建项目目录
mkdir my-mcp-project && cd my-mcp-project
# 初始化 package.json
npm init -y
# 安装 acemcp-node
npm install acemcp-node
# 运行
npx acemcp-node
git clone https://github.com/yeuxuan/Ace-Mcp-Node.git
cd Ace-Mcp-Node
npm install
npm run build
# 开发模式(自动重载)
npm run dev
第一次运行时,程序会在 ~/.acemcp/ 目录下自动创建配置文件:
~/.acemcp/
├── settings.toml # 主配置文件
├── data/
│ └── projects.json # 项目索引数据
└── log/
└── acemcp.log # 日志文件
# ~/.acemcp/settings.toml
# === API 配置 ===
BASE_URL = "https://api.example.com" # 索引服务器地址
TOKEN = "your-token-here" # 访问令牌
# === 索引配置 ===
BATCH_SIZE = 10 # 批量上传数量(1-50)
MAX_LINES_PER_BLOB = 800 # 单个代码块最大行数
# === 文件类型配置 ===
# 支持索引的文本文件扩展名
TEXT_EXTENSIONS = [
# 编程语言
".py", ".js", ".ts", ".jsx", ".tsx",
".java", ".go", ".rs", ".cpp", ".c",
".h", ".hpp", ".cs", ".rb", ".php",
".swift", ".kt", ".scala", ".clj",
# 配置和数据
".md", ".txt", ".json", ".yaml", ".yml",
".toml", ".xml", ".ini", ".conf",
# Web 相关
".html", ".css", ".scss", ".sass", ".less",
# 脚本
".sql", ".sh", ".bash", ".ps1", ".bat"
]
# === 排除模式 ===
# 不会被索引的目录和文件模式
EXCLUDE_PATTERNS = [
# 虚拟环境
".venv", "venv", ".env", "env",
"node_modules",
# 版本控制
".git", ".svn", ".hg",
# Python 缓存
"__pycache__", ".pytest_cache", ".mypy_cache",
".tox", ".eggs", "*.egg-info",
# 构建产物
"dist", "build", "target", "out",
# IDE 配置
".idea", ".vscode", ".vs",
# 系统文件
".DS_Store", "Thumbs.db",
# 编译文件
"*.pyc", "*.pyo", "*.pyd", "*.so", "*.dll"
]
# 临时使用不同的 API 配置
npm start -- --base-url https://custom-api.com --token custom-token
# 自定义批次大小
npm start -- --batch-size 20
# 启动 Web 界面在指定端口
npm start -- --web-port 3000
# 组合使用
npm start -- --base-url https://api.com --token abc123 --web-port 8080
npm start
此模式用于 MCP 客户端集成并通过标准输入/输出进行通信。
npm start -- --web-port 8080
访问 http://localhost:8080 使用图形界面:
npm run dev # 标准模式 + 热重载
npm run dev -- --web-port 8080 # Web 模式 + 热重载
Acemcp Node 提供了对 Windows Subsystem for Linux (WSL) 的完整路径支持,无需手动转换路径格式。
| 路径类型 | 原始格式 | 自动转换 | 使用场景 |
|---|---|---|---|
| Windows 本地 | C:\Users\username\project | C:/Users/username/project | Windows 上的项目 |
| WSI 内部 | /home/user/project | /home/user/project | WSI 文件系统内 |
| 通过 WSL 访问 Windows | /mnt/c/Users/username/project | C:/Users/username/project | 在 WSL 中访问 Windows 文件 ⭐ |
| Windows 访问 WSL | \\wsl$\Ubuntu\home\user\project | /home/user/project | Windows 访问 WSA 文件 ⭐ |
{
"tool": "search_context",
"arguments": {
"project_root_path": "C:/Users/username/myproject",
"query": "authentication logic"
}
}
{
"tool": "search_context",
"arguments": {
"project_root_path": "/mnt/c/Users/username/myproject",
"query": "database connection"
}
}
{
"tool": "search_context",
"arguments": {
"project_root_path": "\\\\wsl$\\Ubuntu\\home\\user\\myproject",
"query": "API routes"
}
}
// 或 \\\wsl$\ 格式/mnt/c/ 转换为 C:/如果遇到路径问题,请参考:
编辑 Claude Desktop 配置文件:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"acemcp": {
"command": "npx",
"args": ["acemcp-node"],
"env": {}
}
}
}
{
"mcpServers": {
"acemcp": {
"command": "node",
"args": ["D:/projects/Ace-Mcp-Node/dist/index.js"],
"env": {}
}
}
}
{
"mcpServers": {
"acemcp": {
"command": "node",
"args": [
"D:/projects/Ace-Mcp-Node/dist/index.js",
"--web-port",
"8080"
],
"env": {}
}
}
}
{
"mcpServers": {
"acemcp": {
"command": "node",
"args": [
"D:/projects/Ace-Mcp-Node/dist/index.js",
"--base-url",
"https://your-api.com",
"--token",
"your-token-here"
],
"env": {}
}
}
}
{
"mcpServers": {
"acemcp": {
"command": "node",
"args": ["\\\\wsl$\\Ubuntu\\home\\user\\Ace-Mcp-Node\\dist\\index.js"],
"env": {}
}
}
}
对于其他支持 MCP 协议的客户端(如 Zed、cursor 等),配置方法类似。请参阅每个客户端的 MCP 配置文档。
配置完成后:
~/.acemcp/log/acemcp.logsearch_context 工具在项目代码库中执行语义搜索,自动执行增量索引并返回相关的代码片段。
| 参数 | 类型 | 必填 | 描述 | 示例 |
|---|---|---|---|---|
project_root_path | string |