AgentSkillsCN

mcp-cli

通过 CLI 为 MCP(模型上下文协议)服务器提供接口。适用于需要通过 MCP 服务器与外部工具、API 或数据源进行交互时使用。

SKILL.md
--- frontmatter
name: mcp-cli
description: Interface for MCP (Model Context Protocol) servers via CLI. Use when you need to interact with external tools, APIs, or data sources through MCP servers.
version: 1.0.0

MCP-CLI

Access MCP servers through the command line. MCP enables interaction with external systems like GitHub, filesystems, databases, and APIs.

Prerequisites

Install mcp-cli:

bash
bun install -g https://github.com/philschmid/mcp-cli

Configuration

Create mcp_servers.json in current directory or ~/.config/mcp/:

json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
    },
    "deepwiki": {
      "url": "https://mcp.deepwiki.com/mcp"
    }
  }
}
  • stdio servers: Use command + args
  • HTTP servers: Use url

Commands

CommandOutput
mcp-cliList 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)

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

Examples

bash
# List all servers and tool names
mcp-cli

# See all tools with parameters
mcp-cli filesystem

# With descriptions (more verbose)
mcp-cli filesystem -d

# Get JSON schema for specific tool
mcp-cli filesystem/read_file

# Call the tool
mcp-cli filesystem/read_file '{"path": "./README.md"}'

# Search for tools
mcp-cli grep "*file*"

# JSON output for parsing
mcp-cli filesystem/read_file '{"path": "./README.md"}' --json

# Complex JSON with quotes (use heredoc or stdin)
mcp-cli server/tool <<EOF
{"content": "Text with 'quotes' inside"}
EOF

# Or pipe from a file/command
cat args.json | mcp-cli server/tool

# 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\": \"{}\"}"'

Options

FlagPurpose
-j, --jsonJSON output for scripting
-r, --rawRaw text content
-dInclude descriptions

Exit Codes

  • 0: Success
  • 1: Client error (bad args, missing config)
  • 2: Server error (tool failed)
  • 3: Network error