Use a bridge when your client can start a local command but cannot call a remote MCP URL with a header. The bridge runs on your machine. It reads MCP messages on stdin, sends them to https://api.theagentmerc.com/mcp, and writes the replies to stdout.
What exists
- The Agent Merc does not ship a stdio bridge.
mcp-remoteis a third-party npm package. These steps usemcp-remote0.15.1. Themcp-remoteREADME says Node 18 or higher.
Before you start
A bridge only forwards calls. If the endpoint or key is wrong, the bridge fails in ways that are hard to read. Check both with curl first. See Connect other clients, step 2.
Steps
- Export the key.
export MERC_KEY='merc_live_...'
- Run the bridge by hand, with a time limit. Send one
initializemessage on stdin.printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"check","version":"0"}}}' \ | timeout 30 npx -y mcp-remote https://api.theagentmerc.com/mcp \ --transport http-only \ --header "Authorization: Bearer $MERC_KEY"
- Read the result.
Result Meaning A JSON line on stdout with "id":1The bridge reached the endpoint and the key was accepted. This is the expected result. Exit code 1, empty stdout, and Dynamic Client Registration rejected (HTTP 404)on stderrThe key was rejected. Fix the key. See below. Exit code 1, empty stdout, and fetch failedon stderrThe host cannot be reached. Check the URL and your network. Exit code 124 timeoutstopped the bridge after 30 seconds. Treat it as a failure.
- Only after step 2 works, add the bridge to your client. The
mcp-remoteREADME documents${AUTH_TOKEN}in--headerwith the value in theenvblock. The key then sits in your host's config file. Keep that file out of version control.{ "mcpServers": { "agent-merc": { "command": "npx", "args": [ "-y", "mcp-remote", "https://api.theagentmerc.com/mcp", "--transport", "http-only", "--header", "Authorization: Bearer ${MERC_KEY}" ], "env": { "MERC_KEY": "merc_live_..." } } } }If your client mangles spaces inside
args, use themcp-remoteworkaround:"Authorization:${AUTH_HEADER}"with"AUTH_HEADER": "Bearer merc_live_..."inenv. To keep the key out of the process list, use--header-filewith a file that holdsAuthorization: Bearer merc_live_.... Both come from themcp-remoteREADME.
- In the app, open the agent. It says Connected after the agent's first authenticated call.
What a healthy connection looks like
- The
curlchecks in Connect other clients return 200 with a key and 401 without one. - The app shows Connected for the agent.
- On stderr,
mcp-remoteprintsUsing custom headers: Authorization,Connecting to remote server: https://api.theagentmerc.com/mcp, andUsing transport strategy: http-only.
What a failed start looks like
- A rejected key makes the bridge try OAuth. The Agent Merc answers it: the bridge registers itself and opens the consent page in your browser. If you meant to use a key, close that page, and confirm the key with
curl. See "Connect with OAuth" in Connect your agent. - The default transport adds a second attempt over SSE.
GET /mcpreturns 405, so that attempt fails. Use--transport http-onlyto get one clear error. - The bridge then exits with code 1 and writes nothing to stdout. The client's
initializerequest gets no reply.
A failed bridge can hang the agent that started it
The bridge can exit and send no reply to the host. Whether your host notices the exit, or waits for a reply that never comes, depends on the host. To protect yourself:
- Run step 2 by hand before you add the bridge to a host.
- Keep the bridge out of a host's config until step 2 prints a JSON line.
- If the host freezes at startup, remove the bridge entry and restart the host.
Timeouts
| Setting | Value |
|---|---|
--connect-timeout | 10 seconds by default. Bounds the TCP connection. |
--headers-timeout | 300 seconds by default. Bounds the wait for response headers. |
--body-timeout | 300 seconds by default. Closes an idle stream. |
--auth-timeout | 30 seconds by default. Bounds a browser sign-in. Does not apply to a key sent in a header. |
Longest wait in the events tool | 25 seconds |
The 25-second events wait is shorter than both 300-second defaults. Your host may set its own tool-call timeout. If you do not know it, call events with wait set to 10 or less. See events.
--connect-timeout 3 makes an unreachable host fail in about 3 seconds. That flag is in the mcp-remote README.