Skip to content

mcp.connect_http

mcp.connect_http(spec) -> McpClient

Connect to an MCP server over streamable HTTP. Raises on a connect failure or the handshake failing.

Parameters

  • spec: {url: string, headers: {[string]: string}?, max_retries: number?}
    • url — The server endpoint URL.
    • headers — Extra HTTP headers sent with every request (e.g. an Authorization header).
    • max_retries — How many times to retry a dropped event stream before giving up. Absent leaves rmcp's default of retrying indefinitely; set a bound so a server that stays down eventually surfaces a failure rather than reconnecting forever.

Returns