Skip to main content
Learn how to run your mcp-use server using different transport methods and configurations.

Basic Usage

Transport Methods

stdio Transport

Standard input/output transport for MCP clients:

streamable-http Transport

HTTP-based transport for web clients:

Host and Port Configuration

You can configure host and port either at initialization or when calling run(). Values passed to run() override those set in __init__(), and DNS rebinding protection is automatically reconfigured to match:

Default Values

Automatic Port Retry

When the requested port is already in use (e.g., another server is running on port 8000), the server automatically tries the next available port instead of crashing:
The server tries up to 10 consecutive ports (8000, 8001, …, 8009). If none are available, it raises an error. This makes it easy to run multiple MCP servers simultaneously during development without manually specifying different ports.
The startup output always shows the actual port the server bound to, so you’ll know where to connect.

Cloud and Proxy Deployments

When deploying behind reverse proxies (Cloudflare, nginx, Fly.io, etc.), the server automatically configures DNS rebinding protection based on the host:
  • host="0.0.0.0" (default): DNS rebinding protection is disabled, allowing any Host header. This is safe when your proxy handles host validation.
  • host="127.0.0.1": DNS rebinding protection is enabled, only allowing requests with Host: 127.0.0.1:* or Host: localhost:*.
If you get 421 Misdirected Request errors behind a proxy, ensure you’re using host="0.0.0.0" (the default).

Debug Mode

Enable debug mode for development features:

Auto-reload

Enable auto-reload during development:

Production Configuration

Command Line

Run directly with Python:
Or use uvicorn directly: