mcpc

作者: apify

使用 mcpc 命令行界面与 MCP 服务器交互——调用工具、读取资源、获取提示。在处理模型上下文协议服务器、调用 MCP 时使用此功能。

npx skills add https://github.com/apify/mcpc --skill mcpc

mcpc: MCP command-line client

mcpc maps every MCP operation to a shell command. For agents this is often more efficient than function calling: discover the right tool on demand, then generate shell commands (ideally with --json) instead of carrying tool definitions in context.

Mental model

  1. Connect once to a server — this creates a persistent, named @session. A background bridge process keeps the connection (and its state) alive.
  2. Run commands against the @session: list/call tools, read resources, get prompts, run async tasks. There is no one-shot mcpc <url> tools-list — connect first.
  3. Default output is human-readable; add --json for machine-readable, MCP-spec shaped output that composes with jq and shell pipelines (code mode).

Everything is self-documenting — when unsure, ask the CLI:

mcpc --help                       # all commands + global options
mcpc help connect                 # help for one command
mcpc @apify tools-call foo --help # that tool's details + schema

First steps

mcpc                                   # list sessions + auth profiles (start here)
mcpc connect mcp.apify.com @apify      # connect, create the @apify session
mcpc @apify                            # server info, capabilities, tools overview
mcpc @apify tools-list                 # list tools
mcpc @apify tools-call <tool> q:="hi"  # call a tool

Connecting

Server formats accepted by connect:

  • mcp.example.com — remote HTTP server (https:// is added automatically)
  • localhost:8080 or 127.0.0.1:8080 — local HTTP server (http:// is the default for localhost and 127.0.0.1)
  • ~/.vscode/mcp.json:filesystem — a single entry from a config file (file:entry)
  • ~/.vscode/mcp.json — connect every entry in a config file
  • (no server) — auto-discover standard configs and connect all of them
mcpc connect mcp.apify.com @apify        # remote server, explicit session name
mcpc connect mcp.apify.com               # auto-name the session → @apify
mcpc connect ./.vscode/mcp.json:fs @fs   # one config entry (stdio or http)
mcpc connect                             # discover standard configs + connect everything
  • @session is optional — omit it to auto-generate a name from the server (mcp.apify.com@apify). A matching session (same server + auth) is reused.
  • Stdio (command-based) entries launch a local process on connect — only connect to configs you trust. Bulk connects skip stdio entries unless you pass --stdio.
  • login / logout only accept an MCP server URL (a bare host or full http(s):// URL) — not config files or auto-discovery.

Sessions

mcpc                     # list all sessions and their state
mcpc @apify              # session details, capabilities, tools (also reports the
                         # negotiated protocol version and stateful vs stateless)
mcpc restart @apify      # restart (after server updates, or to recover an 'expired' session)
mcpc close @apify        # tear the session down

Session states:

  • 🟢 live — ready to use
  • 🟡 connecting / reconnecting — transient; retry in a moment
  • 🟡 disconnected — bridge alive but the server has gone quiet; retry to reconnect
  • 🟡 crashed — bridge process died; auto-restarts on next use
  • 🔴 unauthorized — auth failed; run mcpc login <server> then mcpc restart @session
  • 🔴 expired — server dropped the session; run mcpc restart @session

Discovering and inspecting tools

mcpc @apify tools-list                  # compact list with inline param signatures
mcpc @apify tools-list --full           # full JSON schemas
mcpc @apify tools-get <tool>            # one tool's details + schema
mcpc @apify tools-call <tool> --help    # shortcut for tools-get: that tool's details + schema

mcpc grep "search"                      # search tools + instructions across ALL sessions
mcpc @apify grep "actor" --resources    # search one session
# grep filters: --tools/--resources/--prompts/--instructions, -E regex, -s case-sensitive, -m <n> max

Prefer progressive discovery: grep to find the right tool, then tools-get for its schema. This keeps token use low instead of dumping every tool definition.

Calling tools (passing arguments)

Arguments go after the tool name. Three interchangeable styles:

# 1) key:=value — values are auto-parsed as JSON, falling back to string
mcpc @apify tools-call search query:="hello world" limit:=10 enabled:=true
mcpc @apify tools-call search config:='{"nested":"value"}' items:='[1,2,3]'
mcpc @apify tools-call search id:='"123"'          # force a string with JSON quotes

# 2) inline JSON — when the first arg starts with { or [
mcpc @apify tools-call search '{"query":"hello","limit":10}'

# 3) stdin — auto-detected when piped and no positional args are given
echo '{"query":"hello"}' | mcpc @apify tools-call search

JSON output (code mode)

Add --json for machine-readable output: results on stdout, errors on stderr, shaped strictly per the MCP spec.

mcpc --json @apify tools-list | jq -r '.[].name'
mcpc --json @apify tools-call search query:="test" | jq -r '.content[0].text'

# chain tools across calls/sessions
mcpc --json @apify tools-call search-actors keywords:="scraper" \
  | jq -r '.content[0].text | fromjson | .items[0].id' \
  | xargs -I{} mcpc --json @apify tools-call get-actor actorId:="{}"

mcpc --json with no command returns { "sessions": [...], "profiles": [...] }.

Resources and prompts

mcpc @apify resources-list
mcpc @apify resources-read "file:///path/to/file"   # -o <file> to save (binary-safe), --raw to pipe
mcpc @apify resources-templates-list
mcpc @apify resources-subscribe <uri> <file>        # keep local <file> in sync with the resource
mcpc @apify resources-unsubscribe <uri>             # stop syncing, keep the file

mcpc @apify prompts-list
mcpc @apify prompts-get <name> arg1:=value1         # same argument syntax as tools-call (values coerced to strings)

Async tasks (long-running tools)

mcpc @apify tools-call <tool> --task <args>     # run as a task with a progress spinner; Ctrl+C (or
                                                # ESC) leaves it running and prints the task ID.
                                                # Falls back to a normal sync call if the server has no task support.
mcpc @apify tools-call <tool> --detach <args>   # start and return the task ID immediately
mcpc @apify tasks-list
mcpc @apify tasks-get <taskId>                  # status
mcpc @apify tasks-result <taskId>               # block until the final result is ready
mcpc @apify tasks-cancel <taskId>

Authentication

# OAuth — interactive browser login, saved as a reusable profile
mcpc login mcp.apify.com                    # "default" profile
mcpc login mcp.apify.com --profile work     # a named profile (multiple accounts per server)
mcpc connect mcp.apify.com @apify --profile work
mcpc logout mcp.apify.com

# Bearer token — not stored as a profile; kept per-session
mcpc connect mcp.apify.com @s -H "Authorization: Bearer $TOKEN"
mcpc @s tools-list

With no auth flags, mcpc uses the default profile if one exists, otherwise it connects anonymously. Use --no-profile to force an anonymous connection, or --profile <name> to require a specific one.

Proxy for AI isolation

Expose an authenticated session as a local MCP server, so sandboxed AI code can use it without ever seeing your real credentials:

# Human: authenticated session + proxy listening on :8080
mcpc connect mcp.apify.com @ai-proxy --profile ai-access --proxy 8080

# AI in a sandbox limited to localhost: no access to the original tokens
mcpc connect localhost:8080 @sandboxed
mcpc @sandboxed tools-list

A proxy does not make an untrusted server safe — stdio servers still touch your system, and HTTP servers still hold your credentials. Only connect to servers you trust.

Server-published skills (experimental)

Distinct from this guide: some MCP servers publish their own agent skills (draft MCP extension, SEP-2640). Read them with:

mcpc @apify skills-list
mcpc @apify skills-get <name> --raw    # print the SKILL.md markdown (pipe to a file or an LLM)

(mcpc help --skill documents mcpc itself; skills-list / skills-get fetch skills from the server.)

Global flags worth knowing

--json                  # machine-readable, MCP-spec-shaped output (code mode)
--verbose               # protocol-level debug logging (JSON-RPC, transport)
--profile <name>        # OAuth profile to use ("default" if omitted)
--timeout <seconds>     # request timeout in seconds (default: 60)
--max-chars <n>         # truncate human-readable output to n chars (ignored with --json)
--insecure              # skip TLS verification (self-signed certs only)

(--no-profile, --stdio, --proxy, and -H are options of connect, not global flags.)

mcpc also has experimental --x402 auto-payment for paid MCP tools — see mcpc help x402.

Debugging

mcpc --verbose @apify tools-call <tool>   # protocol-level detail (JSON-RPC, transport)
mcpc @apify logs                          # bridge log; -n <N>, --follow, --since 1h
mcpc @apify ping                          # round-trip health check
mcpc clean                                # tidy stale sessions/logs (also: mcpc clean all)

Exit codes

  • 0 — success
  • 1 — client error (invalid arguments, unknown command)
  • 2 — server error (tool failed, resource not found)
  • 3 — network error
  • 4 — authentication error

来自 apify 的更多技能

bug-triage
apify
对 apify/apify-mcp-server 上的开放 bug 问题进行分类。分析、草拟回复、获取批准、发布。
official
dig
apify
用于在Apify MCP服务器上探索、规划和指定工作的灵活技能。请勿编辑源文件——此技能仅用于理解和规划。
official
apify-actor-development
apify
创建、调试和部署用于网页抓取、自动化及数据处理的无服务器云程序。支持JavaScript、TypeScript和Python模板,集成Crawlee、Playwright和Cheerio库,用于HTTP和基于浏览器的爬取。包含通过apify run进行的本地测试(使用隔离存储)、输入/输出的模式验证,以及通过apify push部署到Apify平台。需要Apify CLI认证,并在.actor/actor.json中强制包含generatedBy元数据以用于AI...
official
apify-actorization
apify
将现有项目转换为无服务器Apify Actors,支持语言特定的SDK集成。支持JavaScript/TypeScript(使用Actor.init() / Actor.exit())、Python(异步上下文管理器)以及通过CLI包装器的任何语言。提供结构化工作流:使用apify init搭建脚手架,应用SDK封装,配置输入/输出模式,通过apify run进行本地测试,然后使用apify push进行部署。包含输入和输出模式验证、Docker容器化以及可选的按事件付费...
official
apify-audience-analysis
apify
从Facebook、Instagram、YouTube和TikTok提取受众人口统计、参与模式和行为数据。支持18+个专业Actor,涵盖所有四个平台的粉丝人口统计、参与指标、评论和资料分析。提供三种输出格式:快速聊天显示、CSV导出或JSON导出,用于下游分析。需要Apify令牌和mcpc CLI工具;使用动态模式获取来调整输入以适应每个Actor的要求。包括结构化...
official
apify-brand-reputation-monitoring
apify
监控Google Maps、Booking.com、TripAdvisor、Facebook、Instagram、YouTube和TikTok上的品牌声誉。支持16+个专用Apify Actor,覆盖所有主要平台的评论、评分、评论和提及内容。灵活的输出格式:在聊天中显示结果、导出为CSV或保存为JSON供下游分析使用。需要Apify令牌和Node.js 20.6+;使用mcpc CLI动态获取Actor架构和输入参数。工作流程引导用户选择平台...
official
apify-competitor-intelligence
apify
通过Apify Actors实现多平台竞争对手分析,覆盖Google Maps、Booking.com、Facebook、Instagram、YouTube和TikTok。包含七个平台25+个专用Actors,每个针对特定分析类型优化:商业数据提取、评论对比、广告策略监控、内容表现及受众洞察。需Apify令牌、Node.js 20.6+及mcpc CLI工具以动态获取Actor架构并运行分析。支持三种输出格式:快速聊天展示...
official
apify-content-analytics
apify
通过Apify Actors实现多平台内容分析,支持Instagram、Facebook、YouTube和TikTok。涵盖17+个专业Actors,覆盖所有四个平台的帖子、Reels、故事、评论、话题标签、粉丝和广告。使用mcpc CLI动态获取Actor模式,以确定所需输入和可用输出字段。结果以三种格式输出:快速聊天显示、CSV导出或JSON导出,并可自定义结果数量。需要在.env文件中配置Apify令牌,并安装Node.js 20.6+...
official