npx skills add https://github.com/obra/superpowers-lab --skill mcp-cli使用 mcp CLI 工具动态发现和调用 MCP 服务器功能,无需预先将其配置为永久集成。
在以下情况下使用此技能:
mcp CLI 必须安装在 ~/.local/bin/mcp。如果不存在:
# 克隆并构建
cd /tmp && git clone --depth 1 https://github.com/f/mcptools.git
cd mcptools && CGO_ENABLED=0 go build -o ~/.local/bin/mcp ./cmd/mcptools
始终确保 PATH 包含该二进制文件:
export PATH="$HOME/.local/bin:$PATH"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
mcp tools <server-command>
示例:
# 文件系统服务器
mcp tools npx -y @modelcontextprotocol/server-filesystem /path/to/allow
# 内存/知识图谱服务器
mcp tools npx -y @modelcontextprotocol/server-memory
# GitHub 服务器(需要令牌)
mcp tools docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
# 基于 HTTP 的服务器
mcp tools https://example.com/mcp
mcp resources <server-command>
资源是服务器暴露的数据源(文件、数据库条目等)。
mcp prompts <server-command>
提示是服务器提供的预定义提示模板。
# 获取完整的模式详细信息,包括参数类型
mcp tools --format json <server-command>
mcp tools --format pretty <server-command>
mcp call <tool_name> --params '<json>' <server-command>
读取文件:
mcp call read_file --params '{"path": "/tmp/example.txt"}' \
npx -y @modelcontextprotocol/server-filesystem /tmp
写入文件:
mcp call write_file --params '{"path": "/tmp/test.txt", "content": "Hello world"}' \
npx -y @modelcontextprotocol/server-filesystem /tmp
列出目录:
mcp call list_directory --params '{"path": "/tmp"}' \
npx -y @modelcontextprotocol/server-filesystem /tmp
创建实体(内存服务器):
mcp call create_entities --params '{"entities": [{"name": "Project", "entityType": "Software", "observations": ["Uses TypeScript"]}]}' \
npx -y @modelcontextprotocol/server-memory
搜索(内存服务器):
mcp call search_nodes --params '{"query": "TypeScript"}' \
npx -y @modelcontextprotocol/server-memory
对于嵌套对象和数组,确保 JSON 有效:
mcp call edit_file --params '{
"path": "/tmp/file.txt",
"edits": [
{"oldText": "foo", "newText": "bar"},
{"oldText": "baz", "newText": "qux"}
]
}' npx -y @modelcontextprotocol/server-filesystem /tmp
# 表格(默认,人类可读)
mcp call <tool> --params '{}' <server>
# JSON(用于解析)
mcp call <tool> --params '{}' -f json <server>
# 美化 JSON(可读的 JSON)
mcp call <tool> --params '{}' -f pretty <server>
# 列出可用资源
mcp resources <server-command>
# 读取特定资源
mcp read-resource <resource-uri> <server-command>
# 替代语法
mcp call resource:<resource-uri> <server-command>
# 列出可用提示
mcp prompts <server-command>
# 获取提示(可能需要参数)
mcp get-prompt <prompt-name> <server-command>
# 带参数
mcp get-prompt <prompt-name> --params '{"arg": "value"}' <server-command>
如果在会话期间频繁使用某个服务器:
# 创建别名
mcp alias add fs npx -y @modelcontextprotocol/server-filesystem /home/user
# 使用别名
mcp tools fs
mcp call read_file --params '{"path": "README.md"}' fs
# 列出别名
mcp alias list
# 完成后移除
mcp alias remove fs
别名存储在 ~/.mcpt/aliases.json 中。
mcp tools --auth-user "username:password" https://api.example.com/mcp
mcp tools --auth-header "Bearer your-token-here" https://api.example.com/mcp
mcp tools docker run -i --rm \
-e GITHUB_PERSONAL_ACCESS_TOKEN="$GITHUB_TOKEN" \
ghcr.io/github/github-mcp-server
mcp tools npx -y @modelcontextprotocol/server-filesystem /tmp
mcp tools https://example.com/mcp
mcp tools http://localhost:3001/sse
# 或显式指定:
mcp tools --transport sse http://localhost:3001
# 允许访问特定目录
mcp tools npx -y @modelcontextprotocol/server-filesystem /path/to/allow
mcp tools npx -y @modelcontextprotocol/server-memory
export GITHUB_PERSONAL_ACCESS_TOKEN="your-token"
mcp tools docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
export BRAVE_API_KEY="your-key"
mcp tools npx -y @anthropic/mcp-server-brave-search
mcp tools npx -y @anthropic/mcp-server-puppeteer
在调用工具之前,运行 mcp tools 以了解可用的内容以及确切的参数模式。
当需要以编程方式处理结果时:
mcp call <tool> --params '{}' -f json <server> | jq '.field'
表格输出显示参数签名。请精确匹配:
param:str = 字符串param:num = 数字param:bool = 布尔值param:str[] = 字符串数组[param:str] = 可选参数工具调用可能失败。检查退出代码和 stderr:
if ! result=$(mcp call tool --params '{}' server 2>&1); then
echo "Error: $result"
fi
如果对同一服务器进行多次调用:
mcp alias add tmp-server npx -y @modelcontextprotocol/server-filesystem /tmp
mcp call list_directory --params '{"path": "/tmp"}' tmp-server
mcp call read_file --params '{"path": "/tmp/file.txt"}' tmp-server
mcp alias remove tmp-server
为了安全起见,限制可访问的工具:
# 仅允许读取操作
mcp guard --allow 'tools:read_*,list_*' --deny 'tools:write_*,delete_*' \
npx -y @modelcontextprotocol/server-filesystem /home
mcp tools --server-logs <server-command>
cat ~/.mcpt/aliases.json
使用 --format pretty 获取详细的 JSON 输出以调试参数问题。
| 操作 | 命令 |
|---|---|
| 列出工具 | mcp tools <server> |
| 列出资源 | mcp resources <server> |
| 列出提示 | mcp prompts <server> |
| 调用工具 | mcp call <tool> --params '<json>' <server> |
| 读取资源 | mcp read-resource <uri> <server> |
| 获取提示 | mcp get-prompt <name> <server> |
| 添加别名 | mcp alias add <name> <server-command> |
| 移除别名 | mcp alias remove <name> |
| JSON 输出 | 添加 -f json 或 -f pretty |
# 1. 发现可用的内容
mcp tools npx -y @modelcontextprotocol/server-filesystem /home/user/project
# 2. 检查资源
mcp resources npx -y @modelcontextprotocol/server-filesystem /home/user/project
# 3. 为方便起见创建别名
mcp alias add proj npx -y @modelcontextprotocol/server-filesystem /home/user/project
# 4. 探索目录结构
mcp call directory_tree --params '{"path": "/home/user/project"}' proj
# 5. 读取特定文件
mcp call read_file --params '{"path": "/home/user/project/README.md"}' proj
# 6. 搜索模式
mcp call search_files --params '{"path": "/home/user/project", "pattern": "**/*.ts"}' proj
# 7. 清理别名
mcp alias remove proj
确保 PATH 已设置:export PATH="$HOME/.local/bin:$PATH"
--params "$(cat params.json)"某些服务器需要时间启动。mcp CLI 会自动等待初始化。
对于文件系统服务器,确保允许的目录路径正确且可访问。
每周安装次数
109
仓库
GitHub 星标数
243
首次出现时间
2026 年 1 月 21 日
安全审计
安装于
opencode93
codex90
gemini-cli85
github-copilot83
claude-code82
cursor76
Use the mcp CLI tool to dynamically discover and invoke MCP server capabilities without pre-configuring them as permanent integrations.
Use this skill when you need to:
The mcp CLI must be installed at ~/.local/bin/mcp. If not present:
# Clone and build
cd /tmp && git clone --depth 1 https://github.com/f/mcptools.git
cd mcptools && CGO_ENABLED=0 go build -o ~/.local/bin/mcp ./cmd/mcptools
Always ensure PATH includes the binary:
export PATH="$HOME/.local/bin:$PATH"
mcp tools <server-command>
Examples:
# Filesystem server
mcp tools npx -y @modelcontextprotocol/server-filesystem /path/to/allow
# Memory/knowledge graph server
mcp tools npx -y @modelcontextprotocol/server-memory
# GitHub server (requires token)
mcp tools docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
# HTTP-based server
mcp tools https://example.com/mcp
mcp resources <server-command>
Resources are data sources the server exposes (files, database entries, etc.).
mcp prompts <server-command>
Prompts are pre-defined prompt templates the server provides.
# For full schema details including parameter types
mcp tools --format json <server-command>
mcp tools --format pretty <server-command>
mcp call <tool_name> --params '<json>' <server-command>
Read a file:
mcp call read_file --params '{"path": "/tmp/example.txt"}' \
npx -y @modelcontextprotocol/server-filesystem /tmp
Write a file:
mcp call write_file --params '{"path": "/tmp/test.txt", "content": "Hello world"}' \
npx -y @modelcontextprotocol/server-filesystem /tmp
List directory:
mcp call list_directory --params '{"path": "/tmp"}' \
npx -y @modelcontextprotocol/server-filesystem /tmp
Create entities (memory server):
mcp call create_entities --params '{"entities": [{"name": "Project", "entityType": "Software", "observations": ["Uses TypeScript"]}]}' \
npx -y @modelcontextprotocol/server-memory
Search (memory server):
mcp call search_nodes --params '{"query": "TypeScript"}' \
npx -y @modelcontextprotocol/server-memory
For nested objects and arrays, ensure valid JSON:
mcp call edit_file --params '{
"path": "/tmp/file.txt",
"edits": [
{"oldText": "foo", "newText": "bar"},
{"oldText": "baz", "newText": "qux"}
]
}' npx -y @modelcontextprotocol/server-filesystem /tmp
# Table (default, human-readable)
mcp call <tool> --params '{}' <server>
# JSON (for parsing)
mcp call <tool> --params '{}' -f json <server>
# Pretty JSON (readable JSON)
mcp call <tool> --params '{}' -f pretty <server>
# List available resources
mcp resources <server-command>
# Read a specific resource
mcp read-resource <resource-uri> <server-command>
# Alternative syntax
mcp call resource:<resource-uri> <server-command>
# List available prompts
mcp prompts <server-command>
# Get a prompt (may require arguments)
mcp get-prompt <prompt-name> <server-command>
# With parameters
mcp get-prompt <prompt-name> --params '{"arg": "value"}' <server-command>
If using a server frequently during a session:
# Create alias
mcp alias add fs npx -y @modelcontextprotocol/server-filesystem /home/user
# Use alias
mcp tools fs
mcp call read_file --params '{"path": "README.md"}' fs
# List aliases
mcp alias list
# Remove when done
mcp alias remove fs
Aliases are stored in ~/.mcpt/aliases.json.
mcp tools --auth-user "username:password" https://api.example.com/mcp
mcp tools --auth-header "Bearer your-token-here" https://api.example.com/mcp
mcp tools docker run -i --rm \
-e GITHUB_PERSONAL_ACCESS_TOKEN="$GITHUB_TOKEN" \
ghcr.io/github/github-mcp-server
mcp tools npx -y @modelcontextprotocol/server-filesystem /tmp
mcp tools https://example.com/mcp
mcp tools http://localhost:3001/sse
# Or explicitly:
mcp tools --transport sse http://localhost:3001
# Allow access to specific directory
mcp tools npx -y @modelcontextprotocol/server-filesystem /path/to/allow
mcp tools npx -y @modelcontextprotocol/server-memory
export GITHUB_PERSONAL_ACCESS_TOKEN="your-token"
mcp tools docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server
export BRAVE_API_KEY="your-key"
mcp tools npx -y @anthropic/mcp-server-brave-search
mcp tools npx -y @anthropic/mcp-server-puppeteer
Before calling tools, run mcp tools to understand what's available and the exact parameter schema.
When you need to process results programmatically:
mcp call <tool> --params '{}' -f json <server> | jq '.field'
The table output shows parameter signatures. Match them exactly:
param:str = stringparam:num = numberparam:bool = booleanparam:str[] = array of strings[param:str] = optional parameterTool calls may fail. Check exit codes and stderr:
if ! result=$(mcp call tool --params '{}' server 2>&1); then
echo "Error: $result"
fi
If making several calls to the same server:
mcp alias add tmp-server npx -y @modelcontextprotocol/server-filesystem /tmp
mcp call list_directory --params '{"path": "/tmp"}' tmp-server
mcp call read_file --params '{"path": "/tmp/file.txt"}' tmp-server
mcp alias remove tmp-server
For safety, limit what tools are accessible:
# Only allow read operations
mcp guard --allow 'tools:read_*,list_*' --deny 'tools:write_*,delete_*' \
npx -y @modelcontextprotocol/server-filesystem /home
mcp tools --server-logs <server-command>
cat ~/.mcpt/aliases.json
Use --format pretty for detailed JSON output to debug parameter issues.
| Action | Command |
|---|---|
| List tools | mcp tools <server> |
| List resources | mcp resources <server> |
| List prompts | mcp prompts <server> |
| Call tool | mcp call <tool> --params '<json>' <server> |
| Read resource | mcp read-resource <uri> <server> |
| Get prompt | mcp get-prompt <name> <server> |
# 1. Discover what's available
mcp tools npx -y @modelcontextprotocol/server-filesystem /home/user/project
# 2. Check for resources
mcp resources npx -y @modelcontextprotocol/server-filesystem /home/user/project
# 3. Create alias for convenience
mcp alias add proj npx -y @modelcontextprotocol/server-filesystem /home/user/project
# 4. Explore directory structure
mcp call directory_tree --params '{"path": "/home/user/project"}' proj
# 5. Read specific files
mcp call read_file --params '{"path": "/home/user/project/README.md"}' proj
# 6. Search for patterns
mcp call search_files --params '{"path": "/home/user/project", "pattern": "**/*.ts"}' proj
# 7. Clean up alias
mcp alias remove proj
Ensure PATH is set: export PATH="$HOME/.local/bin:$PATH"
--params "$(cat params.json)"Some servers take time to start. The mcp CLI waits for initialization automatically.
For filesystem server, ensure the allowed directory path is correct and accessible.
Weekly Installs
109
Repository
GitHub Stars
243
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubFailSocketWarnSnykFail
Installed on
opencode93
codex90
gemini-cli85
github-copilot83
claude-code82
cursor76
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
118,000 周安装
| Add alias | mcp alias add <name> <server-command> |
| Remove alias | mcp alias remove <name> |
| JSON output | Add -f json or -f pretty |