Loading...
Loading...
Lightweight CLI for interacting with MCP (Model Context Protocol) servers - discover, inspect, and execute MCP tools from the command line
npx skill4agent add aradotso/mcp-skills mcp-cli-toolSkill by ara.so — MCP Skills collection.
mcp-clijqcurl -fsSL https://raw.githubusercontent.com/philschmid/mcp-cli/main/install.sh | bashbun install -g https://github.com/philschmid/mcp-climcp-cli --versionmcp_servers.jsonMCP_CONFIG_PATH-c/--config./mcp_servers.json~/.mcp_servers.json~/.config/mcp/mcp_servers.json{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"."
]
},
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"deepwiki": {
"url": "https://mcp.deepwiki.com/mcp"
}
}
}{
"mcpServers": {
"local-server": {
"command": "node",
"args": ["./server.js"],
"env": {
"API_KEY": "${API_KEY}"
},
"cwd": "/path/to/directory",
"allowedTools": ["read_*", "list_*"],
"disabledTools": ["delete_*"]
},
"remote-server": {
"url": "https://mcp.example.com",
"headers": {
"Authorization": "Bearer ${TOKEN}"
}
}
}
}${VAR_NAME}{
"mcpServers": {
"api-server": {
"command": "node",
"args": ["server.js"],
"env": {
"DATABASE_URL": "${DATABASE_URL}",
"API_KEY": "${API_KEY}"
}
}
}
}MCP_STRICT_ENV=trueMCP_STRICT_ENV=false{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
"allowedTools": ["read_file", "list_directory"],
"disabledTools": ["delete_file"]
}
}
}allowedTools*?disabledTools// Only read operations
"allowedTools": ["read_*", "list_*", "search_*"]
// Disable destructive operations
"disabledTools": ["delete_*", "write_*", "create_*"]
// Combine filters
"allowedTools": ["*file*"],
"disabledTools": ["delete_file"]# Basic listing
mcp-cli
# With descriptions
mcp-cli -dgithub
• search_repositories
• get_file_contents
• create_or_update_file
filesystem
• read_file
• write_file
• list_directory# Find file-related tools
mcp-cli grep "*file*"
# Search with descriptions
mcp-cli grep "*search*" -dgithub/get_file_contents
github/create_or_update_file
filesystem/read_file
filesystem/write_filemcp-cli info <server>mcp-cli info githubServer: github
Transport: stdio
Command: npx -y @modelcontextprotocol/server-github
Tools (12):
search_repositories
Search for GitHub repositories
Parameters:
• query (string, required) - Search query
• page (number, optional) - Page number
...mcp-cli info <server> <tool>
mcp-cli info <server>/<tool>mcp-cli info github search_repositoriesTool: search_repositories
Server: github
Description:
Search for GitHub repositories
Input Schema:
{
"type": "object",
"properties": {
"query": { "type": "string", "description": "Search query" },
"page": { "type": "number" }
},
"required": ["query"]
}# Inline JSON
mcp-cli call <server> <tool> '{"key": "value"}'
# From stdin (auto-detected, no '-' needed)
echo '{"path": "./file"}' | mcp-cli call <server> <tool>
# Heredoc for complex JSON
mcp-cli call <server> <tool> <<EOF
{"content": "Text with 'quotes' and \"escapes\""}
EOFmcp-cli call github search_repositories '{"query": "mcp server", "per_page": 5}'{
"content": [
{
"type": "text",
"text": "{\"items\": [{\"name\": \"mcp-cli\", \"url\": \"...\"}]}"
}
]
}# Step 1: List available servers
mcp-cli
# Step 2: View server tools
mcp-cli info filesystem
# Step 3: Get tool schema
mcp-cli info filesystem read_file
# Step 4: Call the tool
mcp-cli call filesystem read_file '{"path": "./README.md"}'# Extract specific field
mcp-cli call github search_repositories '{"query": "mcp"}' | jq '.content[0].text'
# Parse nested JSON
mcp-cli call github search_repositories '{"query": "mcp"}' \
| jq -r '.content[0].text | fromjson | .items[].html_url'
# Filter results
mcp-cli call filesystem list_directory '{"path": "."}' \
| jq -r '.content[0].text | split("\n")[] | select(endswith(".md"))'# Search and read first result
mcp-cli call filesystem search_files '{"path": "src/", "pattern": "*.ts"}' \
| jq -r '.content[0].text | split("\n")[0]' \
| xargs -I {} mcp-cli call filesystem read_file '{"path": "{}"}'
# Process all matching files
mcp-cli call filesystem search_files '{"path": ".", "pattern": "*.md"}' \
| jq -r '.content[0].text | split("\n")[]' \
| while read file; do
echo "=== $file ==="
mcp-cli call filesystem read_file "{\"path\": \"$file\"}" | jq -r '.content[0].text'
done# Conditional execution
mcp-cli call filesystem list_directory '{"path": "."}' \
| jq -e '.content[0].text | contains("README.md")' \
&& mcp-cli call filesystem read_file '{"path": "./README.md"}'
# Fallback on error
if result=$(mcp-cli call filesystem read_file '{"path": "./config.json"}' 2>/dev/null); then
echo "$result" | jq '.content[0].text | fromjson'
else
echo "File not found, using defaults"
fimcp-cli call github get_file_contents '{"owner": "user", "repo": "project", "path": "src/main.ts"}' \
| jq -r '.content[0].text' > main.ts{
mcp-cli call github search_repositories '{"query": "mcp", "per_page": 3}'
mcp-cli call filesystem list_directory '{"path": "./src"}'
} | jq -s '.'# Heredoc (recommended)
mcp-cli call server tool <<EOF
{
"content": "Text with 'single quotes' and \"double quotes\"",
"metadata": {
"nested": "value"
}
}
EOF
# From file
cat args.json | mcp-cli call server tool
# Using jq to build complex JSON
jq -n '{query: "mcp", filters: ["active", "starred"]}' | mcp-cli call github search| Variable | Description | Default |
|---|---|---|
| Path to config file | (none) |
| Enable debug output | |
| Request timeout (seconds) | |
| Servers processed in parallel | |
| Retry attempts for transient errors | |
| Base retry delay (milliseconds) | |
| Error on missing | |
| Disable connection caching | |
| Idle timeout for cached connections (seconds) | |
# Enable debug mode
export MCP_DEBUG=true
mcp-cli info github
# Use custom config
export MCP_CONFIG_PATH=/path/to/config.json
mcp-cli
# Disable connection pooling
export MCP_NO_DAEMON=true
mcp-cli call server tool '{}'| Option | Description |
|---|---|
| Show help message |
| Show version number |
| Include tool descriptions |
| Path to config file |
# List with descriptions
mcp-cli -d
# Use custom config
mcp-cli -c ./my-config.json info github
# Get help
mcp-cli --help{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/directory"
],
"allowedTools": ["read_file", "list_directory", "search_files"],
"disabledTools": ["delete_file"]
}
}
}mcp-cli call filesystem read_file '{"path": "./README.md"}'
mcp-cli call filesystem list_directory '{"path": "."}'{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}mcp-cli call github search_repositories '{"query": "mcp server"}'
mcp-cli call github get_file_contents '{"owner": "user", "repo": "repo", "path": "README.md"}'{
"mcpServers": {
"api": {
"url": "https://mcp.example.com",
"headers": {
"Authorization": "Bearer ${API_TOKEN}"
}
}
}
}mcp-cli info api
mcp-cli call api tool_name '{"param": "value"}'{
"mcpServers": {
"custom": {
"command": "node",
"args": ["./my-server.js"],
"cwd": "/path/to/project",
"env": {
"PORT": "3000",
"API_KEY": "${API_KEY}"
}
}
}
}Error: No MCP configuration foundmcp_servers.json~/.config/mcp/MCP_CONFIG_PATH-cmcp-cli -c /path/to/config.jsonError: Failed to connect to server 'github'npx @modelcontextprotocol/server-github --versionMCP_DEBUG=true mcp-cli info githubError: Environment variable GITHUB_TOKEN not foundexport GITHUB_TOKEN=your_tokenMCP_STRICT_ENV=falseError: Tool 'invalid_tool' not found on server 'github'mcp-cli info githubdisabledToolsError: Tool 'write_file' is disabled by configurationallowedToolsdisabledToolsError: Invalid JSON argumentsecho '{}' | mcp-cli call server tool'{"key": "value"}'Error: Request timeout after 1800 secondsexport MCP_TIMEOUT=3600export MCP_NO_DAEMON=trueError: EACCES: permission deniedcwd## MCP Servers
You have access to MCP servers via the `mcp-cli` CLI.
Commands:
- `mcp-cli info` - List all servers
- `mcp-cli info <server>` - Show server tools
- `mcp-cli info <server> <tool>` - Get tool schema
- `mcp-cli grep "<pattern>"` - Search tools
- `mcp-cli call <server> <tool> '{}'` - Call with JSON args
- `echo '{}' | mcp-cli call <server> <tool>` - Call from stdin
Workflow:
1. Discover: `mcp-cli info` to see available servers
2. Inspect: `mcp-cli info <server> <tool>` to get schema
3. Execute: `mcp-cli call <server> <tool> '{}'` with arguments
Use stdin for complex JSON to avoid shell escaping issues.# ❌ Avoid: Loading everything into context
mcp-cli -d # Thousands of tokens
# ✅ Efficient: On-demand loading
mcp-cli # List servers (minimal tokens)
mcp-cli info github # Show tools when needed
mcp-cli info github search_repositories # Get schema only when calling
mcp-cli call github search_repositories '{"query": "mcp"}'#!/bin/bash
# Generated by AI agent to analyze repository
# Search for repos
repos=$(mcp-cli call github search_repositories '{"query": "mcp server", "per_page": 5}')
# Extract URLs
urls=$(echo "$repos" | jq -r '.content[0].text | fromjson | .items[].html_url')
# For each repo, get README
for url in $urls; do
owner=$(echo "$url" | cut -d'/' -f4)
repo=$(echo "$url" | cut -d'/' -f5)
echo "=== $owner/$repo ==="
mcp-cli call github get_file_contents "{\"owner\": \"$owner\", \"repo\": \"$repo\", \"path\": \"README.md\"}" \
| jq -r '.content[0].text'
done-d${VAR}infocallgrep