#![allow(
clippy::expect_used,
clippy::panic,
clippy::missing_errors_doc,
clippy::missing_panics_doc,
dead_code
)]
use rmcp::ServiceExt;
use rmcp::handler::server::ServerHandler;
use rmcp::handler::server::router::tool::ToolRouter;
use rmcp::{tool, tool_handler, tool_router};
#[derive(Clone)]
struct StdioServer {
router: ToolRouter<Self>,
}
#[tool_router]
impl StdioServer {
fn new() -> Self {
Self {
router: Self::tool_router(),
}
}
#[tool(description = "Return a friendly greeting")]
async fn greet(&self) -> String {
"hello from stdio".to_string()
}
}
#[allow(clippy::unused_async_trait_impl)] #[tool_handler]
impl ServerHandler for StdioServer {}
#[tokio::main]
async fn main() {
let server = StdioServer::new();
let transport = rmcp::transport::io::stdio();
let running = server
.serve(transport)
.await
.expect("stdio server initialize");
running.waiting().await.ok();
}