Skip to main content
MCP servers communicate with clients using different transport protocols. The mcp-use client supports multiple connection types, each optimized for different use cases and deployment scenarios.

Overview

The client supports three primary connection types:
  • STDIO: Local process communication via standard input/output
  • HTTP/SSE: Remote servers via HTTP with Server-Sent Events
  • WebSocket: Bidirectional streaming communication
The connection type is automatically detected based on your server configuration. You don’t need to specify it explicitly - just provide the appropriate parameters (command for STDIO, url for HTTP/WebSocket).

STDIO (Standard Input/Output)

STDIO connections launch and manage MCP servers as local child processes, communicating through standard input and output streams.

When to Use STDIO

  • Local development: Testing servers on your local machine
  • Security-sensitive operations: No network exposure required
  • File system access: Direct access to local files and resources
  • Simple deployment: No need for network configuration

Characteristics

  • Servers run as child processes
  • Communication via stdin/stdout
  • Automatic process lifecycle management
  • Zero network latency
  • No external dependencies

Configuration Example:

{
  "mcpServers": {
    "stdio_server": {
      "command": "npx",
      "args": ["@my-mcp/server"],
      "env": {}
    }
  }
}

HTTP/SSE (Server-Sent Events)

HTTP connections communicate with MCP servers over standard HTTP/HTTPS protocols, using Server-Sent Events for real-time updates.

When to Use HTTP

  • Remote servers: Connecting to servers hosted elsewhere
  • Production deployment: Servers behind load balancers or API gateways
  • Authentication: Servers requiring OAuth or API key authentication
  • Scalability: Multiple clients connecting to the same server

Characteristics

  • Servers accessible via HTTP(S) endpoints
  • Support for custom headers (authentication, etc.)
  • Compatible with standard web infrastructure
  • Server-Sent Events for notifications

Configuration Example:

{
  "mcpServers": {
    "http_server": {
      "url": "http://localhost:3000",
      "headers": {
        "Authorization": "Bearer ${AUTH_TOKEN}"
      }
    }
  }
}

Connection Type Selection

The client automatically detects the appropriate connection type based on your configuration:
ConfigurationConnection TypeUse Case
command + argsSTDIOLocal process servers
url: http://...HTTP/SSERemote HTTP servers
url: ws://...WebSocketWebSocket servers
Automatic Detection: You never need to specify the connection type explicitly. The client analyzes your configuration and selects the appropriate transport protocol automatically.

Best Practices

For Development

Use STDIO connections for local development:
  • Faster iteration with direct process control
  • No network configuration needed
  • Easy debugging with process logs

For Production

Use HTTP connections for production deployments:
  • Better scalability and load distribution
  • Support for authentication and authorization
  • Compatible with existing infrastructure
  • Easier monitoring and logging

Security Considerations

  • STDIO: Most secure, no network exposure
  • HTTP: Use HTTPS in production, implement authentication
  • WebSocket: Use WSS (WebSocket Secure) for encrypted connections

Next Steps