fastmcp-client-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

FastMCP CLI: List and Call

FastMCP CLI: 列出与调用

Use
fastmcp list
and
fastmcp call
to interact with any MCP server from the command line.
使用
fastmcp list
fastmcp call
从命令行与任意MCP服务器进行交互。

Listing Tools

列出工具

bash
undefined
bash
undefined

Remote server

远程服务器

Local Python file (runs via fastmcp run automatically)

本地Python文件(通过fastmcp run自动运行)

fastmcp list server.py
fastmcp list server.py

MCPConfig with multiple servers

包含多个服务器的MCPConfig配置文件

fastmcp list mcp.json
fastmcp list mcp.json

Stdio command (npx, uvx, etc.)

标准输入输出命令(npx、uvx等)

fastmcp list --command 'npx -y @modelcontextprotocol/server-github'
fastmcp list --command 'npx -y @modelcontextprotocol/server-github'

Include full input/output schemas

包含完整的输入/输出模式

fastmcp list server.py --input-schema --output-schema
fastmcp list server.py --input-schema --output-schema

Machine-readable JSON

机器可读的JSON格式输出

fastmcp list server.py --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.
fastmcp list server.py --resources --prompts

默认输出会显示工具签名和描述。使用`--input-schema`或`--output-schema`参数可包含完整的JSON模式,使用`--json`参数可获取结构化输出。

Calling Tools

调用工具

bash
undefined
bash
undefined

Key=value arguments (auto-coerced to correct types)

键值对参数(自动转换为正确类型)

fastmcp call server.py greet name=World fastmcp call server.py add a=3 b=4
fastmcp call server.py greet name=World fastmcp call server.py add a=3 b=4

Single JSON object for complex/nested args

单个JSON对象用于复杂/嵌套参数

fastmcp call server.py create_item '{"name": "Widget", "tags": ["a", "b"]}'
fastmcp call server.py create_item '{"name": "Widget", "tags": ["a", "b"]}'

--input-json with key=value overrides

使用--input-json参数并通过键值对覆盖配置

fastmcp call server.py search --input-json '{"query": "hello", "limit": 5}' limit=10
fastmcp call server.py search --input-json '{"query": "hello", "limit": 5}' limit=10

JSON output for scripting

用于脚本的JSON格式输出

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.
fastmcp call server.py add a=3 b=4 --json

类型转换是自动的:基于工具的输入模式,`limit=5`会转换为整数,`verbose=true`会转换为布尔值。

Server Targets

服务器目标

All commands accept the same server targets:
TargetExample
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
:
bash
fastmcp list http://localhost:8000/mcp --transport sse
所有命令都支持以下服务器目标:
目标类型示例
HTTP/HTTPS URL
http://localhost:8000/mcp
Python文件
server.py
MCPConfig JSON配置
mcp.json
(必须包含
mcpServers
键)
标准输入输出命令
--command 'npx -y @mcp/server'
已发现的名称
weather
source:name
编辑器配置(Claude Desktop、Claude Code、Cursor、Gemini CLI、Goose)或项目级
mcp.json
中配置的服务器可以通过名称引用。使用
source:name
格式(例如
claude-code:my-server
cursor:weather
)可指定特定来源的服务器。运行
fastmcp discover
命令查看可用的服务器名称。
对于SSE服务器,需传递
--transport sse
参数:
bash
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
:
bash
fastmcp call http://server/mcp tool --auth none
HTTP目标会自动使用OAuth认证(如果服务器不需要认证则无操作)。可使用
--auth none
参数禁用认证:
bash
fastmcp call http://server/mcp tool --auth none

Discovering Configured Servers

发现已配置的服务器

bash
undefined
bash
undefined

See all MCP servers in editor/project configs

查看编辑器/项目配置中的所有MCP服务器

fastmcp discover
fastmcp discover

Filter by source

按来源过滤

fastmcp discover --source claude-code
fastmcp discover --source claude-code

JSON output

JSON格式输出

fastmcp discover --json

Scans Claude Desktop, Claude Code, Cursor, Gemini CLI, Goose, and `./mcp.json`. Sources: `claude-desktop`, `claude-code`, `cursor`, `gemini`, `goose`, `project`.
fastmcp discover --json

扫描范围包括Claude Desktop、Claude Code、Cursor、Gemini CLI、Goose以及`./mcp.json`文件。来源类型包括:`claude-desktop`、`claude-code`、`cursor`、`gemini`、`goose`、`project`。

Workflow Pattern

工作流模式

Discover tools first, then call them:
bash
undefined
先发现工具,再调用它们:
bash
undefined

1. See what servers are configured

1. 查看已配置的服务器

fastmcp discover
fastmcp discover

2. See what tools a server has

2. 查看某服务器提供的工具

fastmcp list weather
fastmcp list weather

3. Call a tool

3. 调用工具

fastmcp call weather get_forecast city=London

If you call a nonexistent tool, FastMCP suggests close matches.
fastmcp call weather get_forecast city=London

如果你调用了不存在的工具,FastMCP会提示相似的匹配项。