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