test-mcp-by-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Test MCP by CLI

通过CLI测试MCP

Validate MCP servers with
mcp-cli
(philschmid/mcp-cli v0.3.0) using release-verified behavior first, then use official repo source only when it matches what the installed binary actually does.
首先使用经过发布验证的行为,通过
mcp-cli
(philschmid/mcp-cli v0.3.0)验证MCP服务器;仅当官方仓库源码与已安装二进制文件的实际表现一致时,才使用官方仓库源码。

Core rules

核心规则

  • Execute commands directly and sequentially.
  • Do not write helper scripts unless explicitly requested.
  • Treat server work as incomplete until verification checks pass.
  • Prefer single-server commands while debugging.
  • After rebuilding a server, always retest with
    MCP_NO_DAEMON=1
    .
  • Treat
    mcp-cli --help
    and real command output as the primary behavioral source for the installed release.
  • Remember that
    call
    returns the raw MCP JSON envelope on stdout in the installed
    v0.3.0
    binary.
  • 直接按顺序执行命令。
  • 除非明确要求,否则不要编写辅助脚本。
  • 在验证检查全部通过前,视服务器工作为未完成状态。
  • 调试时优先使用单服务器命令。
  • 重建服务器后,务必使用
    MCP_NO_DAEMON=1
    重新测试。
  • mcp-cli --help
    及实际命令输出作为已安装版本的主要行为参考依据。
  • 请记住,在已安装的v0.3.0版本二进制文件中,
    call
    命令会在标准输出中返回原始的MCP JSON信封。

What to load first

优先加载内容

Use this progressive order to keep context tight:
  1. This file (
    SKILL.md
    )
    for command strategy, decision rules, and execution flow.
  2. Skill references for concrete command blocks:
    • references/testing-flow.md
      — 8-phase verification sequence and checklist
    • references/configuration-and-arguments.md
      — config format, search paths, tool filtering, env var substitution, JSON input methods
    • references/output-debugging-and-chaining.md
      — raw output parsing, stream handling, chaining, CI/CD patterns, verified environment variables
    • references/errors-and-recovery.md
      — common errors, exit codes, daemon behavior, and release inconsistencies
  3. Read only the relevant reference for the current problem instead of loading all files.
  4. Return to this file when you need the overall workflow or decision rules.
遵循以下渐进式顺序,以保持上下文紧凑:
  1. 本文件(
    SKILL.md
    :提供命令策略、决策规则及执行流程。
  2. Skill参考文档:包含具体命令块:
    • references/testing-flow.md
      — 8阶段验证序列及检查清单
    • references/configuration-and-arguments.md
      — 配置格式、搜索路径、工具过滤、环境变量替换、JSON输入方法
    • references/output-debugging-and-chaining.md
      — 原始输出解析、流处理、命令链、CI/CD模式、已验证环境变量
    • references/errors-and-recovery.md
      — 常见错误、退出码、守护进程行为及版本不一致问题
  3. 仅加载与当前问题相关的参考文档,而非全部文件。
  4. 当需要整体工作流或决策规则时,回到本文件。

Execution workflow

执行工作流

  1. Follow the 8-phase verification order in
    references/testing-flow.md
    .
  2. Use config and JSON argument patterns from
    references/configuration-and-arguments.md
    .
  3. Use stream handling, chaining, and env controls from
    references/output-debugging-and-chaining.md
    .
  4. If any command fails, apply diagnosis from
    references/errors-and-recovery.md
    .
  5. Do not report done until all checklist items pass.
  1. 遵循
    references/testing-flow.md
    中的8阶段验证顺序。
  2. 使用
    references/configuration-and-arguments.md
    中的配置及JSON参数模式。
  3. 使用
    references/output-debugging-and-chaining.md
    中的流处理、命令链及环境变量控制方法。
  4. 若任何命令执行失败,参考
    references/errors-and-recovery.md
    进行诊断。
  5. 所有检查清单项通过前,不要报告完成。

Decision rules

决策规则

Apply when things go wrong:
  • If Phase 1 (connect) fails: stop everything. Fix config or server startup before proceeding.
  • If a tool is missing from inventory: check
    disabledTools
    in config — it takes precedence over
    allowedTools
    . Read
    references/configuration-and-arguments.md
    .
  • If calls return stale results: use
    MCP_NO_DAEMON=1
    — the daemon caches old server processes for 60s. Read daemon section in
    references/errors-and-recovery.md
    .
  • If calls hang: lower timeout with
    MCP_TIMEOUT=30
    (default is 1800s). Read env var section in
    references/output-debugging-and-chaining.md
    .
  • If debugging protocol issues: use
    MCP_DEBUG=1
    to see full protocol traffic on stderr.
  • If
    mcp-cli
    (no args) hangs
    : it connects ALL servers. Use
    mcp-cli info <server>
    to test one at a time.
  • If you get
    AMBIGUOUS_COMMAND
    : always use a subcommand —
    call
    ,
    info
    , or
    grep
    .
  • If output parsing looks wrong:
    call
    returns raw JSON in this release. Extract content with
    jq -r '.content[0].text'
    . Read
    references/output-debugging-and-chaining.md
    .
  • If docs and binary disagree: trust the installed binary and real command output over inferred internals.
当出现问题时应用以下规则:
  • 若阶段1(连接)失败:立即停止所有操作。在继续之前修复配置或服务器启动问题。
  • 若工具未出现在清单中:检查配置中的
    disabledTools
    — 它的优先级高于
    allowedTools
    。请阅读
    references/configuration-and-arguments.md
  • 若调用返回过时结果:使用
    MCP_NO_DAEMON=1
    — 守护进程会缓存旧服务器进程60秒。请阅读
    references/errors-and-recovery.md
    中的守护进程章节。
  • 若调用挂起:通过
    MCP_TIMEOUT=30
    降低超时时间(默认是1800秒)。请阅读
    references/output-debugging-and-chaining.md
    中的环境变量章节。
  • 若调试协议问题:使用
    MCP_DEBUG=1
    在标准错误输出中查看完整协议流量。
  • mcp-cli
    (无参数)挂起
    :它会连接所有服务器。使用
    mcp-cli info <server>
    逐个测试。
  • 若出现
    AMBIGUOUS_COMMAND
    错误
    :务必使用子命令 —
    call
    info
    grep
  • 若输出解析异常:在本版本中
    call
    返回原始JSON。使用
    jq -r '.content[0].text'
    提取内容。请阅读
    references/output-debugging-and-chaining.md
  • 若文档与二进制文件表现不一致:优先信任已安装的二进制文件及实际命令输出,而非推断的内部实现。

Repository-specific execution mode

仓库专属执行模式

When validating this repository's own source code, run the local CLI implementation:
bash
bun run src/index.ts -c ./mcp_servers.json info filesystem
bun run src/index.ts -c ./mcp_servers.json call filesystem read_file '{"path":"./README.md"}'
Use globally installed
mcp-cli
for all other workflows.
当验证本仓库自身的源码时,运行本地CLI实现:
bash
bun run src/index.ts -c ./mcp_servers.json info filesystem
bun run src/index.ts -c ./mcp_servers.json call filesystem read_file '{"path":"./README.md"}'
所有其他工作流均使用全局安装的
mcp-cli

Minimal quick start

极简快速入门

bash
undefined
bash
undefined

Install if missing

若未安装则进行安装

Connect and inspect

连接并检查

mcp-cli info my-server mcp-cli info my-server my-tool
mcp-cli info my-server mcp-cli info my-server my-tool

Happy path + error path

正常路径 + 错误路径测试

mcp-cli call my-server my-tool '{"param":"value"}' mcp-cli call my-server my-tool '{}'
mcp-cli call my-server my-tool '{"param":"value"}' mcp-cli call my-server my-tool '{}'

Fresh-connection check after rebuild

重建后进行新连接检查

MCP_NO_DAEMON=1 mcp-cli call my-server my-tool '{"param":"value"}'

If any step fails, continue debugging; do not claim completion.
MCP_NO_DAEMON=1 mcp-cli call my-server my-tool '{"param":"value"}'

若任何步骤失败,请继续调试;不要声称已完成。

Reference files

参考文件

FileWhen to read
references/testing-flow.md
Running the full 8-phase verification sequence or the final checklist
references/configuration-and-arguments.md
Setting up config files, tool filtering, env var substitution, or passing JSON arguments
references/output-debugging-and-chaining.md
Parsing output, piping between tools, CI/CD scripts, or controlling behavior via env vars
references/errors-and-recovery.md
Any command fails — error type lookup, exit code interpretation, daemon issues, or release inconsistencies
文件阅读时机
references/testing-flow.md
运行完整的8阶段验证序列或最终检查清单时
references/configuration-and-arguments.md
设置配置文件、工具过滤、环境变量替换或传递JSON参数时
references/output-debugging-and-chaining.md
解析输出、工具间管道传输、编写CI/CD脚本或通过环境变量控制行为时
references/errors-and-recovery.md
任何命令执行失败时 — 错误类型查找、退出码解读、守护进程问题或版本不一致问题