Skip to main content
Glama

inferdiff-mcp

Check live LLM streaming contracts or audit a pasted stream offline from an MCP client. inferdiff-mcp uses UTF-8 stdio and supports MCP 2024-11-05 and 2025-03-26. It runs on Python 3.11+ with inferdiff as its only runtime dependency.

在 MCP 客户端中检查在线 LLM 接口的流式响应协议,或离线审计粘贴的流式记录。服务通过 UTF-8 标准输入输出通信,支持 MCP 2024-11-05 和 2025-03-26,需要 Python 3.11+,唯一的运行时依赖是 inferdiff。

Quickstart / 快速开始

From this checkout, install into the Python environment your MCP client will use. 在项目目录中执行以下命令,安装到 MCP 客户端将使用的 Python 环境。

python -m pip install .
inferdiff-mcp --version

To install a published release, run python -m pip install inferdiff-mcp. 安装已发布版本可运行 python -m pip install inferdiff-mcp。

The server works with inferdiff 0.1.1. To use a local inferdiff-v02 checkout, set PYTHONPATH in the MCP server's environment to its src directory. Optional features are detected at runtime.

服务兼容 inferdiff 0.1.1。使用本地 inferdiff-v02 时,把其 src 目录加到 MCP 服务进程的 PYTHONPATH。服务启动后会根据可用功能运行。

Related MCP server: MCP Rigor

Client setup / 客户端配置

Copy the matching JSON into your client's config, or merge the inferdiff-mcp entry into the existing mcpServers object. Reload the client or its MCP servers. If the client cannot find the command, use the absolute path to the installed inferdiff-mcp executable (inferdiff-mcp.exe on Windows).

复制对应的 JSON 到客户端配置文件,已有 mcpServers 时只合并 inferdiff-mcp 一项。保存后重新加载客户端或 MCP 服务。如果客户端找不到命令,请填写已安装的可执行文件的绝对路径(Windows 上为 inferdiff-mcp.exe)。

Claude Desktop, Windsurf, Cline, Antigravity

{
  "mcpServers": {
    "inferdiff-mcp": {
      "command": "inferdiff-mcp",
      "args": []
    }
  }
}

Client / 客户端

Configuration / 配置入口

Claude Desktop

Settings → Developer → Edit Config. Windows %APPDATA%\Claude\claude_desktop_config.json, macOS ~/Library/Application Support/Claude/claude_desktop_config.json. Guide

Windsurf

Open the Cascade MCP configuration or edit ~/.codeium/windsurf/mcp_config.json. 在 Cascade 中打开 MCP 配置。 文档

Cline

MCP Servers → Configure → Configure MCP Servers opens cline_mcp_settings.json. Guide

Antigravity

MCP Servers → Manage MCP Servers → View raw config. Global ~/.gemini/config/mcp_config.json or workspace .agents/mcp_config.json. Guide

Claude Code, Cursor

{
  "mcpServers": {
    "inferdiff-mcp": {
      "type": "stdio",
      "command": "inferdiff-mcp",
      "args": []
    }
  }
}

Client / 客户端

Configuration / 配置入口

Claude Code

Project root .mcp.json. Use /mcp to check the connection. 项目根目录下的 .mcp.json,通过 /mcp 查看连接状态。 Guide

Cursor

Workspace .cursor/mcp.json or global ~/.cursor/mcp.json. Guide

You can also register the server from the Claude Code terminal. 也可以用 Claude Code 命令行注册。

claude mcp add --transport stdio inferdiff-mcp -- inferdiff-mcp

Run a check / 运行检查

Try this in your client with an OpenAI-compatible local server and a model it serves. 本地启动 OpenAI 兼容服务后,将下面的地址和模型换成实际值,再在客户端中试用。

Run doctor_endpoint for http://127.0.0.1:8000/v1/chat/completions, model my-model, profile quick. Summarize the grade, P0 breaches, and time to first token.

用 doctor_endpoint 检查 http://127.0.0.1:8000/v1/chat/completions,模型为 my-model,使用 quick 配置。汇报等级、P0 问题和首 token 延迟。

For authenticated endpoints, pass the credential's environment variable name as api_key_env, for example INFERDIFF_ENDPOINT_KEY. If the client passes through your environment, set the variable before launching the client. If it filters inherited variables, configure the variable under env in the MCP server entry in your private client config. Share only the variable name in chat.

如果接口需要鉴权,请把密钥的环境变量名(例如 INFERDIFF_ENDPOINT_KEY)作为 api_key_env 传入。若客户端会将环境变量传给服务,请在启动客户端之前设置。若客户端会过滤环境变量,请在私有配置的服务条目中通过 env 设置。聊天中只提供变量名。

Cursor and Windsurf can forward an existing environment variable using "env": {"INFERDIFF_ENDPOINT_KEY": "${env:INFERDIFF_ENDPOINT_KEY}"} in the server entry. Claude Code uses ${INFERDIFF_ENDPOINT_KEY} for the value. Cursor 和 Windsurf 可用前面的写法从客户端环境读取密钥,Claude Code 的引用语法为 ${INFERDIFF_ENDPOINT_KEY}。 Cursor · Windsurf · Claude Code

Tool / 工具

What it returns / 返回内容

doctor_endpoint

Wire Health Grade, checks, P0 breaches, and timing. Supports quick, full, and relay. Set report_path to an .html file to save the report. / 协议健康等级、检查明细、P0 问题和耗时。可用 report_path 将报告保存为 .html 文件。

compare_endpoints

Structured JSON and a Markdown table comparing model and fingerprint changes, finish reasons, the TTFT ratio (B ÷ A), and breaches. Pass url_a and url_b. Supply model to request the same model from both. / 提供 JSON 和 Markdown 对照表,展示模型与指纹变化、结束原因、首 token 延迟比(B ÷ A)和协议问题。

rank_endpoints

Live leaderboard for 2–5 endpoints as JSON and Markdown. Sorts by Contract Honesty Grade, P0 breach count, median TTFT, and total check latency, in that order. / 在线检查 2 至 5 个接口,按协议等级、P0 问题数、首 token 延迟中位数和检查总耗时依次排名,输出 JSON 与 Markdown。

audit_trace_file

Offline P0/P1 findings and frame statistics for a local .trace.jsonl at trace_path. / 离线分析 trace_path 指向的本地追踪文件,返回 P0/P1 问题和帧统计。

audit_sse_text

Accepts raw SSE or .trace.jsonl contents as text and an optional dialect. Returns a grade, detected protocol, frame count, findings, and a redacted issue summary of at most 25 lines. Runs offline. / 离线审计粘贴到 text 的 SSE 或 .trace.jsonl 内容,返回评级、协议、帧数、问题及最多 25 行的脱敏说明。

replay_trace_bundle

Offline breach diff for a trace file or directory, with an optional baseline directory. / 离线分析追踪文件或目录,并可与基准目录比较协议问题。

probe_catalog

Descriptions, severities, and recommended profiles for canaries C1–C10 and detectors D1–D8. Takes an empty arguments object and runs offline. / 离线列出 C1–C10 检查项和 D1–D8 检测器的说明、严重级别与推荐配置,参数为 {}。

export_issue_report

Redacted GitHub Issue or support ticket repro block of at most 25 lines from trace_path. / 根据本地追踪文件生成最多 25 行的脱敏复现说明。

Clients with MCP prompt support can also load verify_streaming_contract. 支持 MCP 提示词的客户端也可加载 verify_streaming_contract。

doctor_endpoint and compare_endpoints accept an optional protocol. It defaults to openai. Set it to anthropic or gemini with inferdiff v0.2 to run C9 or C10, respectively. A comparison uses the same protocol for both endpoints. Inferdiff 0.1.1 returns an unsupported_protocol error for these two options. Use replay_trace_bundle for detectors that need paired traces or recorded backend counters.

doctor_endpoint 和 compare_endpoints 接受可选的 protocol,默认为 openai。使用 inferdiff v0.2 时,可设为 anthropic 运行 C9,或设为 gemini 运行 C10。比较的两个接口使用相同协议。inferdiff 0.1.1 对这两个选项返回 unsupported_protocol 错误。需要对比两份追踪记录或分析后端计数器时,用 replay_trace_bundle。

For a comparison with separate credentials, use api_key_env_a and api_key_env_b. 两个对比接口使用不同密钥时,可分别设置 api_key_env_a 和 api_key_env_b。

Private and loopback endpoints are enabled by default for local development. Add "--no-allow-private-urls" to args to restrict checks to public endpoints. "--timeout", "30" sets the per-request network timeout in seconds (default 30).

默认允许访问私网和回环地址,便于本地调试。在 args 中加入 "--no-allow-private-urls" 可限制为公网接口。"--timeout", "30" 设置每次请求的网络超时,默认 30 秒。

Rank endpoints / 接口排名

Use the same profile for the whole run. Each endpoint supplies its own label, base_url, and model. For credentials, supply api_key_env or api_key per endpoint. The result includes the ordered rankings array and a Markdown leaderboard.

同一次排名使用同一个 profile。各接口分别设置 label、base_url 和 model,鉴权参数可选 api_key_env 或 api_key。输出包含排序后的 rankings 数组及 Markdown 榜单。

{
  "profile": "quick",
  "endpoints": [
    {"label": "Baseline", "base_url": "http://127.0.0.1:8000/v1", "model": "my-model"},
    {"label": "Candidate", "base_url": "http://127.0.0.1:8001/v1", "model": "my-model", "api_key_env": "CANDIDATE_KEY"}
  ]
}

Audit pasted streams / 审计粘贴的流式记录

Paste the stream into text and leave dialect at auto, or specify openai-chat, openai-responses, anthropic, or gemini. Include the trace header when checking whether requested usage was omitted. issue_markdown gives you a paste-ready summary with structural evidence such as frame numbers.

将流式记录粘贴到 text,可以用 auto 自动识别协议,也可以指定 openai-chat、openai-responses、anthropic 或 gemini。检查是否漏报请求的用量时,请包含追踪记录的头部。issue_markdown 提供可粘贴的问题说明和帧号等证据。

Replay trace bundles / 重放追踪记录

Pass a .trace.jsonl file or a directory of traces as path to replay_trace_bundle. Use baseline_dir to compare P0 and P1 findings by relative trace path, detector, breach code, and severity. The result contains NEW_BREACHES, FIXED_BREACHES, and UNCHANGED arrays. With no baseline, every reported breach counts as new. Inferdiff v0.2 also runs the paired D8 detector.

调用 replay_trace_bundle 时,path 可指向单个 .trace.jsonl 文件或追踪目录。传入 baseline_dir 后按相对路径、检测器、问题代码及严重级别比较 P0 和 P1 问题,结果分为新增、已修复及仍存在的问题。省略基准目录时,所有返回的问题均计为新增。inferdiff v0.2 还会对配对的记录运行 D8 检测器。

{"path": "traces/candidate", "baseline_dir": "traces/baseline"}

Browse trace resources / 浏览追踪资源

Set --trace-dir to expose trace summaries through MCP resources. For example, set the MCP server's args to ["--trace-dir", "/absolute/path/to/traces"]. resources/list lists .trace.jsonl files under that directory, including nested paths. A file at nightly/smoke test.trace.jsonl is listed as inferdiff://traces/nightly/smoke%20test.trace.jsonl. Pass the listed URI to resources/read for a compact, redacted JSON summary of findings and frame statistics.

设置 --trace-dir 可通过 MCP 资源查看追踪摘要。用 resources/list 浏览指定目录及其子目录中的 .trace.jsonl 文件,再将返回的 URI 传给 resources/read,获取脱敏后的问题及帧统计 JSON 摘要。

Tests / 测试

python -W error -m unittest discover -s tests -v

To test without installing, add this repository's src and your local inferdiff checkout's src to PYTHONPATH. Use ; to join them on Windows or : on Linux.

如需直接从源码测试,把本项目与本地 inferdiff 项目的 src 都加入 PYTHONPATH。Windows 用 ; 分隔,Linux 用 : 分隔。

GitHub Actions builds the wheel and runs the tests against the installed package on Ubuntu and Windows with Python 3.11 and 3.12. GitHub Actions 会在 Ubuntu 和 Windows 上用 Python 3.11 与 3.12 构建 wheel,并安装它来运行测试。

Releases / 发布

A pushed v*.*.* tag must match the package version, for example v0.2.0 for version 0.2.0. The release workflow checks and builds the source distribution and wheel, then attaches both to a GitHub Release.

推送的 v*.*.* 标签必须与包版本一致,例如 0.2.0 对应 v0.2.0。发布流程会构建并检查源码包与 wheel,再将两者附加到 GitHub Release。

To enable PyPI publishing, configure the pypi GitHub Actions environment and register a GitHub Trusted Publisher in PyPI with this repository's owner and name, workflow release.yml, and environment pypi. Set the repository's Actions variable ENABLE_PYPI_PUBLISH to true before pushing the tag. The publish job obtains its credentials through OIDC. Existing PyPI project · First PyPI release

启用 PyPI 发布前,请配置名为 pypi 的 GitHub Actions 环境,并在 PyPI 配置 GitHub Trusted Publisher,填写仓库所有者和名称、工作流 release.yml 以及环境 pypi。推送标签前,将仓库的 Actions 变量 ENABLE_PYPI_PUBLISH 设为 true。发布任务通过 OIDC 获取凭证。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables LLMs to inspect and test other MCP servers by listing and calling their tools, reading resources, and getting prompts. Supports stdio, SSE, and HTTP transports for both local and remote MCP server inspection.
      7
      6 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables natural-language testing of MCP servers—covering tools, resources, prompts, contracts, and transports—without writing test code, with deterministic validation and CI integration.
      Apache 2.0
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables MCP clients such as Claude Code, Codex, and Cursor to debug failing traces, sessions, and exceptions, inspect route decisions, prompts, datasets, and metrics, and control token overhead via compact output, file dumps, and selective tool loading. It supports local stdio or HTTP deployment with optional read-only mode for safer observability workflows.
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables MCP clients to score retrieval quality with recall, precision, nDCG, hit rate and MRR, compare 2-3 configurations with seeded paired-bootstrap confidence intervals, audit agent tool calls against expected traces, and detect prompt regressions against golden sets. It also generates Markdown, JSON or JUnit reports with pass/fail gates, all deterministically and offline without paid API keys.
      6
      47 npm
      1
      MIT