Acemcp is an MCP server that provides code repository indexing and semantic search capabilities for codebases. It offers a `search_context` tool that performs automatic incremental indexing and semantic search across code files, returning formatted code snippets with file paths and line numbers, while supporting multiple file encodings and .gitignore integration. The server includes a web management interface for configuration, real-time logging, and tool debugging, solving the problem of quickly finding relevant code context within large projects without requiring manual indexing.
简体中文 | English
代码库索引和语义搜索的 MCP 服务器。
# 安装到系统
uv tool install acemcp
# 或临时运行(无需安装)
uvx acemcp
# 克隆仓库
git clone https://github.com/qy527145/acemcp.git
cd acemcp
# 安装依赖
uv sync
# 运行
uv run acemcp
配置文件会在首次运行时自动创建在 ~/.acemcp/settings.toml,包含默认值。
编辑 ~/.acemcp/settings.toml 进行配置:
BATCH_SIZE = 10
MAX_LINES_PER_BLOB = 800
BASE_URL = "https://your-api-endpoint.com"
TOKEN = "your-bearer-token-here"
TEXT_EXTENSIONS = [".py", ".js", ".ts", ...]
EXCLUDE_PATTERNS = [".venv", "node_modules", ".git", "__pycache__", "*.pyc", ...]
配置选项:
BATCH_SIZE: 每批上传的文件数量(默认:10)MAX_LINES_PER_BLOB: 大文件分割前的最大行数(默认:800)BASE_URL: API 端点 URLTOKEN: 认证令牌TEXT_EXTENSIONS: 要索引的文件扩展名列表EXCLUDE_PATTERNS: 要排除的模式列表(支持通配符如 *.pyc)您还可以通过以下方式配置:
--base-url、--tokenACEMCP_ 前缀)将以下内容添加到您的 MCP 客户端配置中(例如 Claude Desktop):
{
"mcpServers": {
"acemcp": {
"command": "uvx",
"args": [
"acemcp"
]
}
}
}
可用的命令行参数:
--base-url: 覆盖 BASE_URL 配置--token: 覆盖 TOKEN 配置--web-port: 在指定端口启用 Web 管理界面(例如 8080)要启用 Web 管理界面,添加 --web-port 参数:
{
"mcpServers": {
"acemcp": {
"command": "uvx",
"args": [
"acemcp",
"--web-port",
"8888"
]
}
}
}
然后访问管理界面:http://localhost:8888
Web 管理功能:
search_context 工具,输入项目路径和查询基于查询搜索相关的代码上下文。此工具在搜索前自动执行增量索引,确保结果始终是最新的。它在您的代码库中执行语义搜索,并返回格式化的文本片段,显示相关代码的位置。
核心特性:
.gitignore 模式参数:
project_root_path(字符串):项目根目录的绝对路径
/)作为路径分隔符C:/Users/username/projects/myproject/home/username/projects/myprojectquery(字符串):用于查找相关代码上下文的自然语言搜索查询
返回内容:
查询示例:
查找配置代码:
{
"project_root_path": "C:/Users/username/projects/myproject",
"query": "日志配置 设置 初始化 logger"
}
返回:与日志设置、logger 初始化和配置相关的代码
查找认证逻辑:
{
"project_root_path": "C:/Users/username/projects/myproject",
"query": "用户认证 登录 密码验证"
}
返回:认证处理器、登录函数、密码验证代码
查找数据库代码:
{
"project_root_path": "C:/Users/username/projects/myproject",
"query": "数据库连接池 初始化"
}
返回:数据库连接设置、连接池配置、初始化代码
查找错误处理:
{
"project_root_path": "C:/Users/username/projects/myproject",
"query": "错误处理 异常 try catch"
}
返回:错误处理模式、异常处理器、try-catch 块
查找 API 端点:
{
"project_root_path": "C:/Users/username/projects/myproject",
"query": "API 端点 路由 HTTP 处理器"
}
返回:API 路由定义、HTTP 处理器、端点实现
获得更好结果的技巧:
索引特性:
.gitignore 模式,与配置的排除模式结合使用搜索特性:
默认排除模式:
.venv, venv, .env, env, node_modules, .git, .svn, .hg, __pycache__,
.pytest_cache, .mypy_cache, .tox, .eggs, *.egg-info, dist, build,
.idea, .vscode, .DS_Store, *.pyc, *.pyo, *.pyd, .Python,
pip-log.txt, pip-delete-this-directory.txt, .coverage, htmlcov,
.gradle, target, bin, obj
模式支持通配符(*、?),并匹配目录/文件名或路径。
注意: 如果项目根目录存在 .gitignore 文件,其模式将自动加载并与配置的排除模式结合使用。.gitignore 模式遵循 Git 的标准 wildmatch 语法。
Acemcp 自动检测和处理不同字符编码的文件,适用于国际化项目:
这对以下情况特别有用:
Acemcp 自动遵守您项目的 .gitignore 文件:
.gitignoreEXCLUDE_PATTERNS 一起工作.gitignore.gitignore 模式示例:
# 依赖
node_modules/
vendor/
# 构建输出
dist/
build/
*.pyc
# IDE 文件
.vscode/
.idea/
# 环境文件
.env
.env.local
所有这些模式在索引期间都会自动遵守,并与默认排除模式结合使用。
search_context 搜索代码上下文
.gitignore 模式~/.acemcp/settings.toml~/.acemcp/data/projects.json(固定位置)~/.acemcp/log/acemcp.log(自动轮转)应用程序自动记录日志到 ~/.acemcp/log/acemcp.log,具有以下特性:
.zip 格式日志格式:
2025-11-06 13:51:25 | INFO | acemcp.server:main:103 - Starting acemcp MCP server...
日志文件在首次运行时自动创建,无需手动配置。
Web 管理界面提供:
要启用 Web 界面,在启动服务器时使用 --web-port 参数。
功能:
新特性:
/api/failed-blobs API 接口,支持 web 控制台显示异常信息技术细节:
_binary_search_failed_blobs() 递归二分法算法,O(log n) 复杂度failed_blobs.json 存储文件,记录项目异常 blob 信息改进:
search_context 工具的提示词描述错误修复:
.env 文件时,因编码错误导致 acemcp 启动失败的问题依赖更新:
新特性:
改进:
新特性:
技术细节:
/api/validate-token API 端点改进:
新特性:
改进:
InterceptHandler 拦截所有标准库日志/api/tools 端点列出可用工具技术细节:
InterceptHandler 类来拦截标准库 logginglog_config=None 禁用默认日志~/.acemcp/log/acemcp.log新特性:
.gitignore 模式改进:
错误修复: