Transport Layer
HTTP transport implementation for Model Context Protocol
The Model Context Protocol (MCP) supports different transport mechanisms for communication between hosts and clients. Kambrium implements HTTP transport with comprehensive security features and multi-tenant support.
HTTP Transport
Kambrium’s HTTP transport implementation provides:
- POST endpoints for standard JSON-RPC messages
- GET endpoints for Server-Sent Events (SSE) streaming
- Multi-tenant routing with
/{tenant}/mcp
paths - Session management via
Mcp-Session-Id
headers - Security compliance with CORS, rate limiting, and input validation
Endpoint Structure
Where {tenant}
is the path prefix identifying the specific MCP server instance.
HTTP Methods
POST - Standard Requests
Used for most MCP communication:
GET - Server-Sent Events
Used for streaming and long-lived connections:
Headers
Required Headers
Header | Purpose | Example |
---|---|---|
Content-Type | JSON-RPC content | application/json |
Authorization | OAuth/PAT authentication | Bearer {token} |
Optional Headers
Header | Purpose | Example |
---|---|---|
Mcp-Session-Id | Session management | session-123 |
Accept | Response format | text/event-stream |
Authentication
All HTTP requests require authentication:
OAuth 2.1 Bearer Tokens
Personal Access Tokens (PAT)
Session Management
Sessions are managed via the Mcp-Session-Id
header:
- Initial Request: No session header required
- Server Response: Returns
Mcp-Session-Id
header - Subsequent Requests: Include the session ID
Rate Limiting
HTTP transport includes advanced rate limiting:
- Per-endpoint limits: Different limits for MCP POST, GET, and health endpoints
- Burst control: Allows quick succession up to burst size
- Client identification: OAuth-aware rate limiting
- MCP-compliant errors: Proper JSON-RPC error responses
Rate limit headers in responses:
CORS Support
The server includes comprehensive CORS support:
- Preflight handling: OPTIONS requests supported
- Origin validation: Configurable allowed origins
- Credential support:
Access-Control-Allow-Credentials
Server-Sent Events (SSE)
For real-time communication and streaming:
Error Handling
HTTP transport provides proper error responses:
Authentication Errors
Rate Limit Errors
Security Features
DNS Rebinding Protection
- Origin validation: Strict origin checking for browser requests
- Host header validation: Prevents DNS rebinding attacks
- Secure headers: Comprehensive security header configuration
Input Validation
- JSON schema validation: All requests validated against schemas
- Parameter sanitization: Input sanitization for security
- Size limits: Request size limits to prevent abuse
Connection Security
- TLS enforcement: HTTPS recommended for production
- Token validation: OAuth/PAT token verification
- Session isolation: Multi-tenant session separation
Usage Examples
Basic HTTP Client
Session Management
Batch Requests
Configuration
Environment Variables
Multi-Tenant Setup
Configure tenant routing in your database:
This creates a tenant accessible at /{path_prefix}/mcp
.
Best Practices
- Always use HTTPS in production environments
- Implement proper authentication with OAuth or PAT tokens
- Handle rate limits gracefully with exponential backoff
- Use session management for multi-request workflows
- Validate all inputs before sending requests
- Monitor connection health with ping utilities
For detailed implementation examples, see the MCP Methods documentation.