MCP server for Cangjie programming language - documentation search and code intelligence
Project description
Cangjie MCP Server
仓颉编程语言的 MCP (Model Context Protocol) 服务器,提供文档搜索和代码智能功能。
功能
- 文档搜索: 基于向量检索的仓颉语言文档搜索
- 代码智能: 基于 LSP 的代码补全、跳转定义、查找引用等功能
- 可选远程文档服务: 支持连接远程文档/索引服务,减少本地资源占用,适合开箱即用或团队共享
安装
pip install cangjie-mcp
或使用 uvx 直接运行(推荐):
uvx cangjie-mcp # 启动 MCP 服务器
安装并指定 Rust feature
当平台没有预编译 wheel,或你希望按需启用 GPU/NPU 等加速后端时,可强制从 sdist 构建并传入 maturin 构建参数:
pip install --no-binary cangjie-mcp cangjie-mcp \
--config-settings=build-args="--features local"
可用 feature(传给 cangjie-mcp-cli):
local:本地向量化(CPU;默认构建的二进制已启用)legacy:本地向量化改用ort-tract后端(适配旧 glibc 构建)local-cuda/local-cudnn:启用 CUDA/CUDNN 后端local-metal:启用 Apple Metal 后端local-mkl/local-accelerate:启用 MKL / Accelerate 后端
架构
cangjie-mcp 支持两种运行模式:
本地模式(默认)
MCP 服务器在本地加载检索索引(BM25 + 向量索引),直接处理查询。
cangjie-mcp
远程文档服务模式(可选)
如果你不想在本机下载/加载向量模型与索引(或希望多人/多台机器共享同一套索引),可以把检索能力以 HTTP 的方式独立部署。之后 MCP 只需要通过 --server-url 连接,就能直接使用文档检索能力。
# 终端 1:启动 HTTP 查询服务器
cangjie-mcp server --embedding local --port 8765
# 终端 2:启动 MCP 服务器,连接远程索引
cangjie-mcp --server-url http://localhost:8765
快速配置
公共文档服务器已部署在 https://cj-mcp.learningman.top,连接后无需本地加载嵌入模型,开箱即用。
注意:LSP 功能需要已安装仓颉 SDK,请将
/path/to/cangjie-sdk替换为实际路径,或设置CANGJIE_HOME环境变量。
Claude Code(推荐)
claude mcp add \
-e CANGJIE_SERVER_URL=https://cj-mcp.learningman.top \
-e CANGJIE_HOME=/path/to/cangjie-sdk \
cangjie -- uvx cangjie-mcp
Cursor / Windsurf / Claude Desktop
配置文件路径:
- Cursor:
~/.cursor/mcp.json - Windsurf:
~/.codeium/windsurf/mcp_config.json - Claude Desktop (macOS):
~/Library/Application Support/Claude/claude_desktop_config.json - Claude Desktop (Windows):
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"cangjie": {
"command": "uvx",
"args": ["cangjie-mcp"],
"env": {
"CANGJIE_SERVER_URL": "https://cj-mcp.learningman.top",
"CANGJIE_HOME": "/path/to/cangjie-sdk"
}
}
}
}
VS Code (GitHub Copilot)
settings.json:
{
"mcp": {
"servers": {
"cangjie": {
"command": "uvx",
"args": ["cangjie-mcp"],
"env": {
"CANGJIE_SERVER_URL": "https://cj-mcp.learningman.top",
"CANGJIE_HOME": "/path/to/cangjie-sdk"
}
}
}
}
}
Zed
~/.config/zed/settings.json:
{
"context_servers": {
"cangjie": {
"command": {
"path": "uvx",
"args": ["cangjie-mcp"],
"env": {
"CANGJIE_SERVER_URL": "https://cj-mcp.learningman.top",
"CANGJIE_HOME": "/path/to/cangjie-sdk"
}
}
}
}
}
本地模式(不使用远程服务器)
如需完全离线使用或自建索引,可不设置 CANGJIE_SERVER_URL,MCP 会在本地加载嵌入模型和索引:
claude mcp add \
-e CANGJIE_RERANK_TYPE=local \
-e CANGJIE_HOME=/path/to/cangjie-sdk \
cangjie -- uvx cangjie-mcp
可用工具
文档搜索
| 工具名称 | 功能 |
|---|---|
cangjie_search_docs |
语义搜索仓颉文档 |
cangjie_get_topic |
获取指定主题的完整内容 |
cangjie_list_topics |
列出所有可用主题 |
代码智能
需要设置
CANGJIE_HOME环境变量指向仓颉 SDK 路径,LSP 工具才会注册。
| 工具名称 | 功能 |
|---|---|
cangjie_lsp_definition |
跳转到符号定义 |
cangjie_lsp_references |
查找符号的所有引用 |
cangjie_lsp_hover |
获取符号的类型信息和文档 |
cangjie_lsp_symbols |
列出文档中的所有符号 |
cangjie_lsp_diagnostics |
获取文件的错误和警告 |
cangjie_lsp_completion |
获取代码补全建议 |
命令行参考
cangjie-mcp
启动 MCP 服务器,同时提供文档搜索和 LSP 代码智能功能。LSP 功能在设置了 CANGJIE_HOME 环境变量时自动启用。
cangjie-mcp [OPTIONS]
选项
| CLI 参数 | 环境变量 | 默认值 | 说明 |
|---|---|---|---|
-v, --version |
- | - | 显示版本并退出 |
--log-file PATH |
CANGJIE_LOG_FILE |
- | 日志文件路径 |
--debug / --no-debug |
CANGJIE_DEBUG |
--no-debug |
启用调试模式,将 stdio 流量写入日志文件 |
-V, --docs-version TEXT |
CANGJIE_DOCS_VERSION |
latest |
文档版本 (git tag) |
-l, --lang TEXT |
CANGJIE_DOCS_LANG |
zh |
文档语言 (zh / en) |
-e, --embedding TEXT |
CANGJIE_EMBEDDING_TYPE |
none |
向量化类型 (none / local / openai) |
--local-model TEXT |
CANGJIE_LOCAL_MODEL |
paraphrase-multilingual-MiniLM-L12-v2 |
本地 HuggingFace 向量化模型 |
--openai-api-key TEXT |
OPENAI_API_KEY |
- | OpenAI API 密钥 |
--openai-base-url TEXT |
OPENAI_BASE_URL |
https://api.openai.com/v1 |
OpenAI API 基础 URL |
--openai-model TEXT |
OPENAI_EMBEDDING_MODEL |
text-embedding-3-small |
OpenAI 向量化模型 |
-r, --rerank TEXT |
CANGJIE_RERANK_TYPE |
none |
重排序类型 (none / local / openai) |
--rerank-model TEXT |
CANGJIE_RERANK_MODEL |
BAAI/bge-reranker-v2-m3 |
重排序模型 |
--rerank-top-k INT |
CANGJIE_RERANK_TOP_K |
5 |
重排序后返回结果数 |
--rerank-initial-k INT |
CANGJIE_RERANK_INITIAL_K |
20 |
重排序前候选数 |
--chunk-size INT |
CANGJIE_CHUNK_MAX_SIZE |
6000 |
最大分块大小(字符数) |
-d, --data-dir PATH |
CANGJIE_DATA_DIR |
~/.cangjie-mcp |
数据目录路径 |
--server-url TEXT |
CANGJIE_SERVER_URL |
- | 远程查询服务器 URL |
LSP 功能通过以下环境变量控制:
| 环境变量 | 说明 |
|---|---|
CANGJIE_HOME |
仓颉 SDK 路径,设置后自动启用 LSP 工具 |
cangjie-mcp server
启动 HTTP 查询服务器,加载本地检索索引(BM25 + 向量索引),通过 HTTP 提供查询服务。
cangjie-mcp server [OPTIONS]
支持所有与 cangjie-mcp 相同的索引选项,以及:
| CLI 参数 | 环境变量 | 默认值 | 说明 |
|---|---|---|---|
--host TEXT |
CANGJIE_SERVER_HOST |
127.0.0.1 |
HTTP 服务器监听地址 |
-p, --port INT |
CANGJIE_SERVER_PORT |
8765 |
HTTP 服务器监听端口 |
HTTP API
| 方法 | 路径 | 说明 |
|---|---|---|
GET |
/health |
健康检查 |
GET |
/info |
索引元数据 |
POST |
/search |
向量搜索 |
GET |
/topics |
列出所有分类和主题 |
GET |
/topics/{category}/{topic} |
获取文档内容 |
调试与日志
--log-file 和 --debug 配合使用,可以帮助排查 MCP 通信问题:
# 记录应用日志到文件
cangjie-mcp --log-file /tmp/cangjie.log
# 调试模式:额外记录 MCP stdio 协议流量
cangjie-mcp --log-file /tmp/cangjie.log --debug
# 通过环境变量配置
CANGJIE_LOG_FILE=/tmp/cangjie.log CANGJIE_DEBUG=1 cangjie-mcp
许可证
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cangjie_mcp-0.3.2.tar.gz.
File metadata
- Download URL: cangjie_mcp-0.3.2.tar.gz
- Upload date:
- Size: 152.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16f0e6a643064680d01b8748f051b5e440ef02a5031c23d5b4d3574d8941807f
|
|
| MD5 |
80debf4d933bb3e3a5569336bdd514a3
|
|
| BLAKE2b-256 |
6096d74f81229ec265d4ffc82e200d4fb160d1b46180ad811d96cbf0f9b96a17
|
File details
Details for the file cangjie_mcp-0.3.2-py3-none-win_amd64.whl.
File metadata
- Download URL: cangjie_mcp-0.3.2-py3-none-win_amd64.whl
- Upload date:
- Size: 23.8 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a790cf513a914a1a2199e765ea9efe2002b563cb191d68db229d3c9f660c5e4
|
|
| MD5 |
483c96d27372e1122b9a59714b12e05b
|
|
| BLAKE2b-256 |
f3b8b2e0adb9778080ef0ed3e8ae89e3c5fdec8c6f7b469eee9445fb71f7761c
|
File details
Details for the file cangjie_mcp-0.3.2-py3-none-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: cangjie_mcp-0.3.2-py3-none-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 25.6 MB
- Tags: Python 3, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a568a9735fd4efacff5e3981083affc971ea7e8c9e1f5a58b3054a3c27caf9d
|
|
| MD5 |
5e516365a5d99baa325e80df6a5c2939
|
|
| BLAKE2b-256 |
a7f27f7893bf910293e3f630d133c7260bc265229837529f5a1da522001ad027
|
File details
Details for the file cangjie_mcp-0.3.2-py3-none-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: cangjie_mcp-0.3.2-py3-none-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 25.9 MB
- Tags: Python 3, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c42e22fd8222f47e3a069a779c8d81729b93de8ba4379965232f40983f89bef3
|
|
| MD5 |
7968abecd11884c1cc8d3c96fa02536b
|
|
| BLAKE2b-256 |
f93fe34ed810f1f10f6e747e0540869427bfb6df04f9c89e76207af5b0a30820
|
File details
Details for the file cangjie_mcp-0.3.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: cangjie_mcp-0.3.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 23.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0249d828220834ad21ec587fb7f0b6a9a584e6609225b3517305b66ab2af64e
|
|
| MD5 |
1c823f4cf1604842d70c8bde3ea8941c
|
|
| BLAKE2b-256 |
84fb6a4dfbe30c0816ebde0b7dc39332ddca736c45634d25559bcc02b3ebeca5
|
File details
Details for the file cangjie_mcp-0.3.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: cangjie_mcp-0.3.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 21.9 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a2aea86ecda79a496baabab47ecb8a142122720d2145f30769d911ef64835e8
|
|
| MD5 |
5a1d07d16c45c3039f4ea9500be227d2
|
|
| BLAKE2b-256 |
afbdd78b7247da83136cd618fc543238e6853b8535ff99e344f4296f4c6b9dae
|
File details
Details for the file cangjie_mcp-0.3.2-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: cangjie_mcp-0.3.2-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 23.3 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84f047bc025fc37de9c88d71811166f645bff19bc0824227492a858998c01bbd
|
|
| MD5 |
a85d541f1e92ffafd08e2c25f49419ec
|
|
| BLAKE2b-256 |
c8a9b949a1f7f8063311307290ca6c437b3d869444245df6e55b98f318b43966
|