Skip to content

client

MCP client implementation for connecting to MCP servers over either Streamable HTTP or the older direct SSE feature path.

MCP Client - Connect to MCP servers

Methods

fn new() -> Self

Create new MCP client

fn with_auth_handler<H>(self, handler: H) -> Self

Configure authentication

fn with_streamable_http_server(self, endpoint: &str) -> Self

Connect to MCP server via Streamable HTTP.

fn with_streamable_http_server_auth(self, endpoint: &str, auth_token: &str) -> Self

Connect to MCP server via Streamable HTTP with bearer authentication.

fn with_streamable_http_headers(self, headers: HashMap<String, String>) -> Self

Add extra HTTP headers to the Streamable HTTP transport.

fn with_streamable_http_client_info(self, client_info: ClientInfo) -> Self

Override the Streamable HTTP client identity used during initialize.

async fn list_tools_async(&self) -> Result<Vec<Tool>, ProtocolError>

List tools from server.

async fn call_tool_async(&self, name: &str, arguments: Option<serde_json::Value>) -> Result<CallToolResult, ProtocolError>

Call tool on server.

async fn call_tool_with_meta_async(&self, name: &str, arguments: Option<serde_json::Value>, meta: Option<serde_json::Value>) -> Result<CallToolResult, ProtocolError>
async fn initialize_async(&self) -> Result<(), ProtocolError>

Initialize the current Streamable HTTP transport explicitly.

async fn health_check(&self) -> Result<(), ProtocolError>

Check server health.

MCP Client Builder - Convenient client configuration

Methods

fn new() -> Self

Create new client builder

fn with_auth_handler<H>(self, handler: H) -> Self

Set authentication handler

fn with_streamable_http_server(self, endpoint: &str) -> Self

Configure Streamable HTTP transport.

fn with_streamable_http_auth_token(self, token: &str) -> Self

Set bearer token for Streamable HTTP transport.

fn build(self) -> McpClient

Build the MCP client