使用说明
MCP链接
MCP Links是一个用于检查的小型实用程序 模型上下文协议 (MCP)服务器/客户端,并可视化其拓扑结构。它可以导入实时FastMCP服务器,抓取多个MCP对象的目录,并将图形导出为HTML(可选的JSON输出用于工具)。
将其用作CLI 或 作为项目中的库,相同的发现、图构建和导出逻辑支持这两个入口点。
安装
# Clone the repo
git clone https://github.com/jacemElwaar1/mcp_links.git
cd mcp_links
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt # installs the same deps declared in pyproject
# (Optional) install editable with CLI entry point + HTML extras
pip install -e ".[viz]"
用法
# Introspect a single server object (module:attribute)
mcp-links introspect --server my_package.weather:mcp --out graph.html
# Bulk-discover every MCP object (FastMCP, low-level servers, etc.) under a directory or single file
mcp-links introspect --all ./servers --out overview.html
mcp-links introspect --all ./servers/weather.py --out weather_only.html
# Render to alternate formats
mcp-links introspect --server my_package.weather:mcp --format json > graph.json
使用 --view 使用HTML导出在默认浏览器中打开结果,而无需选择文件名:
mcp-links introspect --server my_package.weather:mcp --view
功能检查表(本地运行)
下面的每个命令都验证一个核心功能。激活虚拟环境后,从项目根目录运行它们。
-
单对象内省
PYTHONPATH=/path/to/project \ mcp-links introspect --server my_pkg.weather:mcp --out graph.html打开
graph.html以确保服务器和工具渲染。 -
跨文件夹的批量发现
PYTHONPATH=/path/to/project \ mcp-links introspect --all /path/to/project --out overview.html确认检测到多个MCP对象并将其组合在一个图中。
-
实时预览
PYTHONPATH=/path/to/project \ mcp-links introspect --server my_pkg.weather:mcp --view应导出到临时文件并启动默认浏览器。
-
用于工具的JSON导出
PYTHONPATH=/path/to/project \ mcp-links introspect --server my_pkg.weather:mcp --format json > graph.json验证节点/边缘元数据是否按预期显示。
-
程序化API
from mcp_links import discover_graph, Exporter graph = discover_graph("/path/to/project") Exporter.to_html(graph, "graph.html")当你不想掏腰包时,在笔记本或脚本中使用它。
-
捆绑样品项目
回购随附lib/test_case,其中包含weather+air_qualityFastMCP服务器。通过以下方式进行端到端验证:cd /path/to/mcp_links source .venv/bin/activate PYTHONPATH="$PWD/lib/test_case" \ mcp-links introspect --all lib/test_case --view
程序化API
from mcp_links import discover_graph, Exporter
graph = discover_graph("./servers")
Exporter.to_html(graph, "graph.html")
您还可以从特定对象构建图形:
from my_package import weather
from mcp_links import build_graph_from_object
graph = build_graph_from_object(weather.mcp)
发展
python -m venv .venv
source .venv/bin/activate
pip install -e ".[viz]"
python -m unittest discover
释放
- 将版本插入
pyproject.toml. - 运行测试(
python -m unittest discover)并浏览上面的功能检查表(单对象、批量发现、视图、JSON、API、捆绑示例)。 - 构建发行版:
python -m build. - 上传到PyPI:
python -m twine upload dist/*.