Cloud Run MCP transparent proxy (stdio <-> streamable HTTP)
Project description
mcp-cloudrun-proxy
Transparent proxy for using an MCP server deployed on Cloud Run (Streamable HTTP) as a local stdio MCP server.
Access to Cloud Run uses IAM Invoker + ID Token (Bearer), and the proxy automatically refreshes expired tokens.
What It Does
- Local side: acts as a stdio MCP server
- Remote side: connects to a Streamable HTTP MCP server
- Transparently relays JSON-RPC messages bidirectionally
- Adds
Authorization: Bearer <ID Token>to all requests - Refreshes tokens and retries/reconnects on
401/403
Prerequisites
- Python 3.10+
- A Cloud Run MCP endpoint (for example:
https://xxxx.run.app/mcp) - Valid ADC (Application Default Credentials) in the runtime environment
- Cloud Run Invoker role granted to the calling principal
ADC Setup (Local Development)
If you use user credentials locally, you usually need to set up ADC first:
gcloud auth application-default login
Notes:
gcloud auth loginalone may not configure ADC (this tool uses ADC).- If you use a service account,
GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.jsonalso works.
Usage
uvx mcp-cloudrun-proxy run \
--url https://xxxx.run.app/mcp \
--audience https://xxxx.run.app \
--token-source google-auth \
--log-level info \
--refresh-margin 60
If you installed the command locally (for example with pipx, uv tool, or Nix),
replace uvx mcp-cloudrun-proxy run with mcp-cloudrun-proxy run.
Options:
--url(required): Cloud Run MCP endpoint URL--audience(optional): ID token audience (inferred from--urlif omitted)--log-level:info/debug/warn--refresh-margin: Seconds before expiry to refresh proactively (default:60)--token-source(required):google-auth/gcloud
Notes:
- If
--audienceis omitted, the proxy extractsscheme://host[:port]from--url. - In many cases, the audience should be the Cloud Run service URL (without
/mcp), but it must match your server-side expectations. - In
--token-source gcloudmode, theaudiencevalue is ignored because the gcloud user-credential path does not support audience-scoped ID tokens. - Use
--token-source google-authfor service account / metadata-based credentials. - Use
--token-source gcloudfor local user ADC when you want token issuance via thegcloudCLI.
Debug Command
Use the debug subcommand to test token issuance and Cloud Run access step by step.
uvx mcp-cloudrun-proxy debug \
--url https://xxxx.run.app/mcp \
--token-source gcloud
What it checks:
- ID token issuance (and prints which token source was used)
- Authenticated HTTP reachability to the Cloud Run endpoint
Tip:
- If local development changes are not reflected with
uvx, tryuvx --refresh ...oruv cache clean.
Claude Desktop / Claude Code Configuration
Register this proxy as a stdio MCP server. Client config schemas vary, so the examples below are generic patterns.
Recommended example using uvx (no local install):
{
"mcpServers": {
"cloudrun-proxy": {
"command": "uvx",
"args": [
"mcp-cloudrun-proxy",
"run",
"--url",
"https://xxxx.run.app/mcp",
"--audience",
"https://xxxx.run.app",
"--token-source",
"gcloud"
]
}
}
}
Nix
You can use this project via Nix without cloning the repository.
Run directly (no install):
nix run github:logicoffee/mcp-cloudrun-proxy -- \
run \
--url https://xxxx.run.app/mcp \
--audience https://xxxx.run.app \
--token-source google-auth
Install via Nix:
nix profile install github:logicoffee/mcp-cloudrun-proxy
After installation:
mcp-cloudrun-proxy run --url https://xxxx.run.app/mcp --audience https://xxxx.run.app --token-source google-auth
Troubleshooting
401/403keeps happening:- Check the
--audiencevalue first - If you are using user ADC, try
--token-source gcloudand note thataudienceis ignored in gcloud mode - If Cloud Run requires an audience-scoped ID token, use a service account (
--token-source google-auth) - Confirm the Cloud Run Invoker role is granted
- Confirm ADC points to the expected account
- Check the
- Connection closes immediately:
- Confirm
--urlpoints to the MCP endpoint (/mcp) - Confirm Streamable HTTP transport is enabled on the Cloud Run side
- Confirm
- Logs are not visible:
- Logs are written to stderr (stdout is reserved for the MCP protocol)
Security Notes
- ID token contents are not logged
- Raw Authorization values are not logged or included in exception messages
- This proxy is intended as a secure relay that relies on Cloud Run IAM
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_cloudrun_proxy-0.1.0.tar.gz.
File metadata
- Download URL: mcp_cloudrun_proxy-0.1.0.tar.gz
- Upload date:
- Size: 75.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50d209a00f4d64dae490a6af9cef20ce84eafa8a85ab1c95a582488be7c21fcd
|
|
| MD5 |
eff8eb85146cb42586ce7554f6dc1800
|
|
| BLAKE2b-256 |
9f19dece93d799f2ab6cc65f9130b6d7e56173e16a79dfbbeb5b1522079668e5
|
Provenance
The following attestation bundles were made for mcp_cloudrun_proxy-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on logicoffee/mcp-cloudrun-proxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_cloudrun_proxy-0.1.0.tar.gz -
Subject digest:
50d209a00f4d64dae490a6af9cef20ce84eafa8a85ab1c95a582488be7c21fcd - Sigstore transparency entry: 997062049
- Sigstore integration time:
-
Permalink:
logicoffee/mcp-cloudrun-proxy@3b50ede02b262099ed0eb39a3e02c2390b317629 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/logicoffee
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3b50ede02b262099ed0eb39a3e02c2390b317629 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mcp_cloudrun_proxy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_cloudrun_proxy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b852a58ec16b3def7e25e3b2346d69ebe37dbd9bc508cca6e9b2ebc5bd07935
|
|
| MD5 |
43b7a027d53c61b15865e6881befae98
|
|
| BLAKE2b-256 |
d15c11e49657aef27bcd19d5b1fe9ef0475b8e1d8412e5bb9fff8870e0f94d7f
|
Provenance
The following attestation bundles were made for mcp_cloudrun_proxy-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on logicoffee/mcp-cloudrun-proxy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_cloudrun_proxy-0.1.0-py3-none-any.whl -
Subject digest:
7b852a58ec16b3def7e25e3b2346d69ebe37dbd9bc508cca6e9b2ebc5bd07935 - Sigstore transparency entry: 997062119
- Sigstore integration time:
-
Permalink:
logicoffee/mcp-cloudrun-proxy@3b50ede02b262099ed0eb39a3e02c2390b317629 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/logicoffee
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@3b50ede02b262099ed0eb39a3e02c2390b317629 -
Trigger Event:
release
-
Statement type: