A generic MCP SSE <-> Stdio bridge with advanced security and SSL/TLS support.
Project description
MCP Stdio Bridge
A generic, professional-grade gateway that bridges Model Context Protocol (MCP) servers between SSE (Server-Sent Events) and Stdio transports.
Features
-
Generic Bridge: Works with any executable that speaks MCP over stdio.
-
Command Wrapper Mode: Directly wrap any CLI utility (like
wp-cli,git, or custom scripts) into a restricted MCP server without writing external scripts. -
Dual Transport Support: Run over SSE (HTTP/HTTPS) for remote access or Stdio for local use by MCP clients.
-
100% Test Coverage: Exhaustive test suite ensuring stability across all transports, operational modes, and failure paths.
-
YAML Configuration: Easily manage settings via a central config file.
-
Dynamic Configuration Reload: Opt-in feature to live-reload settings from
config.yamlwithout dropping active sessions. -
Idle Session Timeouts: Automatically terminates stalled proxy and wrapper sessions to prevent resource leaks.
-
Process Management: Automatically spawns, manages, and cleans up subprocesses for bridging.
-
Security:
- API key authentication (Header or Query Param).
- Restricted argument prefixing and regex filtering for wrapped commands.
- Built-in Directory Traversal Protection for local tool execution.
- Environment Scrubbing: Allowlist/Denylist variables passed to subprocesses.
- Secret Masking: Sensitive keys are automatically hidden from logs.
- Connection limiting and message size throttling.
- SSL/TLS with client certificate and CRL support.
- HSTS and secure security headers.
Installation
Install the package using pip:
pip install mcp-stdio-bridge
Documentation
For detailed information on configuring and deploying the bridge, see:
- docs/configuration.md: Full settings reference and JSON Schema.
- docs/deployment.md: Docker and local execution guides.
- docs/mcp-servers.md: Integration requirements for MCP servers.
- docs/roadmap.md: Future considerations and planned features.
Architecture & Design
To understand the internal logic and security model, refer to:
- docs/architecture.md: Modular structure and transport/mode design.
- docs/security.md: Detailed security features and sandboxing.
- docs/workflows.md: Sequential operational flows.
Examples
Check the examples/ directory for templates covering common use cases:
wp-cli-wrapper.yaml: Manage WordPress via MCP (Mix of Allowlist/Denylist).git-wrapper.yaml: Expose Git operations to local clients (Allowlist-only).sqlite-proxy.yaml: Bridge an existing SQLite MCP server to SSE.security-patterns.yaml: Advanced regex-based security filtering.docker-tool-wrapper.yaml: Using custom environment variables per tool.
Example config.yaml:
host: "127.0.0.1"
port: 8000
command: "python your_mcp_server.py"
verbose: true
api_key: "your-secret-key"
max_connections: 5
cors_origins: ["*"]
# ssl_keyfile: "path/to/key.pem"
# ssl_certfile: "path/to/cert.pem"
Running the Bridge
mcp-stdio-bridge
Docker
You can run the bridge using Docker:
# Build the image
docker build -t mcp-stdio-bridge .
# Run with a mounted config file
docker run -p 8000:8000 -v $(pwd)/config.yaml:/app/config.yaml mcp-stdio-bridge
Alternatively, use Docker Compose:
docker-compose up -d
Customization Arguments
| Argument | Description | Default |
|---|---|---|
--host |
Host to bind the server to | 0.0.0.0 |
--port |
Port to bind the server to | 8000 |
--command |
The command to run for each session (Proxy Mode) | None |
--mode |
Operation mode (proxy or command-wrapper) |
proxy |
--transport |
Transport protocol (sse or stdio) |
sse |
--api-key |
Optional API key for authentication | None |
--max-connections |
Max concurrent subprocesses | 10 |
--max-message-size |
Max message size in bytes | 1048576 |
--ssl-keyfile |
Path to SSL key file | None |
--ssl-certfile |
Path to SSL cert file | None |
--ssl-keyfile-password |
Password for SSL key file | None |
--ssl-ca-certs |
Path to SSL CA certificates file | None |
--ssl-crlfile |
Path to SSL CRL file | None |
--ssl-client-cert-required |
Require client certificates | False |
--ssl-protocol |
SSL protocol (TLSv1_2, TLSv1_3) |
TLSv1_2 |
--ssl-ciphers |
SSL ciphers | None |
--hsts |
Enable HSTS | False |
--no-security-headers |
Disable default security headers | False |
--cors-origins |
CORS origins (space-separated) | ["*"] |
--idle-timeout |
Idle timeout for proxy sessions (seconds) | 3600 |
--env-allowlist |
Allowlist of environment variables | None |
--env-denylist |
Denylist of environment variables | [...] |
--log-level |
Set the logging level (DEBUG, INFO, etc.) | INFO |
--logging-config |
Path to a custom logging config file | None |
--watch-config |
Enable dynamic config reloading | False |
-v, --verbose |
Enable verbose logging | False |
Development
Install all dependencies (including test and dev extras):
pip install -e ".[dev,test]"
Run the full test suite (the --timeout=10 flag is required — SSE transport tests can hang without it):
pytest --timeout=10
Lint, type-check, and security scan:
ruff check src tests
mypy src
bandit -r src -c pyproject.toml
License
This is free and unencumbered software released into the public domain. For more information, please refer to the LICENSE file or http://unlicense.org/.
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_bridge-1.0.1.post1.tar.gz.
File metadata
- Download URL: mcp_stdio_bridge-1.0.1.post1.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c08ec3259426bdcce86aa9fb5f83de00bffb29ecd8e2d6d07a16d9831fee44e9
|
|
| MD5 |
ad0082539a050cfbd4e6f6156fecd2bc
|
|
| BLAKE2b-256 |
8513b0edf659b8dfa027ed1439f3f780269aeac904028786ee700b5c87056e81
|
Provenance
The following attestation bundles were made for mcp_stdio_bridge-1.0.1.post1.tar.gz:
Publisher:
publish.yml on hackagadget/mcp-stdio-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_stdio_bridge-1.0.1.post1.tar.gz -
Subject digest:
c08ec3259426bdcce86aa9fb5f83de00bffb29ecd8e2d6d07a16d9831fee44e9 - Sigstore transparency entry: 1341824848
- Sigstore integration time:
-
Permalink:
hackagadget/mcp-stdio-bridge@c151a59fbae67cb6cc2b3d2598e1ada3e7ece937 -
Branch / Tag:
refs/tags/v1.0.1.post1 - Owner: https://github.com/hackagadget
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c151a59fbae67cb6cc2b3d2598e1ada3e7ece937 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mcp_stdio_bridge-1.0.1.post1-py3-none-any.whl.
File metadata
- Download URL: mcp_stdio_bridge-1.0.1.post1-py3-none-any.whl
- Upload date:
- Size: 13.6 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 |
1dd7e377dfed1498f924ec7503acaeb658771337b1eeccf7628ba766a34abe53
|
|
| MD5 |
f2283e12bd5c3a0a92ae9256d8139004
|
|
| BLAKE2b-256 |
dc44fe743d7b0ae3ee7f36ae0967ee0311f47a77da3138647cba0ba591414806
|
Provenance
The following attestation bundles were made for mcp_stdio_bridge-1.0.1.post1-py3-none-any.whl:
Publisher:
publish.yml on hackagadget/mcp-stdio-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mcp_stdio_bridge-1.0.1.post1-py3-none-any.whl -
Subject digest:
1dd7e377dfed1498f924ec7503acaeb658771337b1eeccf7628ba766a34abe53 - Sigstore transparency entry: 1341824857
- Sigstore integration time:
-
Permalink:
hackagadget/mcp-stdio-bridge@c151a59fbae67cb6cc2b3d2598e1ada3e7ece937 -
Branch / Tag:
refs/tags/v1.0.1.post1 - Owner: https://github.com/hackagadget
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c151a59fbae67cb6cc2b3d2598e1ada3e7ece937 -
Trigger Event:
push
-
Statement type: