
轻量级CLI用于与MCP服务器交互
概览
一个轻量级、基于 Bun 的 CLI,用于与 MCP(模型上下文协议)服务器交互。 - 🪶 - 最小依赖,启动快速 - 📦 - 通过bun构建编译为独立可执行文件 -- 编译 - 🔧 - 调用时的JSON输出,带jq的管道,链式支持- 🤖 - 为AI编码代理设计(Gemini CLI、Claude Code等)- 🔌 - 支持stdio和HTTP MCP服务器 - ⚡ - 懒散生成守护进程保持连接温暖(空闲超时60秒) - - 通过配置允许/禁用每个服务器的特定工具 - 📋 - 输出显示MCP服务器指令 - 💡 - 结构化错误信息,包含可用服务器和恢复建议 在你当前的目录里创建mcp_servers.json,或者 ~/.config/mcp/: 在任何命令中添加 -d 以包含描述。 对于包含单引号、特殊字符或长文本的JSON参数,请使用以下方式以避免shell逃逸问题: 对{}、引号和特殊字符的壳层解释需要谨慎的逃逸。Stdin完全绕过壳层解析。
概述(AI 翻译)
一个轻量级、基于 Bun 的 CLI,用于与 MCP(模型上下文协议)服务器交互。
特色
- 🪶 轻量级 - 依赖最小,启动快速
- 📦 单一二进制 - 通过[[T0]编译为独立可执行文件]
- 🔧 Shell-友好 - 用于调用的JSON输出,带有
jq的管道,支持链式 - 🤖 Agent-Optimized - 为AI编码代理(Gemini CLI、Claude Code等)设计
- 🔌 通用 - 支持stdio和HTTP MCP服务器
- ⚡ 连接池 - 懒散生成守护进程保持连接温暖(60秒空闲超时)
- 工具过滤 - 通过配置允许/禁用每个服务器的特定工具
- 📋 服务器指令 - 输出显示MCP服务器指令
- 💡 可操作错误 - 结构化错误消息,包含可用服务器和恢复建议
快速启动
1.安装
或
2.创建一个配置文件
在当前目录中创建 mcp_servers.json 或 ~/.config/mcp/:
3.发现可用工具
4.叫个工具
用途
两种格式都支持: info 或 info /
[!提示] 在任何包含描述的命令中添加
-d。
选项
| 选项 | 描述 |
|---|
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
mcp-cli
A lightweight, Bun-based CLI for interacting with MCP (Model Context Protocol) servers.
Features
- 🪶 Lightweight - Minimal dependencies, fast startup
- 📦 Single Binary - Compile to standalone executable via
bun build --compile - 🔧 Shell-Friendly - JSON output for call, pipes with
jq, chaining support - 🤖 Agent-Optimized - Designed for AI coding agents (Gemini CLI, Claude Code, etc.)
- 🔌 Universal - Supports both stdio and HTTP MCP servers
- ⚡ Connection Pooling - Lazy-spawn daemon keeps connections warm (60s idle timeout)
- � Tool Filtering - Allow/disable specific tools per server via config
- 📋 Server Instructions - Display MCP server instructions in output
- �💡 Actionable Errors - Structured error messages with available servers and recovery suggestions
Quick Start
1. Installation
curl -fsSL https://raw.githubusercontent.com/philschmid/mcp-cli/main/install.sh | bash
or
# requires bun install
bun install -g https://github.com/philschmid/mcp-cli
2. Create a config file
Create mcp_servers.json in your current directory or ~/.config/mcp/:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"."
]
},
"deepwiki": {
"url": "https://mcp.deepwiki.com/mcp"
}
}
}
3. Discover available tools
# List all servers and tools
mcp-cli
# With descriptions
mcp-cli -d
4. Call a tool
# View tool schema first
mcp-cli info filesystem read_file
# Call the tool
mcp-cli call filesystem read_file '{"path": "./README.md"}'
Usage
mcp-cli [options] List all servers and tools
mcp-cli [options] info Show server tools and parameters
mcp-cli [options] info Show tool schema
mcp-cli [options] grep Search tools by glob pattern
mcp-cli [options] call Call tool (reads JSON from stdin if no args)
mcp-cli [options] call Call tool with JSON arguments
Both formats work: info or info /
[!TIP] Add
-dto any command to include descriptions.
Options
| Option | Description |
|---|---|
-h, --help |
Show help message |
-v, --version |
Show version number |
-d, --with-descriptions |
Include tool descriptions |
-c, --config |
Path to config file |
Output
| Stream | Content |
|---|---|
| stdout | Tool results and human-readable info |
| stderr | Errors and diagnostics |
Commands
List Servers
# Basic listing
$ mcp-cli
github
• search_repositories
• get_file_contents
• create_or_update_file
filesystem
• read_file
• write_file
• list_directory
安装
npx -y @modelcontextprotocol/server-filesystem .配置
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"."
]
},
"deepwiki": {
"url": "https://mcp.deepwiki.com/mcp"
}
}
}