#[cfg(all(feature = "server", not(feature = "legacy-spec")))]
pub use app::extension::Extension;
#[cfg(all(feature = "server", not(feature = "legacy-spec"), feature = "tasks"))]
pub use app::extension::TasksExtension;
#[cfg(all(feature = "server", not(feature = "legacy-spec")))]
pub use app::mrtr_store::{InMemoryStateStore, RequestStateStore};
#[cfg(feature = "server")]
pub use app::{App, context::Context};
#[cfg(feature = "client")]
pub use client::Client;
#[cfg(feature = "server")]
pub mod app;
#[cfg(feature = "client")]
pub mod client;
pub mod commands;
#[cfg(feature = "di")]
pub mod di;
pub mod error;
#[cfg(feature = "macros")]
pub mod macros;
#[cfg(feature = "server")]
pub mod middleware;
pub mod shared;
#[cfg(any(feature = "server", feature = "client"))]
pub mod transport;
pub mod types;
#[cfg(feature = "client-macros")]
pub use neva_macros::elicitation;
#[cfg(feature = "macros")]
pub use neva_macros::json_schema;
#[cfg(all(feature = "client-macros", feature = "legacy-spec"))]
pub use neva_macros::sampling;
#[cfg(feature = "server-macros")]
pub use neva_macros::{completion, handler, prompt, resource, resources, tool};
pub(crate) const SDK_NAME: &str = "neva";
#[cfg(any(feature = "server", feature = "client"))]
pub(crate) const PROTOCOL_VERSIONS: &[&str] = &[
"2024-11-05",
"2025-03-26",
"2025-06-18",
"2025-11-25",
#[cfg(not(feature = "legacy-spec"))]
LATEST_PROTOCOL_VERSION,
];
#[cfg(not(feature = "legacy-spec"))]
pub(crate) const LATEST_PROTOCOL_VERSION: &str = "2026-07-28";
#[cfg(any(
// all(feature = "legacy-spec", feature = "proto-2027-XX-XX"),
))]
compile_error!("Only one protocol-generation feature flag may be enabled per build");
#[cfg(any(feature = "http-server", feature = "client-oauth"))]
pub mod auth {
#[cfg(feature = "http-server")]
pub use crate::transport::http::core::types::Claims;
#[cfg(feature = "http-server")]
pub use crate::transport::http::core::types::DefaultClaims;
#[cfg(feature = "http-server-volga")]
pub use crate::transport::http::server::volga::auth_config::AuthConfig;
#[cfg(all(feature = "http-server-volga", feature = "server-oauth"))]
pub use crate::transport::http::server::volga::auth_config::OAuthConfig;
#[cfg(feature = "http-server-volga")]
pub use volga::auth::AuthClaims;
#[cfg(feature = "http-server-volga")]
pub use volga::auth::{Algorithm, Authorizer, Claims as ClaimsDerive};
#[cfg(any(feature = "server-oauth", feature = "client-oauth"))]
pub mod oauth {
#[cfg(feature = "server-oauth")]
pub use crate::transport::http::core::oauth::{
BearerChallenge, OAuthError, OAuthErrorCode, OAuthResourceOptions,
ProtectedResourceMetadata, WELL_KNOWN_PROTECTED_RESOURCE, canonicalize_resource_uri,
protected_resource_metadata_url,
};
#[cfg(feature = "client-oauth")]
pub use crate::transport::http::client::oauth::{
AuthorizationHandler, CallbackParams, InMemoryTokenStore, LoopbackHandler,
OAuthClientConfig, TokenSet, TokenStore,
};
}
}
pub mod json {
#[doc(hidden)]
pub use schemars;
pub use schemars::JsonSchema;
}
#[doc(hidden)]
pub mod __macro_support {
#[cfg(not(feature = "legacy-spec"))]
pub use crate::types::schema_2020::{
SchemaProbe, ViaFallback, ViaJsonSchema, object_schema, primitive_subschema,
};
#[cfg(feature = "server")]
pub trait IsArgument {
fn is_argument() -> bool;
fn is_required() -> bool;
fn category() -> &'static str;
}
#[cfg(feature = "server")]
impl<T: crate::types::helpers::TypeCategory> IsArgument for T {
#[inline]
fn is_argument() -> bool {
T::category() != crate::types::PropertyType::None
}
#[inline]
fn is_required() -> bool {
!T::is_optional()
}
#[inline]
fn category() -> &'static str {
use crate::types::PropertyType;
match T::category() {
PropertyType::String => "string",
PropertyType::Number => "number",
PropertyType::Integer => "integer",
PropertyType::Bool => "boolean",
PropertyType::Array => "array",
PropertyType::Object => "object",
PropertyType::None => "none",
}
}
}
}
#[cfg(feature = "server")]
#[macro_export]
macro_rules! map_tool {
($app:expr, $name:expr, |$($arg:ident : $ty:ty),* $(,)?| $body:expr) => {
$app.map_tool($name, move |$($arg: $ty),*| $body)
.with_arg_names($crate::__arg_names!($($arg : $ty),*))
};
}
#[cfg(feature = "server")]
#[macro_export]
macro_rules! map_prompt {
($app:expr, $name:expr, |$($arg:ident : $ty:ty),* $(,)?| $body:expr) => {
$app.map_prompt($name, move |$($arg: $ty),*| $body)
.with_args($crate::__prompt_args!($($arg : $ty),*))
};
}
#[cfg(feature = "server")]
#[doc(hidden)]
#[macro_export]
macro_rules! __arg_names {
($($arg:ident : $ty:ty),* $(,)?) => {{
let mut names: ::std::vec::Vec<&'static str> = ::std::vec::Vec::new();
$(
if <$ty as $crate::__macro_support::IsArgument>::is_argument() {
names.push(::core::stringify!($arg));
}
)*
names
}};
}
#[cfg(feature = "server")]
#[doc(hidden)]
#[macro_export]
macro_rules! __prompt_args {
($($arg:ident : $ty:ty),* $(,)?) => {{
type __PromptArg = $crate::types::prompt::PromptArgument;
let mut args: ::std::vec::Vec<__PromptArg> = ::std::vec::Vec::new();
$(
if <$ty as $crate::__macro_support::IsArgument>::is_argument() {
args.push(__PromptArg::named(
::core::stringify!($arg),
<$ty as $crate::__macro_support::IsArgument>::is_required(),
));
}
)*
args
}};
}
pub mod prelude {
pub use crate::error::*;
pub use crate::json::*;
pub use crate::shared::BoxFuture;
pub use crate::types::*;
#[cfg(feature = "http-server-volga")]
pub use crate::auth::AuthConfig;
#[cfg(feature = "server-oauth")]
pub use crate::auth::oauth::OAuthResourceOptions;
#[cfg(feature = "http-server")]
pub use crate::auth::{Claims, DefaultClaims};
#[cfg(feature = "http-server")]
#[allow(deprecated)]
pub use crate::transport::SseResponse;
#[cfg(all(feature = "http-server", feature = "server-tls"))]
pub use crate::transport::http::{DevCertMode, TlsConfig};
#[cfg(feature = "http-server")]
pub use crate::transport::{
HttpContext, HttpEngine, HttpRequest, HttpResponse, HttpServer, StreamResponse, handlers,
};
#[cfg(all(feature = "server", not(feature = "legacy-spec")))]
pub use crate::app::extension::Extension;
#[cfg(all(feature = "server", not(feature = "legacy-spec"), feature = "tasks"))]
pub use crate::app::extension::TasksExtension;
#[cfg(feature = "server")]
pub use crate::app::{App, context::Context, options};
#[cfg(feature = "server")]
pub use crate::middleware::{MwContext, Next};
#[cfg(feature = "client")]
pub use crate::client::Client;
#[cfg(all(feature = "client", not(feature = "legacy-spec")))]
pub use crate::client::{Subscription, SubscriptionEnd};
#[cfg(feature = "client-macros")]
pub use crate::elicitation;
#[cfg(feature = "macros")]
pub use crate::json_schema;
#[cfg(all(feature = "client-macros", feature = "legacy-spec"))]
pub use crate::sampling;
#[cfg(feature = "server-macros")]
pub use crate::{completion, handler, prompt, resource, resources, tool};
#[cfg(feature = "di")]
pub use crate::di::Dc;
#[cfg(feature = "tasks")]
pub use crate::shared::TaskApi;
}
#[cfg(test)]
#[cfg(any(feature = "server", feature = "client"))]
mod proto_versions_tests {
use super::PROTOCOL_VERSIONS;
#[test]
fn latest_version_listed_unless_legacy() {
let has_latest = PROTOCOL_VERSIONS.contains(&"2026-07-28");
let legacy = cfg!(feature = "legacy-spec");
assert_eq!(
has_latest, !legacy,
"2026-07-28 must be advertised unless `legacy-spec` is on"
);
}
#[test]
fn stable_versions_always_listed() {
let stable: Vec<_> = PROTOCOL_VERSIONS
.iter()
.filter(|v| **v != "2026-07-28")
.copied()
.collect();
assert!(
!stable.is_empty(),
"PROTOCOL_VERSIONS must always advertise at least one stable version"
);
assert!(
stable.contains(&"2024-11-05"),
"PROTOCOL_VERSIONS must always advertise the inaugural MCP version 2024-11-05"
);
}
}