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