Stdio-to-HTTP gateway — connects MCP clients to remote HTTP MCP servers
Project description
mcp-stdio
English | 日本語
Stdio-to-HTTP gateway — connects MCP clients to remote HTTP MCP servers.
Overview
MCP clients like Claude Desktop and Claude Code see mcp-stdio as a locally running self-hosted MCP server, while it relays all requests to a remote MCP server with support for various authentication methods:
flowchart BT
A[Claude<br>Desktop/Code] <-- stdio --> B(mcp-stdio)
B <== "<b>HTTPS</b><br>Streamable HTTP / SSE<br>Bearer Token<br>Header<br>OAuth" ==> C[Remote<br>MCP Server]
B -. "OAuth 2.1<br>(PKCE)" .-> D[Authorization<br>Server]
D -. callback .-> B
style B fill:#4a5,stroke:#333,color:#fff
Bearer tokens, custom headers, and OAuth 2.1 credentials are forwarded to the remote server.
Features
- Both MCP transports supported — Streamable HTTP (current spec, default) and SSE (MCP 2024-11-05 legacy), selectable with
--transport. SSE parser follows the WHATWG Server-Sent Events spec. - OAuth 2.1 client — built-in authorization code flow with PKCE, dynamic client registration, token refresh, and secure token persistence. Implements the full MCP authorization spec:
- RFC 9728 Protected Resource Metadata discovery
- RFC 8414 Authorization Server Metadata discovery (§3 path insertion for issuers with path components)
- RFC 8707 Resource Indicators for audience binding
- RFC 7636 PKCE with S256 challenge method
- RFC 7591 Dynamic Client Registration
- RFC 6750 Bearer Token usage
- Retry with backoff — retries up to 3 times on connection errors
- Streaming resilience — streams SSE responses in real time; auto-reconnects on mid-stream disconnect
- Session recovery — resets MCP session ID on 404 and retries
- Token refresh on 401 — automatically refreshes expired OAuth tokens mid-session
- Bearer token auth — via
--bearer-tokenflag orMCP_BEARER_TOKENenv var - Custom headers — pass any header with
-H - Graceful shutdown — handles SIGTERM/SIGINT
- Proxy support — respects
HTTP_PROXY,HTTPS_PROXY,NO_PROXYenv vars via httpx - Minimal dependencies — only httpx; OAuth uses stdlib only
Install
pip install mcp-stdio
Or with uv:
uv tool install mcp-stdio
Or run directly without installing:
uvx mcp-stdio https://your-server.example.com:8080/mcp
Or with Homebrew:
brew install shigechika/tap/mcp-stdio
Quick Start
mcp-stdio https://your-server.example.com:8080/mcp
With Bearer token authentication:
# Recommended: use env var (token is hidden from `ps`)
MCP_BEARER_TOKEN=YOUR_TOKEN mcp-stdio https://your-server.example.com:8080/mcp
# Or pass directly (token is visible in `ps` output)
mcp-stdio https://your-server.example.com:8080/mcp --bearer-token YOUR_TOKEN
With custom headers:
mcp-stdio https://your-server.example.com:8080/mcp --header "X-API-Key: YOUR_KEY"
With OAuth 2.1 authentication (for servers that require it):
mcp-stdio --oauth https://your-server.example.com:8080/mcp
# With a pre-registered client ID (skips dynamic registration)
mcp-stdio --oauth --client-id YOUR_CLIENT_ID https://your-server.example.com:8080/mcp
For legacy MCP servers using the 2024-11-05 SSE transport:
mcp-stdio --transport sse https://your-server.example.com:8080/sse
Test connectivity before use:
mcp-stdio --test https://your-server.example.com:8080/mcp
Claude Desktop Configuration
Add to claude_desktop_config.json:
{
"mcpServers": {
"my-remote-server": {
"command": "mcp-stdio",
"args": ["https://your-server.example.com:8080/mcp"],
"env": {
"MCP_BEARER_TOKEN": "YOUR_TOKEN"
}
}
}
}
Config file locations:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Claude Code Configuration
claude mcp add my-remote-server \
-e MCP_BEARER_TOKEN=YOUR_TOKEN \
-- mcp-stdio https://your-server.example.com:8080/mcp
Usage
mcp-stdio [OPTIONS] URL
Arguments:
URL Remote MCP server URL
Options:
--bearer-token TOKEN Bearer token (or set MCP_BEARER_TOKEN env var)
--oauth Enable OAuth 2.1 authentication
--client-id ID Pre-registered OAuth client ID (or set MCP_OAUTH_CLIENT_ID)
--oauth-scope SCOPE OAuth scope to request
-H, --header 'Key: Value' Custom header (can be repeated)
--transport {streamable-http,sse}
Transport type (default: streamable-http)
--timeout-connect SEC Connection timeout (default: 10)
--timeout-read SEC Read timeout (default: 120)
--test Test connection and exit
-V, --version Show version
-h, --help Show help
Workarounds
Works around known issues in Claude Code's HTTP transport:
- Bearer token not sent — Claude Code ignores
Authorizationheader on tool calls (#28293, #33817) - Missing Accept header — servers return 406, misinterpreted as auth failure (#42470)
- OAuth fallback loop — Claude Code enters OAuth discovery even when not needed (#34008, #39271)
- Session lost after disconnect — mcp-stdio recovers MCP sessions automatically on 404 (#34498, #38631)
- OAuth scope omitted — Claude Code sends no
scopeparameter in authorization requests, causing strict OAuth servers to reject the flow (#4540); mcp-stdio sends scopes via--oauth-scope - Proxy settings ignored — Claude Code does not respect
NO_PROXY(#34804); mcp-stdio inherits proxy settings from httpx
How It Works
- If
--oauthis set, obtains an access token (cached → refresh → browser flow) - Reads JSON-RPC messages from stdin (sent by Claude Desktop/Code)
- Relays them over HTTPS to the remote MCP server
- Parses responses and writes them to stdout
- On 401, refreshes the OAuth token and retries
Transport details:
- Streamable HTTP (default) — each stdin message is a single POST; session state is tracked via the
Mcp-Session-Idheader and re-initialized automatically on 404. - SSE (MCP 2024-11-05 legacy) — a persistent
GETstream delivers responses and the initialendpointevent containing the POST URL; the stream auto-reconnects on disconnect.
OAuth tokens are stored in ~/.config/mcp-stdio/tokens.json (permissions 0600).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_stdio-0.4.1.tar.gz.
File metadata
- Download URL: mcp_stdio-0.4.1.tar.gz
- Upload date:
- Size: 45.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98fc81f0b8e9a02d735cf2ddb6a329b342b64b279a71a6266fbcc3f3a9e30597
|
|
| MD5 |
7842dd4eb1f258e9e77980878e7000fb
|
|
| BLAKE2b-256 |
665a29f78290f19d1a9b295b01fa52c013526c551d190957db1c71de8791f18b
|
Provenance
The following attestation bundles were made for mcp_stdio-0.4.1.tar.gz:
Publisher:
release.yml on shigechika/mcp-stdio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_stdio-0.4.1.tar.gz -
Subject digest:
98fc81f0b8e9a02d735cf2ddb6a329b342b64b279a71a6266fbcc3f3a9e30597 - Sigstore transparency entry: 1280385498
- Sigstore integration time:
-
Permalink:
shigechika/mcp-stdio@7153706f4af098507582b94e1028f028fee77661 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/shigechika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7153706f4af098507582b94e1028f028fee77661 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_stdio-0.4.1-py3-none-any.whl.
File metadata
- Download URL: mcp_stdio-0.4.1-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
823b523a6e97280fb33f0770e0652ef95d3d2fe87f9c1a68348e9573d3400c17
|
|
| MD5 |
81004d8328a95506adc997ab85e1e571
|
|
| BLAKE2b-256 |
2639f64c9802214db5a180f1386524a76f7f344ce96666a8a1a0ece3837368d3
|
Provenance
The following attestation bundles were made for mcp_stdio-0.4.1-py3-none-any.whl:
Publisher:
release.yml on shigechika/mcp-stdio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_stdio-0.4.1-py3-none-any.whl -
Subject digest:
823b523a6e97280fb33f0770e0652ef95d3d2fe87f9c1a68348e9573d3400c17 - Sigstore transparency entry: 1280385501
- Sigstore integration time:
-
Permalink:
shigechika/mcp-stdio@7153706f4af098507582b94e1028f028fee77661 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/shigechika
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7153706f4af098507582b94e1028f028fee77661 -
Trigger Event:
push
-
Statement type: