Skip to content

Implemented Transport-Translation Bridge (mcpgateway.translate) #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

manavgup
Copy link
Collaborator

@manavgup manavgup commented Jun 18, 2025

📝 Pull Request Template Selection

Thank you for contributing! To help us review your pull request effectively, please select the appropriate template:

Key Components Implemented:

1. Core Bridge Implementation

  • mcpgateway/translate/init.py: Complete CLI interface with argparse, validation, and configuration management
  • mcpgateway/translate/bridge.py: Core bridge logic with pluggable transport endpoints and bidirectional message pumping
  • Support for stdio, SSE, WebSocket, and Streamable-HTTP transports
  • Reuses existing SSETransport and WebSocketTransport classes

2. CLI Features

  • Console script entry point: mcpgateway-translate
  • Mutually exclusive input transports (--stdio, --sse, --streamableHttp)
  • Auto-detection of output transport based on input
  • Comprehensive flag validation and error handling
  • Support for headers, OAuth2 Bearer tokens, CORS, and health endpoints

3. Docker Support

  • docker/translate.Dockerfile: Multistage build based on python:3.12-slim
  • Multiple variants: base, uvx (Node.js support), deno
  • Updated CI/CD pipeline to build and push all variants with proper tagging
  • Lightweight images with security best practices

4. Testing & Quality

  • tests/unit/mcpgateway/translate/test_cli.py: Comprehensive CLI tests
  • tests/unit/mcpgateway/translate/test_bridge.py: Core bridge functionality tests
  • Unit tests cover argument parsing, validation, transport endpoints, and message routing
  • High test coverage with mocking for external dependencies

5. Documentation

  • docs/translate.md: Complete user guide with quick start, command reference, use cases
  • Covers Docker usage, environment variables, API endpoints, security considerations
  • Includes troubleshooting guide and performance tuning recommendations

User Stories Fulfilled:

User Story 1: mcpgateway-translate --stdio "uvx mcp-server-git" --port 9000 exposes stdio server over SSE
User Story 2: mcpgateway-translate --sse "https://corp.example.com/mcp" bridges remote SSE to local stdio
User Story 3: Health endpoint and CORS support with --healthEndpoint /healthz --cors "https://app.example.com"
User Story 4: Official Docker images with variants published to GHCR

Production-Ready Features:

  • Token redaction and security features
  • CORS support with origin validation
  • Health check endpoints for load balancer integration
  • Comprehensive error handling and logging
  • Environment variable configuration
  • Bidirectional message pumping with JSON-RPC integrity
  • Connection pooling and performance optimizations

The implementation is ready for production use and provides a first-class, batteries-included bridge for running any MCP stdio-based server or remote endpoint over every other official transport protocol.

try:
self.process = subprocess.Popen(
self.command,
shell=True,

Check failure

Code scanning / Bandit

subprocess call with shell=True identified, security issue. Error

subprocess call with shell=True identified, security issue.
@manavgup
Copy link
Collaborator Author

@madhav165 - any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants