Skip to main content

neva/
lib.rs

1//! # Neva
2//! Easy configurable MCP server and client SDK for Rust
3//! 
4//! ## Dependencies
5//! ```toml
6//! [dependencies]
7//! neva = { version = "0.2.1", features = ["full"] }
8//! tokio = { version = "1", features = ["full"] }
9//! ```
10//! 
11//! ## Example Server
12//! ```no_run
13//! # #[cfg(feature = "server")] {
14//! use neva::App;
15//! 
16//! #[tokio::main]
17//! async fn main() {
18//!     let mut app = App::new()
19//!         .with_options(|opt| opt
20//!             .with_stdio());
21//! 
22//!     app.map_tool("hello", |name: String| async move { 
23//!         format!("Hello, {name}!")
24//!     });
25//! 
26//!     app.run().await;
27//! } 
28//! # }
29//! ```
30//! # Example Client
31//! ```no_run
32//! # #[cfg(feature = "client")] {
33//! use std::time::Duration;
34//! use neva::{Client, error::Error};
35//! 
36//! #[tokio::main]
37//! async fn main() -> Result<(), Error> {
38//!     let mut client = Client::new()
39//!         .with_options(|opt| opt
40//!             .with_stdio("npx", ["-y", "@modelcontextprotocol/server-everything"]));
41//! 
42//!     client.connect().await?;
43//! 
44//!     // Call a tool
45//!     let args = [("message", "Hello MCP!")];
46//!     let result = client.call_tool("echo", Some(args)).await?;
47//!     println!("{:?}", result.content);
48//! 
49//!     client.disconnect().await
50//! }
51//! # }
52//! ```
53
54#[cfg(feature = "server")]
55pub use app::{App, context::Context};
56#[cfg(feature = "client")]
57pub use client::Client;
58
59pub mod types;
60#[cfg(any(feature = "server", feature = "client"))]
61pub mod transport;
62pub mod error;
63pub mod shared;
64#[cfg(feature = "server")]
65pub mod app;
66#[cfg(feature = "client")]
67pub mod client;
68#[cfg(feature = "macros")]
69pub mod macros;
70pub mod commands;
71#[cfg(feature = "server")]
72pub mod middleware;
73#[cfg(feature = "di")]
74pub mod di;
75
76#[cfg(feature = "server-macros")]
77pub use neva_macros::{tool, prompt, resource, resources, handler, completion};
78#[cfg(feature = "client-macros")]
79pub use neva_macros::{sampling, elicitation};
80#[cfg(feature = "macros")]
81pub use neva_macros::json_schema;
82
83pub(crate) const SDK_NAME: &str = "neva";
84#[cfg(any(feature = "server", feature = "client"))]
85pub(crate) const PROTOCOL_VERSIONS: [&str; 4] = [
86    "2024-11-05", 
87    "2025-03-26",
88    "2025-06-18",
89    "2025-11-25"
90];
91
92#[cfg(feature = "http-server")]
93pub mod auth {
94    //! Authentication utilities
95    
96    pub use volga::auth::{Algorithm, Authorizer, Claims};
97    pub use crate::transport::http::server::{AuthConfig, DefaultClaims};
98}
99
100pub mod json {
101    //! JSON utilities
102    
103    pub use schemars::JsonSchema;
104    #[doc(hidden)]
105    pub use schemars;
106}
107
108pub mod prelude {
109    //! Prelude with commonly used items
110    
111    pub use crate::types::*;
112    pub use crate::error::*;
113    pub use crate::json::*;
114
115    #[cfg(feature = "http-server")]
116    pub use crate::transport::HttpServer;
117    #[cfg(all(feature = "http-server", feature = "server-tls"))]
118    pub use crate::transport::http::{TlsConfig, DevCertMode};
119    
120    #[cfg(feature = "server")]
121    pub use crate::app::{App, context::Context, options};
122    #[cfg(feature = "server")]
123    pub use crate::middleware::{MwContext, Next};
124    
125    #[cfg(feature = "client")]
126    pub use crate::client::Client;
127    
128    #[cfg(feature = "server-macros")]
129    pub use crate::{tool, prompt, resource, resources, handler, completion};
130    #[cfg(feature = "client-macros")]
131    pub use crate::{sampling, elicitation};
132    #[cfg(feature = "macros")]
133    pub use crate::json_schema;
134
135    #[cfg(feature = "http-server")]
136    pub use crate::auth::*;
137    
138    #[cfg(feature = "di")]
139    pub use crate::di::Dc;
140
141    #[cfg(feature = "tasks")]
142    pub use crate::shared::TaskApi;
143}