Expand description
§Neva
Easy configurable MCP server and client SDK for Rust
§Dependencies
[dependencies]
neva = { version = "0.1.5", features = ["full"] }
tokio = { version = "1", features = ["full"] }§Example Server
use neva::App;
#[tokio::main]
async fn main() {
let mut app = App::new()
.with_options(|opt| opt
.with_stdio());
app.map_tool("hello", |name: String| async move {
format!("Hello, {name}!")
});
app.run().await;
} §Example Client
use std::time::Duration;
use neva::{Client, error::Error};
#[tokio::main]
async fn main() -> Result<(), Error> {
let mut client = Client::new()
.with_options(|opt| opt
.with_stdio("npx", ["-y", "@modelcontextprotocol/server-everything"]));
client.connect().await?;
// Call a tool
let args = [("message", "Hello MCP!")];
let result = client.call_tool("echo", Some(args)).await?;
println!("{:?}", result.content);
client.disconnect().await
}Re-exports§
Modules§
- app
- Represents an MCP application
- auth
- client
- Utilities for the MCP client
- commands
- List of commands
- error
- Represents an error
- json
- macros
- Utilities for macros
- prelude
- shared
- Shared utilities for server and client
- transport
- types
Macros§
- spawn_
fair - Cooperatively yields to the Tokio scheduler before spawning a new task, ensuring fair task scheduling especially under high load or on platforms like Windows where newly spawned tasks may not execute promptly.
Attribute Macros§
- elicitation
- Maps the elicitation handler function
- handler
- Maps the function to a command handler
- json_
schema - prompt
- Maps the function to a prompt
- resource
- Maps the function to a resource template
- resources
- Maps the list of resources function
- sampling
- Maps the sampling handler function
- tool
- Maps the function to a tool