Expand description
Model Context Protocol clients (feature mcp), built on [rmcp].
An McpClient reaches one server over stdio (McpTransport::stdio), streamable HTTP
(McpClientConfig::url) or the legacy HTTP+SSE protocol (McpTransport::sse). Pass it
to an agent with .tools([client]): the agent lists the server’s tools as McpTools when
it initializes and follows the server’s list-changed notifications.
McpClient::load_servers builds clients from an mcp.json-style config.
The raw MCP results (McpClient::list_prompts, McpClient::read_resource, …) are the
rmcp model types; use them through the re-export strands::mcp::rmcp so the
versions match. They are part of this crate’s public API: an rmcp major version bump is a
breaking release of strands.
Re-exports§
pub use rmcp;
Structs§
- Elicitation
Context - What an
ElicitationCallbackreceives besides the request (ElicitationContext). - McpCall
Tool Options - Options for one tool call (
McpCallToolOptions). - McpClient
- A client for one MCP server (
McpClient). - McpClient
Config - How to reach the server, plus the client’s behaviour (
McpClientConfig). - McpClient
Credentials - OAuth client credentials for machine-to-machine authentication (
McpClientCredentials). - McpClient
Options - Behaviour shared by every MCP client configuration (
McpClientOptions). - McpList
Options - Options for the paginated list methods (
McpListOptions). - McpList
Tools Options - Per-call overrides for
McpClient::list_tools_with(McpListToolsOptions). - McpLoad
Servers Options - How
McpClient::load_serversturns entries into clients (McpLoadServersOptions). - McpLog
Handler - Receives the log messages an MCP server emits.
- McpLog
Message - A log message an MCP server emits (
LoggingMessageNotificationParams). - McpProgress
- A progress update an MCP server reports during a tool call (
McpProgress). - McpProgress
Callback - Receives progress notifications during a tool call (
McpProgressCallback). A failure is logged as a warning. - McpServer
Config - One server entry of a config file or map (
McpServerConfig). - McpTool
- A tool that proxies calls to an MCP server (
McpTool). - McpTool
Config - What an
McpToolis built from (McpToolConfig). - McpTool
Filter Callback - Decides whether a tool matches a filter (
McpToolFilterCallback). It receives the tool under its agent-facing name. - McpTool
Filters - Filters controlling which MCP tools a client exposes (
McpToolFilters). - McpTransport
- How an
McpClientreaches its server (McpTransport). - Serializable
McpTool Filters - Tool filters in a config file (
SerializableMcpToolFilters): each pattern is a regex matched from the start of the server-side tool name. - Stdio
Server Parameters - How to spawn a stdio MCP server (
StdioServerParameters). - Tools
Changed Callback - Called when the server’s tool list changes, with the previously registered tool names and the refreshed tools.
Enums§
- McpConnection
State - Connection state of an MCP client (
McpConnectionState). - McpError
- A failure of an MCP client operation.
- McpLog
Level - The severity of an MCP server log message (
LoggingLevel). - McpSdk
Error Code - Why an MCP SDK operation failed.
- McpServer
Transport - The transport of a config entry (
'stdio' | 'sse' | 'streamable-http'). - McpServers
Source - Where
McpClient::load_serversreads servers from: a JSON file (flat or undermcpServers,~/expanded), a typed map, or a JSON object of entries. - McpTool
Matcher - Matches a tool for filtering (
McpToolMatcher).
Constants§
- DEFAULT_
CLIENT_ NAME - The client name sent in the MCP handshake unless
application_nameoverrides it. - URL_
ELICITATION_ REQUIRED - The JSON-RPC code a server uses when a request needs URL elicitation first
(
ProtocolErrorCode.UrlElicitationRequired).
Traits§
- Elicitation
Callback - Handles a server’s request for user input during a tool call (
ElicitationCallback). - McpAuth
Provider - Supplies the bearer token for each request of a URL-configured client (
authProvider).
Functions§
- default_
environment - The variables a stdio server inherits: only those deemed safe, and
none whose value starts with
()(an exported shell function).