poem-mcpserver 0.1.0

Poem for AWS Lambda
Documentation
poem-mcpserver-0.1.0 has been yanked.

Example

use poem_mcpserver::{McpServer, Tools, stdio::stdio, tool::Text};
use tokio::sync::Mutex;

struct Counter {
    count: Mutex<i32>,
}

/// This server provides a counter tool that can increment and decrement values.
///
/// The counter starts at 0 and can be modified using the 'increment' and 'decrement' tools.
/// Use 'get_value' to check the current count.
#[Tools]
impl Counter {
    /// Increment the counter by 1
    async fn increment(&self) -> Text<i32> {
        let mut count = self.count.lock().await;
        *count += 1;
        Text(*count)
    }

    /// Decrement the counter by 1
    async fn decrement(&self) -> Text<i32> {
        let mut count = self.count.lock().await;
        *count -= 1;
        Text(*count)
    }

    /// Get the current counter value
    async fn get_value(&self) -> Text<i32> {
        let count = self.count.lock().await;
        Text(*count)
    }
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    stdio(McpServer::new().tools(Counter {
        count: Mutex::new(0),
    }))
    .await
}

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

MSRV

The minimum supported Rust version for this crate is 1.83.0.

Contributing

:balloon: Thanks for your help improving the project! We are so happy to have you!

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Poem by you, shall be licensed as Apache, without any additional terms or conditions.