MCP Transports
Transports are the communication channels that connect MCP clients and servers. Choose the right transport based on your deployment scenario and requirements.
Available Transports
OmniMCP supports three primary transport mechanisms:
1. Standard I/O (stdio)
The stdio transport uses standard input/output streams for communication. This is ideal for local processes and command-line tools.
When to Use
- Local MCP servers running as child processes
- Command-line tools and utilities
- Development and testing
- Isolated, secure environments
Configuration
const config: StdioTransportConfig = { type: 'stdio', options: { command: 'mcp-server', args: ['--verbose', '--port', '3000'], env: { API_KEY: process.env.API_KEY } } }
Pros & Cons
Pros
- Simple and secure
- No network configuration
- Process isolation
- Direct process control
Cons
- Local only
- Single client per server
- Platform-specific concerns
- Limited scalability
2. HTTP Transport
The HTTP transport uses standard HTTP requests for communication. Perfect for web services and cloud deployments.
When to Use
- Remote MCP servers
- Cloud-based deployments
- Multi-client scenarios
- RESTful API integration
Configuration
const config: HTTPTransportConfig = { type: 'http', options: { url: 'https://api.example.com/mcp', headers: { 'Authorization': 'Bearer ' + token, 'X-API-Version': '2024-11-05' } } }
Pros & Cons
Pros
- Remote access
- Standard HTTP infrastructure
- Load balancing support
- Easy authentication
Cons
- Higher latency
- Request/response only
- No server-initiated messages
- Polling required for updates
3. Server-Sent Events (SSE)
SSE transport provides real-time, server-to-client streaming over HTTP. Ideal for applications needing live updates.
When to Use
- Real-time notifications
- Progress updates
- Live data streaming
- Long-running operations
Configuration
const config: SSETransportConfig = { type: 'sse', options: { url: 'https://api.example.com/mcp/sse', headers: { 'Authorization': 'Bearer ' + token } } }
Pros & Cons
Pros
- Real-time updates
- Automatic reconnection
- Works through proxies
- Simple implementation
Cons
- Unidirectional (server to client)
- Text-only data
- Connection limits
- Not all browsers support
Transport Selection Guide
Decision Matrix
Requirement | stdio | HTTP | SSE |
---|---|---|---|
Local execution | ✅ | ❌ | ❌ |
Remote access | ❌ | ✅ | ✅ |
Real-time updates | ✅ | ❌ | ✅ |
Multiple clients | ❌ | ✅ | ✅ |
Bidirectional | ✅ | ✅ | ⚠️ |
Custom Transports
OmniMCP`s architecture allows for custom transport implementations. To create a custom transport, implement the Transport interface:
interface Transport { connect(): Promise<void>; disconnect(): Promise<void>; send(message: any): Promise<void>; onMessage(handler: (message: any) => void): void; onError(handler: (error: Error) => void): void; onClose(handler: () => void): void; }
Best Practices
- Use stdio for local tools and development
- Use HTTP for stateless, request-response operations
- Use SSE when you need server-initiated updates
- Implement retries for network-based transports
- Handle disconnections gracefully
- Secure your transports with proper authentication
Next Steps
- Learn about error handling
- See transport API reference
- Try basic connection examples