Skip to main content

Stdio Command

mcpproxy stdio connects an MCP client that only speaks stdio (Claude Desktop's JSON configuration, many editors and agents) to the MCPProxy core that is already running — the one the tray starts, or mcpproxy serve. It replaces npx -y mcp-remote http://localhost:8080/mcp: no Node.js, and no API key in the client's configuration.

{
"mcpServers": {
"mcpproxy": {
"command": "/Applications/MCPProxy.app/Contents/Resources/bin/mcpproxy",
"args": ["stdio"]
}
}
}

The client starts the command and speaks MCP on its stdin/stdout. The bridge copies every message to the core's /mcp endpoint and back, unchanged. Use the full path of the mcpproxy binary when the client does not inherit your shell's PATH (Claude Desktop does not).

How it connects​

Without --url, the bridge finds the core the same way the other CLI commands do, and reads your configuration read-only (it never creates a file, never opens config.db and never reads the API key):

  1. MCPPROXY_TRAY_ENDPOINT when it is an http(s):// URL (the base URL; the MCP path is appended).
  2. Otherwise the core's Unix socket / Windows named pipe: MCPPROXY_TRAY_ENDPOINT (unix:// / npipe://), else the config's tray_endpoint, else the socket in the data directory (~/.mcpproxy/mcpproxy.sock). --config, --data-dir, MCPPROXY_DATA_DIR and --system select which instance.
  3. Only with --tcp-fallback, and only when the configuration says there is no socket (enable_socket: false, or the packaged Linux service), the config's loopback listen address.

Over the socket the bridge checks, on every connection, that the listening process runs as your OS user; a socket or pipe owned by another user never receives a byte.

The bridge waits for a core for up to --wait (default 15s), so a client that starts before the tray works. --wait 0 makes one attempt per candidate.

Authentication​

ConnectionNo --key--key mcp_agt_… / mcp_cli_…API key
Socket / pipe (default)administrator (credential kind socket)that token's scoperefused (exit 4): the socket already grants administrator access
--url / http(s) MCPPROXY_TRAY_ENDPOINTanonymous (as any keyless HTTP client)that token's scopeadministrator
--tcp-fallback (loopback listen)anonymousnot used: the bridge never sends a credential to a port it found by itself—

Security note: over the socket, any process of your OS user that can run mcpproxy stdio gets administrator access unless you give a scoped credential. For a client you do not fully trust, mint an agent token or client credential and pass it with --key-file.

mcpproxy token create --name claude-desktop --profile work # prints mcp_agt_…; save it to a file
"args": ["stdio", "--key-file", "~/.mcpproxy/claude-desktop.key"]

Credential sources, in order: --key <value>, --key-file <path> (a regular file of at most 4 KiB; whitespace trimmed, ~ expanded), env MCPPROXY_STDIO_KEY (used as is, not trimmed). The credential is read once at startup and sent only in the X-API-Key header.

Rules that fail closed (exit 4, the key is never printed):

  • With discovery (no --url), only agent tokens (mcp_agt_…) and client credentials (mcp_cli_…) of at least 16 characters are accepted. A typo or the API key would otherwise be treated by the local core as the administrator.
  • A scoped credential is used only with a core that sends the X-MCPProxy-Instance header (this version and later), because older cores could admit an unrecognised scoped value as the administrator. With an older core the client gets this MCPProxy cannot enforce a scoped credential; upgrade it and the bridge exits 1.
  • mcp_oat_ browser-login tokens are refused: they only work on /mcp/oauth.
  • An empty key file or an empty MCPPROXY_STDIO_KEY is an error, so a missing shell expansion never silently becomes an unscoped connection.
  • A credential must be printable ASCII without spaces, " or \, and not only digits.
  • A text flag value that starts with - is refused with the fixed flag error, because it is usually the next flag taken as a missing value (--config --key=…). This also refuses a credential or path that starts with -; use ./-name for such a path.
  • With --url, a credential is sent over plain http only to a loopback host; use https for anything else. URLs with user info or an apikey parameter are refused.

The bridge never writes the credential to stdout or stderr. A message from the core that contains it is withheld: a response becomes the error the response was withheld because it contained the credential, a notification is dropped. With a short user-chosen API key on --url this can withhold answers that merely contain the same text; prefer long keys.

Choosing an endpoint​

FlagPath
(none)/mcp
--server <name>/mcp/s/<name> — one upstream server (names containing / are not supported yet; use --url)
--profile <slug>/mcp/p/<slug>
--routing all|code|call/mcp/all, /mcp/code, /mcp/call
--url <http(s) URL>that exact URL over TCP, e.g. a remote core or the server edition in Docker; excludes the other selectors and --config / --data-dir

An unknown server or profile is reported to the client as the core's 404 text, and the bridge exits 1.

Output, shutdown and restarts​

  • stdout carries only JSON-RPC messages, one per line. Logs, warnings and errors go to stderr (--log-level, default warn). --log-to-file, --log-dir, --output and --json are refused.
  • Closing stdin (or the first SIGINT/SIGTERM) lets in-flight requests finish for up to 2 seconds, ends the HTTP session and exits 0 within 5 seconds. A second signal exits at once (130 / 143).
  • Core restarts: in this version the bridge does not reconnect. When the core goes away or restarts, requests in flight get an error (Connection to MCPProxy lost; the request may have been processed. when it may have run), stderr says the connection to MCPProxy was lost; restart the MCP client to reconnect, and the bridge exits 1. Restart the client (or the MCP server inside it) after updating MCPProxy. A request whose delivery is uncertain is never resent.
  • Server-to-client requests (sampling, elicitation, roots) and notifications are relayed. Their ids are rewritten to mcpproxy-stdio-… on the way out and restored on the reply, so client request ids starting with mcpproxy-stdio- are reserved.

Exit codes​

CodeMeaning
0stdin closed, or SIGINT/SIGTERM
1no core within --wait; the core refused initialize or the session start; the connection was lost; a stdin message over 32 MiB; stdout failed
4invalid flags or credential (see above), an unreadable or invalid explicit config
130 / 143second SIGINT / SIGTERM

Versus mcpproxy serve --listen ""​

serve --listen "" runs a second, complete core with the native stdio transport. It opens config.db, so it cannot run next to the tray's core (exit 3, database locked). mcpproxy stdio is a thin bridge to the core that is already running and shares its servers, quarantine state and activity log.

Self-import​

The configuration importer does not yet recognise mcpproxy stdio entries as pointing back at the importing core. Do not import a client configuration that contains this entry into the same MCPProxy; remove the entry from the import selection.