MCP server providing TCP connectivity checks, DNS resolve, and system ping
Project description
MCP 网络连通性测试服务(Python)
该服务提供在模型调试与运维排障场景中常用的网络连通性测试能力:TCP 连通检查、次数统计的“TCP ping”、DNS 解析以及系统 ping。
安装
- 从源码:
pip install -r requirements.txt
- 从 PyPI(发布后):
pip install mcp-network-tester
建议使用虚拟环境。
运行(命令行)
安装后将提供命令 mcp-network-tester,以 stdio 方式启动 MCP 服务器:
mcp-network-tester
运行(配合 MCP Inspector)
- 启动 Inspector:
npx @modelcontextprotocol/inspector - 在 Inspector 中添加自定义服务器:
- Command:
mcp-network-tester
- Command:
- 连接后即可在 Tools 面板看到以下工具:
tcp_check、tcp_ping、dns_resolve、system_ping。
将其接入到支持 MCP 的客户端
以通用配置为例:
{
"mcpServers": {
"fetch": {
"args": [
"-m",
"mcp_network_tester"
],
"command": "python"
}
}
}
工具说明
tcp_check(host: str, port: int, timeout_seconds: float = 2.0)- 单次 TCP 连接测试,返回 JSON 字符串,含
reachable与latency_ms。
- 单次 TCP 连接测试,返回 JSON 字符串,含
tcp_ping(host: str, port: int, count: int = 4, interval_seconds: float = 0.2, timeout_seconds: float = 2.0)- 多次 TCP 连接测试,统计成功率与时延(适合排查本地到 Docker 暴露端口是否可达)。
dns_resolve(host: str)- 解析 A/AAAA 记录,返回所有地址。
system_ping(target: str, count: int = 4, timeout_seconds: float = 2.0, size: int = 32)- 调用系统
ping(Windows 与 Linux/macOS 自动适配)。可能需要权限。
- 调用系统
发布到 PyPI(公共平台)
- 安装构建与发布工具:
pip install build twine
- 构建分发包:
python -m build
生成dist/*.tar.gz与dist/*.whl。 - 上传到 TestPyPI 验证:
twine upload -r testpypi dist/*
- 上传到正式 PyPI:
twine upload dist/*
请在
pyproject.toml中更新作者信息、主页链接等元数据;确保LICENSE为你选择的许可协议(默认 MIT)。版本号按语义化版本管理递增。
注意
system_ping依赖系统命令;若不可用,将返回错误信息。- TCP 检测依赖目标服务监听状态与本机出站规则,失败时请结合 DNS、系统防火墙与容器网络配置综合排查。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 mcp_network_tester-0.1.0.tar.gz.
File metadata
- Download URL: mcp_network_tester-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6024086a351c8b18b5ca3a8a949f4bc6023479a16ae0795b3af2bf5e6fe08a02
|
|
| MD5 |
824557c2d7925a43c5e8e52ab9d8a83f
|
|
| BLAKE2b-256 |
b344c09f36aea353f10bdff5ce39f62db8704116b46da6c8b7ed25ada90525da
|
File details
Details for the file mcp_network_tester-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_network_tester-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69e015d925ad6e1972a6c252aead4cfbf5940981fe1960ccade7764fd90e254a
|
|
| MD5 |
14da7af4d779cc355079159fcff2ad33
|
|
| BLAKE2b-256 |
3232d4c340690bdccf9dea8910effc76b06cd1289d1c764f346c50f35e049b3e
|