fastmcp-client-cli
它能做什么
这项技能使用 fastmcp 命令行来探索和运行 MCP 服务器上的工具。适合想查看服务器能做什么,或在脚本中使用其工具的人。
适用场景
- ✓当你想在使用 MCP 服务器之前,先查看它提供哪些工具的时候。
- ✓当你需要在命令行或工作流中调用某个 MCP 工具的时候。
- ✓当你想让脚本获取 MCP 服务器的 JSON 格式输出的时候。
技能链接
https://github.com/PrefectHQ/fastmcp/blob/main/docs/.mintlify/skills/fastmcp-client-cli/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的本地 MCP 服务器提供了哪些工具?你能否用 hello 作为查询词调用搜索工具?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体运行 fastmcp list 显示服务器的工具及其签名,然后用 fastmcp call 调用,参数会自动转换为正确的类型。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
FastMCP CLI: List and Call
Use fastmcp list and fastmcp call to interact with any MCP server from the command line.
Listing Tools
# Remote server
fastmcp list http://localhost:8000/mcp
# Local Python file (runs via fastmcp run automatically)
fastmcp list server.py
# MCPConfig with multiple servers
fastmcp list mcp.json
# Stdio command (npx, uvx, etc.)
fastmcp list --command 'npx -y @modelcontextprotocol/server-github'
# Include full input/output schemas
fastmcp list server.py --input-schema --output-schema
# Machine-readable JSON
fastmcp list server.py --json
# Include resources and prompts
fastmcp list server.py --resources --prompts
Default output shows tool signatures and descriptions. Use --input-schema or --output-schema to include full JSON schemas, --json for structured output.
Calling Tools
# Key=value arguments (auto-coerced to correct types)
fastmcp call server.py greet name=World
fastmcp call server.py add a=3 b=4
# Single JSON object for complex/nested args
fastmcp call server.py create_item '{"name": "Widget", "tags": ["a", "b"]}'
# --input-json with key=value overrides
fastmcp call server.py search --input-json '{"query": "hello", "limit": 5}' limit=10
# JSON output for scripting
fastmcp call server.py add a=3 b=4 --json
Type coercion is automatic: limit=5 becomes an integer, verbose=true becomes a boolean, based on the tool's input schema.
Server Targets
All commands accept the same server targets:
| Target | Example |
|---|---|
| HTTP/HTTPS URL | http://localhost:8000/mcp |
| Python file | server.py |
| MCPConfig JSON | mcp.json (must have mcpServers key) |
| Stdio command | --command 'npx -y @mcp/server' |
| Discovered name | weather or source:name |
Servers configured in editor configs (Claude Desktop, Claude Code, Cursor, Gemini CLI, Goose) or project-level mcp.json can be referenced by name. Use source:name (e.g. claude-code:my-server, cursor:weather) to target a specific source. Run fastmcp discover to see available names.
For SSE servers, pass --transport sse:
fastmcp list http://localhost:8000/mcp --transport sse
Auth
HTTP targets automatically use OAuth (no-ops if the server doesn't require auth). Disable with --auth none:
fastmcp call http://server/mcp tool --auth none
Discovering Configured Servers
# See all MCP servers in editor/project configs
fastmcp discover
# Filter by source
fastmcp discover --source claude-code
# JSON output
fastmcp discover --json
Scans Claude Desktop, Claude Code, Cursor, Gemini CLI, Goose, and ./mcp.json. Sources: claude-desktop, claude-code, cursor, gemini, goose, project.
Workflow Pattern
Discover tools first, then call them:
# 1. See what servers are configured
fastmcp discover
# 2. See what tools a server has
fastmcp list weather
# 3. Call a tool
fastmcp call weather get_forecast city=London
If you call a nonexistent tool, FastMCP suggests close matches.
常见问题
它支持哪些类型的服务器?
它支持 URL 上的远程服务器、本地 Python 文件、包含多个服务器的配置文件,以及启动服务器的命令。
我必须把参数写成 JSON 吗?
不必。简单的 key=value 参数即可使用,值会自动转换为正确的类型。
我能查看完整的结构定义吗?
可以。添加输入和输出结构的选项后,列表中会包含完整的 JSON 结构定义。
详情
作者的原始描述
Query and invoke tools on MCP servers using fastmcp list and fastmcp call. Use when you need to discover what tools a server offers, call tools, or integrate MCP servers into workflows.
repo: PrefectHQ/fastmcp
热度
- GitHub 星标
- 28k
- 排名
- #9866
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …