Minimal FastMCP server dedicated to Sangfor CMDB workflows. It exposes only the domain lookup / creation tools plus supporting resources (product lines, Zeus user directory) so LLM clients can reason about CMDB data without any demo features like city prompts or echo helpers.
.
├─ app.py # Builds the FastMCP instance and runs the server
├─ config.py # ProjectConfig with CMDB + Zeus endpoint helpers
├─ logging_config.py # Rich console + file logging setup
├─ resources/ # CMDB product lines + Zeus users @resource definitions
├─ tools/ # CMDB domain tools (list + create)
├─ fastmcp.json # FastMCP CLI config (transport / host / port)
├─ pyproject.toml
├─ requirements.txt
└─ README.md
python -m venv .venv
.\.venv\Scripts\activate
pip install -e ".[dev]"
fastmcp dev # uses fastmcp.json (HTTP + SSE)Set CMDB_COOKIE in your shell or .env so both tools and resources can call
the Sangfor endpoints.
ProjectConfig defines:
cmdb_base_url: defaults tohttps://rudder.sangfor.com/cmdb/api/v1.cmdb_cookie: pulled fromCMDB_COOKIE.product_lines_url,user_directory_url,list_children_url,post_domain_url: derived helpers so every module uses consistent URLs.
- exist_cmdb_domain_list – GET
/deploy/tree/root/children/list- Params:
page,rows(default 10000),productId,childrenType. - Returns
{ query, total, domains[], raw }. domains[]fields include:addr: unique domain/addr string (主键,用于匹配/去重).domainId/id,productId,productName,teamId,teamName.- Contacts:
devBy,opsBy,useBy. - Network metadata:
domainType,domainTypeName,serveType,recordType,reflectAddr,regionId,regionName. - Audit info:
createdAt,updatedAt,createBy,updateBy.
- Params:
- create_cmdb_domain – POST
/deploy/domain- Payload mirrors the CMDB UI fields (
addr,productId,teamId,serveType,domainType,status,regionId, contacts, description). - Response returns
{ request, result }for traceability.
- Payload mirrors the CMDB UI fields (
Both tools validate that cmdb_cookie is set before making requests.
cmdb://product-lines- Calls
product_lines_url. - Response:
{ rows: 1000, products[], raw }. products[]fields:product_id,product_name,business_id,business_dept. Displayproduct_name, but sendproduct_idto CMDB APIs.
- Calls
zeus://users{?rows}- Calls
user_directory_urlwith configurablerows(default 1000). - Response:
{ rows, users[], raw }. users[]fields:id,name(account),display_name,full_name(优先使用),group,role.
- Calls
logging_config.py routes Rich logs to the console and logs/fastmcp.log.
Within tools/resources, use ctx.info/ctx.error so MCP clients receive
progress updates while operations run.
- 该项目仅保留 CMDB 相关能力:
exist_cmdb_domain_list/create_cmdb_domain工具,以及cmdb://product-lines、zeus://users资源。 addr是域名查询结果的唯一键,LLM 去重或匹配时务必按addr判断。product_name适合给用户展示,但在 POST/GET 参数中必须传product_id。full_name(姓名+工号)是 Zeus 用户目录的首选匹配字段。- 启动前在环境变量或
.env中设置CMDB_COOKIE,再运行fastmcp dev即可通过 MCP 客户端调用以上能力。