Skip to main content

Remote MCP Server Connections

Remote connections allow you to connect to Model Context Protocol (MCP) servers hosted on remote machines, cloud infrastructure, or different networks. This enables distributed architectures where MCP servers can be deployed separately from client applications.

Understanding Remote MCP Architecture

Remote MCP servers enable scalable, distributed AI systems by allowing:
  • Centralized server deployment - Host specialized MCP servers on dedicated infrastructure
  • Cross-network access - Connect to servers across different networks and cloud providers
  • Load distribution - Distribute processing across multiple server instances
  • Shared resources - Multiple clients can access the same MCP server capabilities
For comprehensive information about the MCP specification and architecture, visit the official MCP documentation.

Transport Protocols

Pylee supports two transport protocols for remote MCP server connections: The Streamable HTTP transport uses modern HTTP streaming capabilities for efficient communication with remote MCP servers. This is the recommended protocol for most use cases. Transport Type: streamable URL Format:
Key Features:
  • Efficient HTTP streaming for real-time communication
  • Built-in error handling and retry mechanisms
  • Support for bidirectional communication
  • Compatible with standard HTTP infrastructure
  • Automatic connection management
Advantages:
  • Modern streaming capabilities
  • Lower latency than traditional request-response
  • Firewall and proxy friendly
  • Built-in HTTPS security support
  • Excellent performance for high-frequency operations
Best for:
  • Production deployments
  • Real-time applications
  • High-performance scenarios
  • Modern cloud infrastructure
  • Client applications with intermittent connectivity needs

WebSocket Protocol

Provides persistent, bidirectional communication channels for real-time interaction. URL Format:
Advantages:
  • Real-time bidirectional communication
  • Lower latency for frequent operations
  • Persistent connection reduces overhead
  • Native browser support
Disadvantages:
  • More complex connection management
  • May require special network configuration
  • Connection state management complexity
Best for:
  • Interactive applications requiring immediate responses
  • High-frequency tool invocation scenarios
  • Real-time collaborative environments
  • Applications needing bidirectional data flow

Server-Sent Events (SSE)

Uses Server-Sent Events for server-to-client streaming communication. URL Format:
Advantages:
  • Real-time server-to-client updates
  • Automatic reconnection handling
  • HTTP-based (firewall friendly)
  • Built-in browser support
Disadvantages:
  • Unidirectional (server to client only)
  • Limited browser connection limits
  • May require additional endpoint for client-to-server requests
Best for:
  • Live monitoring and status updates
  • Progress tracking for long-running operations
  • Event-driven architectures
  • Applications requiring server push notifications

Configuring Remote Connections in Pylee

Using the Pylee Configuration Interface

Navigate to your server’s configuration page and select Remote Configuration to set up remote MCP connections:
  1. Go to Configuration
  2. Add Remote Connection
    • Click “Add Remote” to create a new remote connection
    • Configure the transport type and endpoint URL
    • Set up authentication headers if required

Remote Configuration Options

Basic Configuration

Transport Type: Choose between streamable (recommended) or sse (deprecated) URL: The endpoint URL for your remote MCP server

Authentication Headers

Configure HTTP headers for authentication and custom requirements: Common Authentication Patterns:

Header Configuration Fields

  • Name: The HTTP header name (e.g., “Authorization”, “X-API-Key”)
  • Value: The header value (tokens, keys, etc.)
  • Description: Optional description of the header’s purpose
  • Required: Mark if this header is mandatory for the connection
  • Secret: Mark if this header contains sensitive information

Variables in Remote Configuration

Remote configuration supports dynamic variables using bracket notation ({variable_name}) to avoid hardcoding sensitive information. Variables are resolved at runtime through a hierarchical lookup system. Variable Resolution Order:
  1. Organization variables or secrets - Global settings for your organization
  2. Registry variables or secrets - Shared configuration across the registry
  3. User prompt - Interactive prompt when no value is found for required variables
Example with Variables:
For comprehensive information about variables configuration, see the Variables Configuration Guide.

Example Configurations

Production API with Authentication

Development Environment

Legacy Server Configuration

For reference, here’s how to configure an MCP server to accept remote connections:
Node.js Streamable Server

Client Configuration

Configure your client to connect to remote MCP servers:

Authentication and Security

Authentication Methods

Implement proper authentication for remote MCP servers:

Security Best Practices

Always implement these security measures for remote MCP servers:
  • Use HTTPS/WSS - Always encrypt connections in production
  • Implement authentication - Require valid credentials for all requests
  • Validate inputs - Sanitize and validate all tool parameters and resource requests
  • Rate limiting - Implement request rate limiting to prevent abuse
  • CORS configuration - Configure Cross-Origin Resource Sharing appropriately
  • Audit logging - Log all access attempts and operations
  • Regular updates - Keep MCP SDK and dependencies updated

Load Balancing and Scaling

Multiple Server Instances

Deploy multiple MCP server instances for high availability:

Docker Deployment

Deploy MCP servers using Docker for scalability:

Monitoring and Observability

Health Checks

Implement health monitoring for remote MCP servers:

Metrics Collection

Track server performance and usage:

Security Best Practices

Authentication

  • Always use HTTPS for production deployments
  • Implement proper API key or token-based authentication
  • Mark sensitive headers as “secret” in the configuration
  • Rotate authentication credentials regularly

Network Security

  • Use secure transport protocols (HTTPS)
  • Configure proper CORS policies on your MCP servers
  • Implement rate limiting and request throttling
  • Monitor and log connection attempts

Troubleshooting Remote Connections

Configuration Issues

Remote endpoint not accessible:
  • Verify the URL is correct and reachable
  • Check network connectivity and firewall rules
  • Ensure the remote server is running and accepting connections
Authentication failures:
  • Verify API keys or tokens are correct and not expired
  • Check that required headers are properly configured
  • Ensure sensitive headers are marked as “secret”
Transport protocol issues:
  • Use streamable transport for new implementations
  • Migrate from sse to streamable for better performance
  • Verify the remote server supports the selected transport type

Debugging Steps

  1. Test connectivity:
  2. Verify authentication:
  3. Check server logs for connection attempts and errors
  4. Monitor network traffic to identify connection issues

Common Issues

Connection Timeouts
  • Check network connectivity between client and server
  • Verify firewall rules allow traffic on required ports
  • Increase client timeout settings if operations are slow
  • Monitor server resource usage and performance
Authentication Failures
  • Verify API keys or tokens are valid and not expired
  • Check authentication headers are properly formatted
  • Ensure server authentication configuration matches client
  • Review server logs for specific authentication errors
Protocol Errors
  • Validate MCP message format compliance using MCP Inspector
  • Check JSON-RPC 2.0 format adherence
  • Verify required fields are present in all messages
  • Test with minimal client to isolate issues
Performance Issues
  • Monitor server resource usage (CPU, memory, network)
  • Check for database connection pooling bottlenecks
  • Implement caching for frequently accessed resources
  • Consider using connection pooling on the client side

Debugging Tools

Use these tools to debug remote MCP connections:

Protocol Selection Guide

Choose the right protocol based on your requirements:

Deployment Patterns

Cloud Deployment

Common patterns for deploying remote MCP servers:
  • Container orchestration - Use Kubernetes or Docker Swarm for scaling
  • Serverless functions - Deploy as AWS Lambda, Azure Functions, or Google Cloud Functions
  • API Gateway integration - Use cloud API gateways for routing and authentication
  • CDN deployment - Cache resources using content delivery networks
  • Multi-region deployment - Deploy servers across regions for global access

Edge Computing

Deploy MCP servers closer to users:

Next Steps

Once you have remote MCP server connections working:

Migration from SSE to Streamable

If you’re currently using SSE transport, consider migrating to Streamable HTTP:

Migration Steps

  1. Update transport type from sse to streamable in your remote configuration
  2. Verify endpoint compatibility with Streamable HTTP protocol
  3. Test the connection thoroughly in a development environment
  4. Update monitoring and logging to account for the new transport
  5. Deploy gradually using canary or blue-green deployment strategies

Benefits of Migration

  • Improved performance and reliability
  • Better error handling and recovery
  • Enhanced streaming capabilities
  • Future-proof protocol choice

Resources and Support

For additional help with remote MCP connections: