Cognito OAuth stdio proxy for AWS Bedrock AgentCore Runtimes
Project description
cognito-mcp-proxy
Cognito OAuth stdio proxy for AWS Bedrock AgentCore Runtimes
A lightweight, uvx-installable package that bridges MCP clients (Kiro IDE, Claude Desktop)
with AgentCore Runtimes secured by Cognito/EntraID OAuth. No .env files, no AWS CLI needed.
Architecture
Kiro IDE <--stdio (JSON-RPC)--> cognito-mcp-proxy <--HTTPS + Bearer JWT--> AgentCore Runtime
|
Cognito OAuth PKCE
(browser sign-in)
How It Works
- On startup, opens your browser for Cognito/EntraID sign-in (OAuth PKCE)
- After auth, reads JSON-RPC messages from stdin (from Kiro)
- For each request: refreshes the JWT, sends it as Bearer token to the AgentCore runtime
- Parses the SSE/JSON response and writes JSON-RPC back to stdout
Installation & Usage
Option 1: uvx (Recommended)
Add to your MCP config (~/.kiro/settings/mcp.json or .kiro/settings/mcp.json):
{
"mcpServers": {
"redshift-secure": {
"command": "uvx",
"args": ["cognito-mcp-proxy@latest"],
"env": {
"AGENTCORE_REGION": "us-east-1",
"AGENTCORE_RUNTIME_ID": "arn:aws:bedrock-agentcore:us-east-1:123456789:runtime/YourRuntime-AbcXyz",
"COGNITO_DOMAIN": "https://your-pool.auth.us-east-1.amazoncognito.com",
"COGNITO_CLIENT_ID": "your_cognito_client_id"
},
"disabled": false,
"autoApprove": ["whoami"]
}
}
}
Option 2: Direct Python (Fallback)
{
"mcpServers": {
"redshift-secure": {
"command": "python",
"args": ["-m", "cognito_mcp_proxy"],
"env": {
"AGENTCORE_REGION": "us-east-1",
"AGENTCORE_RUNTIME_ID": "arn:aws:bedrock-agentcore:...",
"COGNITO_DOMAIN": "https://...",
"COGNITO_CLIENT_ID": "..."
},
"disabled": false
}
}
}
Environment Variables
All configuration is via environment variables set in the env block of your mcp.json:
AgentCore Runtime (Option A — recommended: components)
| Variable | Required | Default | Description |
|---|---|---|---|
AGENTCORE_REGION |
Yes* | Extracted from ARN | AWS region (e.g., us-east-1) |
AGENTCORE_RUNTIME_ID |
Yes* | — | Runtime ARN (e.g., arn:aws:bedrock-agentcore:us-east-1:123456:runtime/MyRuntime-Abc) |
AGENTCORE_QUALIFIER |
No | DEFAULT |
Runtime qualifier/alias |
AgentCore Runtime (Option B — advanced: full URL)
| Variable | Required | Default | Description |
|---|---|---|---|
AGENTCORE_RUNTIME_URL |
Yes* | — | Full invocation URL (overrides region/ID/qualifier) |
*One of Option A or Option B must be provided.
The proxy builds the URL as:
https://bedrock-agentcore.{REGION}.amazonaws.com/runtimes/{URL_ENCODED_ARN}/invocations?qualifier={QUALIFIER}
Cognito OAuth
| Variable | Required | Default | Description |
|---|---|---|---|
COGNITO_DOMAIN |
Yes | — | Cognito User Pool domain (with or without https://) |
COGNITO_CLIENT_ID |
Yes | — | Cognito App Client ID |
COGNITO_REDIRECT_URI |
No | http://localhost:22553/oauth/callback |
OAuth callback URI |
COGNITO_SCOPE |
No | openid email |
OAuth scopes |
COGNITO_CALLBACK_PORT |
No | 22553 |
Local port for OAuth callback server |
COGNITO_REQUEST_TIMEOUT |
No | 120 |
HTTP timeout in seconds for runtime calls |
First-Time Setup
- Add the MCP configuration to your mcp.json (see above)
- Restart Kiro (or reconnect MCP servers)
- On first request, your browser opens for Cognito/Microsoft sign-in
- Complete sign-in — you'll see "Authentication complete"
- Return to Kiro and test: ask "run whoami using redshift-secure"
Connecting to Different Runtimes
Since all config is via env vars, you can have multiple entries pointing to different runtimes:
{
"mcpServers": {
"redshift-secure": {
"command": "uvx",
"args": ["cognito-mcp-proxy@latest"],
"env": {
"AGENTCORE_REGION": "us-east-1",
"AGENTCORE_RUNTIME_ID": "arn:aws:bedrock-agentcore:us-east-1:123456:runtime/Redshift-Prod",
"COGNITO_DOMAIN": "https://my-pool.auth.us-east-1.amazoncognito.com",
"COGNITO_CLIENT_ID": "abc123"
}
},
"another-runtime": {
"command": "uvx",
"args": ["cognito-mcp-proxy@latest"],
"env": {
"AGENTCORE_REGION": "us-west-2",
"AGENTCORE_RUNTIME_ID": "arn:aws:bedrock-agentcore:us-west-2:123456:runtime/Other-Runtime",
"COGNITO_DOMAIN": "https://other-pool.auth.us-west-2.amazoncognito.com",
"COGNITO_CLIENT_ID": "xyz789"
}
}
}
}
Key Differences from tester_bundle
| Feature | tester_bundle (old) | cognito-mcp-proxy (new) |
|---|---|---|
| Installation | Manual copy + pip install truststore |
uvx cognito-mcp-proxy@latest (zero setup) |
| Configuration | Edit .env file |
Set env vars in mcp.json |
| Path management | User must locate Python and script path | Automatic via uvx |
| Upgrades | Manual file replacement | @latest auto-updates |
| Reuse | One config per .env file | Different env vars per mcp.json entry |
| Multi-runtime | Copy entire folder per runtime | Just add another mcp.json entry |
Development
# Clone and build
cd cognito_mcp_proxy
uv venv
uv pip install -e .
# Run directly
cognito_mcp_proxy
# Test with MCP Inspector
npx @modelcontextprotocol/inspector cognito_mcp_proxy
Build & Publish
uv build
uv publish # to PyPI
Troubleshooting
Browser doesn't open:
- Check your default browser is set
- Ensure VPN is connected (corporate network required)
"Invalid grant" error:
- Disconnect and reconnect the MCP server in Kiro
Timeout errors:
- Ensure VPN is active
- Increase
COGNITO_REQUEST_TIMEOUTif runtime is slow
"Required environment variable X is not set":
- Check your mcp.json
envblock has all required variables
"AgentCore runtime not configured":
- Set either
AGENTCORE_RUNTIME_ID(+ optionalAGENTCORE_REGION) orAGENTCORE_RUNTIME_URL
Notes
- No AWS CLI or
aws sso loginneeded - No credentials saved to disk — tokens live in memory only
- Token auto-refreshes (valid ~30 days)
- If already signed into Microsoft, auth completes with zero clicks
- Corporate SSL handled via
truststorepackage - Works with any AgentCore runtime — not limited to Redshift
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 cognito_mcp_proxy-0.1.0.tar.gz.
File metadata
- Download URL: cognito_mcp_proxy-0.1.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
919f64ba6883c1339f697b8242810c09c7a8a3c5914c2020eaff1c4d86346d49
|
|
| MD5 |
d9235dd695bfb5948c7b1484882cac79
|
|
| BLAKE2b-256 |
62b27e85bb5e4b20d79d013b4f0936d1cdc2fc8d911e3936bf0a8bebe993edb2
|
File details
Details for the file cognito_mcp_proxy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cognito_mcp_proxy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a5862085bebfe1441423a9c1d904e0ff926a165ef1188ab1ee3b22305ebaf32
|
|
| MD5 |
0e8f4bdb1500c82cda147e138c20b31d
|
|
| BLAKE2b-256 |
bd6abaf7446a7491e2cf9217efdae4fb74ae6afc6c6e3a5edd359fe22472f99c
|