Expand description
Includes the runtimes and traits required to create a type-safe MCP server.
Choosing Between server_runtime
and server_runtime_core
?
rust-mcp-sdk provides two type of runtimes that you can chose from:
- server_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/hello-world-mcp-server for an example.
- server_runtime_core: If you need more control over MCP messages, consider using
server_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/hello-world-mcp-server-core for an example.
Modules§
Structs§
- Hyper
Server - Hyper server struct for managing the Axum-based web server
- Hyper
Server Options - Configuration struct for the Hyper server Used to configure the HyperServer instance.
- InMemory
Session Store - In-memory session store implementation
- Server
Runtime - Struct representing the runtime core of the MCP server, handling transport and client details
- Uuid
Generator - Struct implementing the IdGenerator trait using UUID v4
Traits§
- IdGenerator
- Trait for generating session identifiers
- Server
Handler - Defines the
ServerHandler
trait for handling Model Context Protocol (MCP) operations on a server. This trait provides default implementations for request and notification handlers in an MCP server, allowing developers to override methods for custom behavior. - Server
Handler Core - Defines the
ServerHandlerCore
trait for handling Model Context Protocol (MCP) server operations. UnlikeServerHandler
, 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. - Session
Store - Trait defining the interface for session storage operations
Functions§
- enforce_
compatible_ protocol_ version - Enforces protocol version compatibility on for MCP Server , allowing the client to use a lower or equal version.