netx/packages/netx-topology-mcp
oliver ed820126df Fix the 5 failing netx-topology-mcp tests.
Stale tests (behavior changed intentionally on 2026-08-12):
- Tool count is 16: suggestSinkHubs and classifyTopologyFabricNodes are
  documented public tools; assert them by name.
- compose_views is no longer a public layout action; assert it is
  rejected, and cover the background-job path via orbit_sweep instead.
- Dual-unit petals are nested ellipse bands with a hollow eye, not
  parallel lanes; assert side split, ordering inside the portals and
  zero crossings instead of portal-aligned lane ends.

Real bug (test failed since it was added on 2026-08-09):
press_hot_edges could never reel a long spoke in to its r_use target,
because max_disp (r0*0.55) is smaller than r0 - r_use. Inward pulls along
the spoke cannot fling a leaf across the bbox, so give them a cap of
r0 - r_use. On a 1483-node dev view crossings after the op drop
25501 -> 25346; a 500-node view is unchanged; runtime unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 22:16:37 +08:00
..
src/netx_topology_mcp Fix the 5 failing netx-topology-mcp tests. 2026-10-12 22:16:37 +08:00
tests Fix the 5 failing netx-topology-mcp tests. 2026-10-12 22:16:37 +08:00
mcp.json Converge netx-topology MCP to dual-unit drain + orbit/polish mainline. 2026-08-09 23:18:53 +08:00
pyproject.toml Converge netx-topology MCP to dual-unit drain + orbit/polish mainline. 2026-08-09 23:18:53 +08:00
README.md Converge netx-topology MCP to dual-unit drain + orbit/polish mainline. 2026-08-09 23:18:53 +08:00
SKILLS.md Add shared skills tree and rename MCP NMS tools to *Nms*. 2026-09-06 01:46:21 +08:00

netx-topology-mcp

独立的 stdio MCP,只暴露 netx 拓扑画布 / Fabric 能力,与告警/CLI 的 netx-mcp 分开安装,方便 Agent 按需启用。

MCP 宿主  →  stdio  netx_topology_mcp  →  HTTP  NETX_API_URL  →  netx API /v1/topology/*

详细说明 → docs/MCP_TOPOLOGY.md

配套 Skill → .cursor/skills/netx-topology(画图流水线与硬规则)

目录模型

  • 顶级「根」为导航;其下「根图」/ Root map 为画布。
  • 只用 createTopologyFolder:顶级建根+根图;根图下建子区域(各带 physical view_id)。
  • 不提供 createTopologyView(禁止同目录另挂 custom 交付图)。

安装

cd D:\project\chatgpt\netx
pip install -e ./packages/netx-topology-mcp
# optional: igraph for soft-block Leiden / block-center FR (layout still ours)
pip install -e "./packages/netx-topology-mcp[layout]"
python -c "import netx_topology_mcp; print('ok')"

GitHub:

pip install "git+https://github.com/hansjone/netx.git#subdirectory=packages/netx-topology-mcp"

配置

复制 mcp.json 到 Cursor / oclaw(server_id=netx-topology),可与 netx 同时存在。

画图请在 env 里设带 ne:write 的 NETX_API_TOKEN(不要只靠仓库 mcp_token)。getTopologyView / projectTopologyNeighbors 默认 detail=summary(坐标抽样 + links[] 邻接);queryTopologyEdges 默认 adjacency(一对网元一条线),避免整图/端口边占满上下文。

工具(14)

类别 工具
树/区域/画布 getTopologyTree, createTopologyFolder(唯一建图,返回 view_id), getTopologyView
画图 addTopologyViewNodes / remove… / sinkTopologyDualUnits(分批沉入+默认可先 layout_dual_unit) / copyTopologyViewNodes(一键克隆测沙箱) / update…Positions(优先筛选,API 自选 id;也可 id 列表), projectTopologyNeighbors
Fabric 只读 queryTopologyFabricNodes(summary|list|search), queryTopologyNeighborhood, queryTopologyEdges
自动布图 layoutTopologyView(小图 compact/corridor/rings;巨图:sinkTopologyDualUnits→orbit_sweep→polish_crossings→clear_edge_hits)
布图验收/规划 analyzeTopologyViewLayout(score;detail=structure 定重心;both=structure+手拖 sight)

安全约束: MCP 不会创建 Fabric 占位节点、不会写手工链路;画布只能引用已存在的 fabric 节点。