Connect to a Remote MCP Server
For a deployed server, connect over HTTPS and pass authorization through supported headers or auth mechanisms.
from mcp.client import Client
async with Client("https://mcp.example.com/mcp") as client:
print(client.protocol_version)
tools = await client.list_tools()Authentication
Keep tokens in headers, not URLs. Scope credentials to the minimum tools and data the application needs.
Timeouts and retries
Remote calls fail. Configure bounded timeouts and retry only operations that are safe to repeat. Mutation calls may need idempotency keys.
TLS and hostname validation
Do not disable certificate verification to make development easier. Use proper local certificates or a development environment rather than normalizing insecure production settings.