neva_macros

Crates.ioneva_macros
lib.rsneva_macros
version0.1.6
created_at2025-04-07 15:13:07.440629+00
updated_at2025-09-14 15:55:28.566735+00
descriptionMacros for Neva
homepage
repositoryhttps://github.com/RomanEmreis/neva
max_upload_size
id1624348
size30,982
Roman (RomanEmreis)

documentation

https://docs.rs/neva

README

Neva

Easy configurable MCP server and client SDK for Rust

latest latest License: MIT CI Release

💡 Note: This project is currently in preview. Breaking changes can be introduced without prior notice.

API Docs | Examples

MCP Client

Dependencies

[dependencies]
neva = { version = "0.1.6", features = ["client-full"] }
tokio = { version = "1", features = ["full"] }

Code

use neva::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let mut client = Client::new()
        .with_options(|opt| opt
            .with_stdio("npx", ["-y", "@modelcontextprotocol/server-everything"])
            .with_timeout(Duration::from_secs(5)));
    
    client.connect().await?;

    // List tools
    let tools = client.list_tools(None).await?;
    for tool in tools.tools {
        println!("- {}", tool.name);
    }

    // Call a tool
    let args = [
        ("message", "Hello MCP!")
    ];
    let result = client.call_tool("echo", args).await?;
    println!("{:?}", result.content);

    client.disconnect().await
}

MCP Server

Dependencies

[dependencies]
neva = { version = "0.1.6", features = ["server-full"] }
tokio = { version = "1", features = ["full"] }

Code

use neva::prelude::*;

#[tool(descr = "A say hello tool")]
async fn hello(name: String) -> String {
    format!("Hello, {name}!")
}

#[resource(uri = "res://{name}", descr = "Some details about resource")]
async fn get_res(name: String) -> ResourceContents {
    ResourceContents::new(format!("res://{name}"))
        .with_mime("plain/text")
        .with_text(format!("Some details about resource: {name}"))
}

#[prompt(descr = "Analyze code for potential improvements")]
async fn analyze_code(lang: String) -> PromptMessage {
    PromptMessage::user()
        .with(format!("Language: {lang}"))
}

#[tokio::main]
async fn main() {
    App::new()
        .with_options(|opt| opt
            .with_stdio()
            .with_name("Sample MCP server")
            .with_version("1.0.0"))
        .run()
        .await;
}
Commit count: 54

cargo fmt