netdiag MCP

io.github.shigechika由 GitHub 帳號 shigechika 發布v0.8.1更新於 Oct 26, 2026

MCP server wrapping dig, ping, mtr, whois and TLS/HTTP checks for on-demand network diagnostics

概覽

AI 產生的概覽

本機 MCP 伺服器,包裝 dig、ping、mtr、whois 與 TLS/HTTP 檢查,讓助理依需求執行單次網路診斷。

可以做什麼
  • 解析 DNS 記錄,並透過一般 DNS、DoT 或 DoH 檢查 DNSSEC 驗證結果
  • 對主機執行 ping,並取得以 mtr 為基礎的逐跳路徑報告
  • 檢查單一 TCP 埠是否開放,並檢視 HTTP 狀態、重新導向鏈與延遲
  • 從網址取得文字或 JSON 回應內容
  • 檢視 TLS 憑證的主體、簽發者、有效期限與 SAN
  • 查詢網域 WHOIS、IP 的 ASN 與國別代碼,以及指定 IANA 時區的目前時間
適用情境
適合排查「連不上某個位址」或「DNS 是否已生效」這類問題,也適合讓助理不必每次登入跳板機執行 dig、ping、curl,就能蒐集 DNS、連通性、TLS 與 WHOIS 資訊。
執行需求
以本機 stdio 程序執行,從 PyPI 安裝(pip 或 uv tool install);Claude Code 外掛透過 uvx 啟動,因此 uvx 必須在 PATH 中。DNS、ping、traceroute 與 WHOIS 工具需要主機安裝 dig、ping、mtr、whois;DoT/DoH 需要 BIND 9.18+ 的 dig。mtr 需要 raw socket 權限。除非啟用 http_get 憑證,否則不需要環境變數。
安裝前請注意
選用的 NETDIAG_HTTP_AUTH 保存供 http_get 使用的憑證;它只從環境變數讀取並在輸出中遮蔽,但若目標端點會轉換該值仍可能外洩,因此前綴只應指向自己控制的端點。工具會向模型選定的目標發出對外網路請求,http_get 會回傳回應內容。所有工具皆為唯讀、單一目標,沒有掃描模式。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 netdiag MCP,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

netdiag-mcp

English | 日本語

MCP server for on-demand network diagnostics — DNS lookups (with a DNSSEC AD-bit check), ping, an mtr-based path report, TCP port checks, HTTP status/redirect checks, TLS certificate inspection, and WHOIS, all from one server.

Built for triaging "can't reach X" / "is DNS propagated yet" reports without shelling into a jump host for each one-off dig/ping/curl.

Tools

ToolPurpose
dns_lookupResolve a DNS record via dig (A/AAAA/MX/TXT/NS/CNAME/SOA/PTR/CAA), optionally against a specific resolver and over plain DNS/DoT/DoH
dnssec_checkQuery a known-validating resolver and report whether the AD bit is set (plain/DoT/DoH) — the only reliable way to confirm DNSSEC validation, since an RRSIG being present in a plain dig reply does not by itself prove anything validated it
ping_hostICMP ping (count clamped to 1-10)
traceroute_pathHop-by-hop path/loss report via mtr --report (fixed cycles, not a live/continuous run)
tcp_port_checkIs a TCP port open — a plain socket connect, not a port scan
http_checkHEAD/GET a URL and report status, redirect chain, and latency
http_getGET a URL and return the body. Textual types only (text/*, JSON, XML, JavaScript, YAML, +json/+xml), capped at 1 MiB. Refuses loopback, link-local and cloud-metadata destinations, including via redirect
tls_cert_checkFetch the certificate a host presents and report subject/issuer/validity/SANs
whois_lookupWHOIS lookup for a domain
asn_lookupASN + country-code lookup for an IP, or org info for an AS number, via Team Cymru's whois service — no API key or GeoIP database needed
current_timeCurrent date, time and weekday in an IANA timezone — the weekday is returned as data because deriving it from a date is arithmetic that fails silently. Also reports UTC and epoch, so it doubles as a clock check
health_checkVersion and which wrapped binaries (dig/ping/mtr/whois) are present on PATH

All tools are read-only and single-target (no batch/sweep mode) — this is a convenience wrapper around checks an operator would run by hand, not a scanning tool. nmap-style multi-host/multi-port scanning is intentionally out of scope; deliberately probing many hosts or ports is a different, higher-blast-radius action that deserves its own tooling and approval flow.

tcp_port_check, http_check, http_get and tls_cert_check use Python's own socket/ssl/httpx stack rather than shelling out to nc/curl/openssl, so those four tools work even on a host with only the dig/ping/mtr/whois binaries installed (or none of them — health_check reports which are missing without failing the whole server).

dns_lookup/dnssec_check support DNS-over-TLS and DNS-over-HTTPS via transport="dot"/"doh" (dig's +tls/+https). This needs dig from BIND 9.18+ — an older dig rejects the flag outright rather than silently falling back to plain DNS, so a stale binary fails loudly instead of giving a false sense of having checked over an encrypted transport.

tls_cert_check/http_check against a bare IP address can fail TLS handshake with a "handshake failure" or similar error on SNI-hosted / CDN-fronted origins (e.g. behind Cloudflare) — TLS's SNI extension only carries hostnames, so an IP literal can't route to the right certificate on a shared edge. This is normal TLS behavior, not a tool bug; check by hostname when the target is CDN-fronted.

Setup

1. System dependencies

dns_lookup, dnssec_check, ping_host, traceroute_path and whois_lookup shell out to dig, ping, mtr and whois respectively. Install whichever of these you want available:

bash
# Debian/Ubuntusudo apt install dnsutils iputils-ping mtr-tiny whois

mtr needs raw-socket access. Debian/Ubuntu's mtr-tiny package grants cap_net_raw to the mtr-packet helper at install time, so it normally works for an unprivileged service user without further setup — verify with getcap "$(command -v mtr-packet)" if traceroute_path reports a socket permission error. Without that capability, traceroute_path fails cleanly with a ToolError rather than crashing the server.

2. Install

bash
pip install netdiag-mcp# oruv tool install netdiag-mcp

3. Claude Code (plugin)

This repository doubles as a single-plugin marketplace, so Claude Code can install the server for you:

/plugin marketplace add shigechika/netdiag-mcp/plugin install netdiag-mcp@netdiag-mcp

The plugin launches uvx netdiag-mcp. No environment variables are required — the only prerequisite is the system dependencies above, and the TCP, HTTP and TLS checks work even without them.

uvx must be on the PATH of the process that runs Claude Code — a login shell usually has it, but a GUI-launched app may not; install uv system-wide if the plugin fails to start.

4. Claude Code (manual)

bash
claude mcp add netdiag -- netdiag-mcp

No environment variables are required.

5. Codex

bash
codex mcp add netdiag -- netdiag-mcp

Any other MCP client that launches stdio servers works the same way: give it netdiag-mcp as the command.

Optional: credentials for http_get

http_get can send an Authorization header to URLs under a configured https prefix, for reading a protected JSON endpoint without handing the credential to the model. Set NETDIAG_HTTP_AUTH to a JSON object mapping prefix to header value:

bash
NETDIAG_HTTP_AUTH='{"https://reports.example.ac.jp/daily/": "Bearer <token>"}'
  • The header is chosen per request and per redirect hop by comparing the parsed URL (https only, exact host and port, path prefix on a / boundary). A redirect to anywhere else drops it, along with any cookie set while it was attached. user@host URLs never match, and neither does a path with anything beyond letters, digits, ., _, ~, - and / (no %, ; or ./.. segments), so a server cannot normalise a matched URL out of the prefix. The longest matching prefix wins; two prefixes that differ only in case, :443 or a trailing dot are rejected as duplicates. Values must be printable ASCII.
  • netdiag-mcp never puts the value into its own output, errors or health_check; the result's status line says auth=applied when the final hop carried it, and health_check lists the configured prefixes in canonical form (not the values). Errors name a bad prefix by position, not by text. A response body under the prefix has the value (and its token part) masked as [redacted], but an endpoint that transforms it (for example base64) would still reveal it, so point a prefix only at endpoints you control.
  • A malformed value fails loudly: http_get returns an error and health_check reports degraded.
  • It is read from the environment only. If several instances run as the same user (for example one open to many users and one restricted), set it only in the environment of the instance that should send it — a file would be shared by all of them.

CLI

bash
netdiag-mcp --version   # print versionnetdiag-mcp --check     # report missing binaries and a malformed NETDIAG_HTTP_AUTH (exit 0 when all binaries are present and the setting, if any, parses)

Security notes

  • Every external-binary call passes an argv list (never a shell string), so no tool argument can break out into shell syntax.
  • Hostname/IP and port arguments are validated and size/range-clamped before use — tool input is model-driven and treated as untrusted, the same as any other tool-calling surface.
  • tcp_port_check connects to exactly one host:port per call; there is no loop or range argument, by design.
  • The optional http_get credential never leaves the configured https prefix and netdiag-mcp never prints it; a response body that echoes it is the server's doing (see above).

Development

Live smoke test

Unit tests check logic against fixtures; they cannot tell you that a tool has stopped returning real data (a dead dig/ping/mtr/whois binary, a broken TLS trust store, a network that blocks outbound ICMP). scripts/ smoke_test.py runs every registered tool against real public endpoints and fails on empty, malformed or error answers:

bash
uv run python scripts/smoke_test.pyuv run python scripts/smoke_test.py --only ping --traceback
  • No inventory, so every target is a fixed public endpoint — Cloudflare's 1.1.1.1 and IANA's example.com (reserved for documentation/testing use, RFC 2606). This server takes no config and has nothing to discover a target from, unlike a device-fleet MCP server in this family.
  • tests/test_smoke_probes.py is the offline half: it only checks that every registered tool has a probe spec (and vice versa), so CI catches a tool added without deciding how anyone would know it works, without needing network access.

License

MIT

來源:README.md,提交 de70a6c

工具

12

health_check

Service health: version, which wrapped binaries are present on PATH, and the http_get auth prefixes. Returns a fixed shape (status/service/version + backend fields) so a monitoring caller never has to branch on missing keys. status is "healthy" when every wrapped binary is found and NETDIAG_HTTP_AUTH (if set) parses, "degraded" otherwise (the affected tools fail at call time). http_auth lists the configured URL prefixes, never the header values.

無需輸入參數。

dns_lookup

Resolve a DNS record via `dig`. record_type: A/AAAA/MX/TXT/NS/CNAME/SOA/PTR/CAA. Pass resolver to query a specific nameserver instead of the host default (e.g. to check whether a change has propagated to a given resolver). transport: "plain" (UDP/TCP 53, default), "dot" (DNS-over-TLS, 853) or "doh" (DNS-over-HTTPS, 443). Requires dig from BIND 9.18+; an older dig rejects dot/doh outright instead of silently querying over plain DNS.

輸入參數hostname必填resolvertransportrecord_type

dnssec_check

Check whether a name validates DNSSEC against a known-validating resolver (AD bit). transport: "plain" (default), "dot" or "doh" — compare validation over plain DNS vs. an encrypted transport when port 53 may be intercepted.

輸入參數hostname必填resolvertransport

ping_host

ICMP ping a host or IP. count is clamped to 1-10.

輸入參數host必填count

traceroute_path

Path/MTU-style hop report via `mtr --report` (fixed cycles, not a live run). cycles clamped 1-10.

輸入參數host必填cycles

tcp_port_check

Check whether a TCP port is open (plain socket connect, no port scanning).

輸入參數host必填port必填timeout

http_check

HEAD/GET a URL and report status, redirect chain and latency.

輸入參數url必填timeout

http_get

GET a URL and return the response body (text/JSON/XML only, capped at max_bytes, hard cap 1 MiB). Use this to read a JSON endpoint or inspect an error page. For status/latency only, use http_check instead.

輸入參數url必填timeoutmax_bytes

tls_cert_check

Fetch the TLS certificate presented on host:port and report subject/issuer/validity/SANs.

輸入參數host必填port

whois_lookup

WHOIS lookup for a domain.

輸入參數domain必填

asn_lookup

ASN + country-code lookup for an IP, or org info for an AS number (e.g. AS15169 or 15169). Via Team Cymru's whois service — no API key or GeoIP database needed. Takes an IP literal or AS number, not a hostname; resolve first with dns_lookup if you only have a name.

輸入參數target必填

current_time

Current date, time and weekday in an IANA timezone (e.g. "Asia/Tokyo"). Call this rather than deriving the weekday from a date yourself — that is calendar arithmetic and it fails silently. Returns the date, the 24h time, the weekday in English and Japanese, the offset, UTC and the epoch, so it also serves as a clock check on this server.

輸入參數timezone

版本歷史

4
  1. v0.8.1最新Oct 26, 2026
  2. v0.8.0Oct 12, 2026
  3. v0.7.0Sep 29, 2026
  4. v0.6.1Sep 16, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分