rust_mcp_sdk/
lib.rs

1pub mod error;
2#[cfg(feature = "hyper-server")]
3mod hyper_servers;
4mod mcp_handlers;
5mod mcp_macros;
6mod mcp_runtimes;
7mod mcp_traits;
8mod utils;
9
10#[cfg(feature = "client")]
11pub mod mcp_client {
12    //! Includes the runtimes and traits required to create a type-safe MCP client.
13    //!
14    //!
15    //! **Choosing Between `client_runtime` and `client_runtime_core` ?**
16    //!
17    //! [rust-mcp-sdk](https://github.com/rust-mcp-stack/rust-mcp-sdk) provides two type of runtimes that you can chose from:
18    //! - **client_runtime** : This is recommended runtime to be used for most MCP projects, and
19    //!   it works with `mcp_server_handler` trait
20    //!   that offers default implementation for common messages like  handling initialization or
21    //!   responding to ping requests, so you only need to override and customize the handler
22    //!   functions relevant to your specific needs.
23    //!
24    //! Refer to [examples/simple-mcp-client](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client) for an example.
25    //!
26    //!
27    //! - **client_runtime_core**: If you need more control over MCP messages, consider using
28    //!   `client_runtime_core` that goes with works with `mcp_server_handler_core` trait which offers
29    //!   methods to manage the three MCP message types: request, notification, and error.
30    //!   While still providing type-safe objects in these methods, it allows you to determine how to
31    //!   handle each message based on its type and parameters.
32    //!
33    //! Refer to [examples/simple-mcp-client-core](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/simple-mcp-client-core) for an example.
34    pub use super::mcp_handlers::mcp_client_handler::ClientHandler;
35    pub use super::mcp_handlers::mcp_client_handler_core::ClientHandlerCore;
36    pub use super::mcp_runtimes::client_runtime::mcp_client_runtime as client_runtime;
37    pub use super::mcp_runtimes::client_runtime::mcp_client_runtime_core as client_runtime_core;
38    pub use super::mcp_runtimes::client_runtime::ClientRuntime;
39    pub use super::utils::ensure_server_protocole_compatibility;
40}
41
42#[cfg(feature = "server")]
43pub mod mcp_server {
44    //! Includes the runtimes and traits required to create a type-safe MCP server.
45    //!
46    //!
47    //! **Choosing Between `server_runtime` and `server_runtime_core` ?**
48    //!
49    //! [rust-mcp-sdk](https://github.com/rust-mcp-stack/rust-mcp-sdk) provides two type of runtimes that you can chose from:
50    //! - **server_runtime** : This is recommended runtime to be used for most MCP projects, and
51    //!   it works with `mcp_server_handler` trait
52    //!   that offers default implementation for common messages like  handling initialization or
53    //!   responding to ping requests, so you only need to override and customize the handler
54    //!   functions relevant to your specific needs.
55    //!
56    //! Refer to [examples/hello-world-mcp-server](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server) for an example.
57    //!
58    //!
59    //! - **server_runtime_core**: If you need more control over MCP messages, consider using
60    //!   `server_runtime_core` that goes with works with `mcp_server_handler_core` trait which offers
61    //!   methods to manage the three MCP message types: request, notification, and error.
62    //!   While still providing type-safe objects in these methods, it allows you to determine how to
63    //!   handle each message based on its type and parameters.
64    //!
65    //! Refer to [examples/hello-world-mcp-server-core](https://github.com/rust-mcp-stack/rust-mcp-sdk/tree/main/examples/hello-world-mcp-server-core) for an example.
66    pub use super::mcp_handlers::mcp_server_handler::ServerHandler;
67    pub use super::mcp_handlers::mcp_server_handler_core::ServerHandlerCore;
68
69    pub use super::mcp_runtimes::server_runtime::mcp_server_runtime as server_runtime;
70    pub use super::mcp_runtimes::server_runtime::mcp_server_runtime_core as server_runtime_core;
71    pub use super::mcp_runtimes::server_runtime::ServerRuntime;
72
73    #[cfg(feature = "hyper-server")]
74    pub use super::hyper_servers::hyper_server;
75    #[cfg(feature = "hyper-server")]
76    pub use super::hyper_servers::hyper_server_core;
77    #[cfg(feature = "hyper-server")]
78    pub use super::hyper_servers::*;
79    pub use super::utils::enforce_compatible_protocol_version;
80}
81
82#[cfg(feature = "client")]
83pub use mcp_traits::mcp_client::*;
84
85#[cfg(feature = "server")]
86pub use mcp_traits::mcp_server::*;
87
88pub use rust_mcp_transport::error::*;
89pub use rust_mcp_transport::*;
90
91#[cfg(feature = "macros")]
92pub mod macros {
93    pub use rust_mcp_macros::*;
94}
95
96pub mod schema {
97    pub use rust_mcp_schema::*;
98}