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):
MCPPROXY_TRAY_ENDPOINTwhen it is anhttp(s)://URL (the base URL; the MCP path is appended).- Otherwise the core's Unix socket / Windows named pipe:
MCPPROXY_TRAY_ENDPOINT(unix:///npipe://), else the config'stray_endpoint, else the socket in the data directory (~/.mcpproxy/mcpproxy.sock).--config,--data-dir,MCPPROXY_DATA_DIRand--systemselect which instance. - 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 loopbacklistenaddress.
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
| Connection | No --key | --key mcp_agt_… / mcp_cli_… | API key |
|---|---|---|---|
| Socket / pipe (default) | administrator (credential kind socket) | that token's scope | refused (exit 4): the socket already grants administrator access |
--url / http(s) MCPPROXY_TRAY_ENDPOINT | anonymous (as any keyless HTTP client) | that token's scope | administrator |
--tcp-fallback (loopback listen) | anonymous | not 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 stdiogets 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-Instanceheader (this version and later), because older cores could admit an unrecognised scoped value as the administrator. With an older core the client getsthis MCPProxy cannot enforce a scoped credential; upgrade itand 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_KEYis 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./-namefor such a path. - With
--url, a credential is sent over plainhttponly to a loopback host; usehttpsfor anything else. URLs with user info or anapikeyparameter 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
| Flag | Path |
|---|---|
| (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, defaultwarn).--log-to-file,--log-dir,--outputand--jsonare 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 saysthe 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 withmcpproxy-stdio-are reserved.
Exit codes
| Code | Meaning |
|---|---|
| 0 | stdin closed, or SIGINT/SIGTERM |
| 1 | no core within --wait; the core refused initialize or the session start; the connection was lost; a stdin message over 32 MiB; stdout failed |
| 4 | invalid flags or credential (see above), an unreadable or invalid explicit config |
| 130 / 143 | second 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.