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}
40
41#[cfg(feature = "server")]
42pub mod mcp_server {
43 //! Includes the runtimes and traits required to create a type-safe MCP server.
44 //!
45 //!
46 //! **Choosing Between `server_runtime` and `server_runtime_core` ?**
47 //!
48 //! [rust-mcp-sdk](https://github.com/rust-mcp-stack/rust-mcp-sdk) provides two type of runtimes that you can chose from:
49 //! - **server_runtime** : This is recommended runtime to be used for most MCP projects, and
50 //! it works with `mcp_server_handler` trait
51 //! that offers default implementation for common messages like handling initialization or
52 //! responding to ping requests, so you only need to override and customize the handler
53 //! functions relevant to your specific needs.
54 //!
55 //! 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.
56 //!
57 //!
58 //! - **server_runtime_core**: If you need more control over MCP messages, consider using
59 //! `server_runtime_core` that goes with works with `mcp_server_handler_core` trait which offers
60 //! methods to manage the three MCP message types: request, notification, and error.
61 //! While still providing type-safe objects in these methods, it allows you to determine how to
62 //! handle each message based on its type and parameters.
63 //!
64 //! 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.
65 pub use super::mcp_handlers::mcp_server_handler::ServerHandler;
66 pub use super::mcp_handlers::mcp_server_handler_core::ServerHandlerCore;
67
68 pub use super::mcp_runtimes::server_runtime::mcp_server_runtime as server_runtime;
69 pub use super::mcp_runtimes::server_runtime::mcp_server_runtime_core as server_runtime_core;
70 pub use super::mcp_runtimes::server_runtime::ServerRuntime;
71
72 #[cfg(feature = "hyper-server")]
73 pub use super::hyper_servers::hyper_server;
74 #[cfg(feature = "hyper-server")]
75 pub use super::hyper_servers::hyper_server_core;
76 #[cfg(feature = "hyper-server")]
77 pub use super::hyper_servers::*;
78}
79
80#[cfg(feature = "client")]
81pub use mcp_traits::mcp_client::*;
82
83#[cfg(feature = "server")]
84pub use mcp_traits::mcp_server::*;
85
86pub use rust_mcp_transport::error::*;
87pub use rust_mcp_transport::*;
88
89#[cfg(feature = "macros")]
90pub mod macros {
91 pub use rust_mcp_macros::*;
92}