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:
venv (built-in)
python -m venv .venv
source .venv/bin/activate
pip install -r src/antd_mcp/requirements.txt
pyenv + venv
brew install pyenv
pyenv install 3.11.8
pyenv local 3.11.8
python -m venv .venv
source .venv/bin/activate
pip install -r src/antd_mcp/requirements.txt
Conda
conda create -n antd-mcp python=3.11 -y
conda activate antd-mcp
pip install -r src/antd_mcp/requirements.txt
Run Server
python -m antd_mcp
# or
python src/antd_mcp/server.py
JSON-RPC Examples
# List tools
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | python -m antd_mcp
# List components
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_components","arguments":{}}}' | python -m antd_mcp
# Get one component
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_component","arguments":{"name":"Button"}}}' | python -m antd_mcp
# Search components
echo '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"search_components","arguments":{"query":"form"}}}' | python -m antd_mcp
# Export all component data
echo '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"export_all","arguments":{}}}' | python -m antd_mcp
Export Output
Default file: src/antd_mcp/exports/antd_components_all.json
Structure:
{
"generated_at": <timestamp>,
"count": <number_of_components>,
"components": [
{
"name": "Button",
"title": "Button 按钮",
"intro": [...],
"props": [...],
"events": [...],
"methods": [...],
"other_tables": [...],
"table_summary": {"props":1,"events":0,...},
"examples": [...],
"source_url": "https://4x.ant.design/..."
}
]
}
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)
安装 (发布后)
pip install antd-mcp-server
安装后命令行入口:
antd-mcp --once '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
本地构建与发布
# 构建
python -m build
# 上传到 PyPI
python -m twine upload dist/*
供 AI 工具使用的 mcp.json 示例
{
"version": 1,
"servers": {
"antd_mcp": {
"command": "antd-mcp",
"args": [],
"timeoutSeconds": 60
}
}
}
环境变量
ANTD_MCP_CACHE_DIR自定义缓存目录。MCP_PRETTY/MCP_COLOR控制输出格式。
版本
当前版本: 0.1.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
antd_mcp_server-0.1.0.tar.gz
(4.8 kB
view details)
Built Distribution
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 antd_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: antd_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09f00c2774c93c6773e7704f4af4f0a136a08a559d8870b75a77d4997aff6790
|
|
| MD5 |
1b2ccedd125d6f0d14e963301a4dc386
|
|
| BLAKE2b-256 |
c372f51d9161df917e6faff3e3a919cc94d69efe73b4f20e644937927e1df7a1
|
File details
Details for the file antd_mcp_server-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: antd_mcp_server-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcedda53f856783add31b12fef512fb55511307133f8c410ddeec97976f4a4d4
|
|
| MD5 |
0f4b185159a8aa4e69d01ca73f77e031
|
|
| BLAKE2b-256 |
aec20b876359333f66eafb9e99ff32c9db42788a145228a5fbf0e53207c86d98
|