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