poem-mcpserver

Crates.iopoem-mcpserver
lib.rspoem-mcpserver
version0.2.4
sourcesrc
created_at2025-03-17 04:06:36.92893+00
updated_at2025-06-06 13:50:37.394532+00
descriptionMCP Server implementation for Poem
homepagehttps://github.com/poem-web/poem
repositoryhttps://github.com/poem-web/poem
max_upload_size
id1594989
size80,239
Sunli (sunli829)

documentation

https://docs.rs/poem/

README

MCP Server implementation for Poem

Crates.io version Download docs.rs docs Unsafe Rust forbidden rustc 1.85.0+

Example

[dependencies]
poem-mcpserver.workspace = "*"
serde = { version = "1.0", features = ["derive"] }
schemars = "0.8.22"
use poem_mcpserver::{stdio::stdio, tool::Text, McpServer, Tools};

struct Counter {
    count: 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(&mut self) -> Text<i32> {
        self.count += 1;
        Text(self.count)
    }

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

    /// Get the current counter value
    async fn get_value(&self) -> Text<i32> {
        Text(self.count)
    }
}

#[tokio::main]
async fn main() -> std::io::Result<()> {
    stdio(McpServer::new().tools(Counter { count: 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.85.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.

Commit count: 1437

cargo fmt