mcp-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MCP-CLI

MCP-CLI

Access MCP servers through the command line. MCP enables interaction with external systems like GitHub, filesystems, databases, and APIs.
通过命令行访问MCP服务器。MCP支持与GitHub、文件系统、数据库和API等外部系统进行交互。

Commands

命令

CommandOutput
mcp-cli
List all servers and tool names
mcp-cli <server>
Show tools with parameters
mcp-cli <server>/<tool>
Get tool JSON schema
mcp-cli <server>/<tool> '<json>'
Call tool with arguments
mcp-cli grep "<glob>"
Search tools by name
Add
-d
to include descriptions
(e.g.,
mcp-cli filesystem -d
)
命令输出
mcp-cli
列出所有服务器和工具名称
mcp-cli <server>
显示带参数的工具
mcp-cli <server>/<tool>
获取工具JSON架构
mcp-cli <server>/<tool> '<json>'
使用参数调用工具
mcp-cli grep "<glob>"
按名称搜索工具
添加
-d
以包含描述
(例如:
mcp-cli filesystem -d

Workflow

工作流程

  1. Discover:
    mcp-cli
    → see available servers and tools
  2. Explore:
    mcp-cli <server>
    → see tools with parameters
  3. Inspect:
    mcp-cli <server>/<tool>
    → get full JSON input schema
  4. Execute:
    mcp-cli <server>/<tool> '<json>'
    → run with arguments
  1. 发现
    mcp-cli
    → 查看可用的服务器和工具
  2. 探索
    mcp-cli <server>
    → 查看带参数的工具
  3. 检查
    mcp-cli <server>/<tool>
    → 获取完整的JSON输入架构
  4. 执行
    mcp-cli <server>/<tool> '<json>'
    → 使用参数运行工具

Examples

示例

bash
undefined
bash
undefined

List all servers and tool names

List all servers and tool names

mcp-cli
mcp-cli

See all tools with parameters

See all tools with parameters

mcp-cli filesystem
mcp-cli filesystem

With descriptions (more verbose)

With descriptions (more verbose)

mcp-cli filesystem -d
mcp-cli filesystem -d

Get JSON schema for specific tool

Get JSON schema for specific tool

mcp-cli filesystem/read_file
mcp-cli filesystem/read_file

Call the tool

Call the tool

mcp-cli filesystem/read_file '{"path": "./README.md"}'
mcp-cli filesystem/read_file '{"path": "./README.md"}'

Search for tools

Search for tools

mcp-cli grep "file"
mcp-cli grep "file"

JSON output for parsing

JSON output for parsing

mcp-cli filesystem/read_file '{"path": "./README.md"}' --json
mcp-cli filesystem/read_file '{"path": "./README.md"}' --json

Complex JSON with quotes (use heredoc or stdin)

Complex JSON with quotes (use heredoc or stdin)

mcp-cli server/tool <<EOF {"content": "Text with 'quotes' inside"} EOF
mcp-cli server/tool <<EOF {"content": "Text with 'quotes' inside"} EOF

Or pipe from a file/command

Or pipe from a file/command

cat args.json | mcp-cli server/tool
cat args.json | mcp-cli server/tool

Find all TypeScript files and read the first one

Find all TypeScript files and read the first one

mcp-cli filesystem/search_files '{"path": "src/", "pattern": "*.ts"}' --json | jq -r '.content[0].text' | head -1 | xargs -I {} sh -c 'mcp-cli filesystem/read_file "{"path": "{}"}"'
undefined
mcp-cli filesystem/search_files '{"path": "src/", "pattern": "*.ts"}' --json | jq -r '.content[0].text' | head -1 | xargs -I {} sh -c 'mcp-cli filesystem/read_file "{"path": "{}"}"'
undefined

Options

选项

FlagPurpose
-j, --json
JSON output for scripting
-r, --raw
Raw text content
-d
Include descriptions
标志用途
-j, --json
输出JSON格式以便脚本处理
-r, --raw
输出原始文本内容
-d
包含工具描述

Exit Codes

退出码

  • 0
    : Success
  • 1
    : Client error (bad args, missing config)
  • 2
    : Server error (tool failed)
  • 3
    : Network error
  • 0
    : 成功
  • 1
    : 客户端错误(参数错误、配置缺失)
  • 2
    : 服务器错误(工具执行失败)
  • 3
    : 网络错误