Expand description
Includes the runtimes and traits required to create a type-safe MCP client.
Choosing Between client_runtime
and client_runtime_core
?
rust-mcp-sdk provides two type of runtimes that you can chose from:
- client_runtime : This is recommended runtime to be used for most MCP projects, and
it works with
mcp_server_handler
trait that offers default implementation for common messages like handling initialization or responding to ping requests, so you only need to override and customize the handler functions relevant to your specific needs.
Refer to examples/simple-mcp-client for an example.
- client_runtime_core: If you need more control over MCP messages, consider using
client_runtime_core
that goes with works withmcp_server_handler_core
trait which offers methods to manage the three MCP message types: request, notification, and error. While still providing type-safe objects in these methods, it allows you to determine how to handle each message based on its type and parameters.
Refer to examples/simple-mcp-client-core for an example.
Modules§
Structs§
Traits§
- Client
Handler - Defines the
ClientHandler
trait for handling Model Context Protocol (MCP) operations on a client. This trait provides default implementations for request and notification handlers in an MCP client, allowing developers to override methods for custom behavior. - Client
Handler Core - Defines the
ClientHandlerCore
trait for handling Model Context Protocol (MCP) client operations. UnlikeClientHandler
, this trait offers no default implementations, providing full control over MCP message handling while ensures type-safe processing of the messages through three distinct handlers for requests, notifications, and errors.
Functions§
- ensure_
server_ protocole_ compatibility - Checks if the client and server protocol versions are compatible by ensuring they are equal.