Fetches and structures Ant Design v4 component documentation, providing tools to list, search, retrieve, and export component metadata including props, events, methods, and usage examples.
Ant Design MCP Server (Python)
This Model Context Protocol (MCP) server fetches and structures Ant Design v4 (Chinese) component documentation into JSON so AI agents can perform analysis.
Features
Fetch overview page and individual component pages.
Extract component metadata: name, description, examples.
Classify API tables automatically (props / events / methods / other).
Cache fetched HTML locally.
Export all components into a single JSON file.
MCP tools exposed over JSON-RPC stdio.
Tools
list_components(force?)
get_component(name, force?)
search_components(query)
export_all(force?, filepath?)
Environment Setup
Choose one method (requirements are inside src/requirements.txt):
venv (built-in)
pyenv + venv
Conda
Run Server (Source Checkout)
Flat layout now exposes modules directly under src/:
Console scripts (after install or via pipx):
JSON-RPC Examples
Export Output
Default file: src/exports/antd_components_all.json
Structure:
TODO / Roadmap
More precise table classification rules (column semantics).
Parallel fetching & retry with backoff.
Version / language (en vs cn) selection.
CLI wrapper.
Optional rate limiting.
License
MIT (add if needed)
安装 (发布后)
安装后命令行入口:
然后向 stdin 逐行发送 JSON 请求。
本地构建与发布
自动化脚本
提供 scripts/release.sh 简化发布流程:
依赖:
已安装
build与twine(pip install build twine)已通过测试 (
pytest -q);脚本会先跑测试。PyPI 凭证 (推荐 Token):
export TWINE_USERNAME="__token__" export TWINE_PASSWORD="pypi-xxxxx" # 在 PyPI 创建的 token
脚本步骤:
检查 git 工作区是否干净
运行测试
更新
pyproject.toml中版本号提交并打 tag
v<version>构建 (wheel + sdist)
twine check验证上传 (跳过若 dry-run)
推送 commit 与 tag
注意事项:
使用
sed简单替换版本号行,保持现有格式。若需要预发行版本,可传入
0.2.0rc1等。若需要撤销,可删除 tag 并重置 commit:
git tag -d v0.1.1 && git reset --hard HEAD~1。
供 AI 工具使用的 mcp.json 示例
方式1:使用已安装的包(推荐)
首先安装包:
然后配置 mcp.json:
方式2:直接运行源码(开发模式)
如果未安装包,可以直接运行源码:
注意:使用方式2时,需要确保:
已安装依赖:
pip install -r src/requirements.txtcwd指向项目的src目录的绝对路径
环境变量
ANTD_MCP_CACHE_DIR自定义缓存目录。命令行参数:
--color启用彩色输出--pretty启用 JSON 格式化输出
版本
当前版本: 0.1.1
常见问题 (FAQ)
ModuleNotFoundError:
No module named 'antd_mcp'
已改为平铺布局,使用
python -m server或安装后使用antd-mcp-server。
输出出现多行 JSON 导致解析报错
仅解析第一行或使用流模式逐行处理。
想加速批量抓取
可后续新增并行与重试(Roadmap 中)。
如何发布新版本?
运行
./scripts/release.sh <version>,确保环境变量与权限正确。
如何进行试发布(dry run)?
增加
--dry-run参数,不上传、不推送。
如何本地测试安装?
使用
pipx install --force dist/antd_mcp_server-<version>-py2.py3-none-any.whl