* feat(macros): auto-generate get_info and default router * docs: simplify examples and docs with new defaults * feat(macros): add tool_router(server_handler) to elide separate #[tool_handler] impl * docs: add Tools section to README and simplify calculator examples with server_handler
26 lines
869 B
Rust
26 lines
869 B
Rust
use anyhow::Result;
|
|
use common::calculator::Calculator;
|
|
use rmcp::{ServiceExt, transport::stdio};
|
|
use tracing_subscriber::{self, EnvFilter};
|
|
mod common;
|
|
|
|
/// npx @modelcontextprotocol/inspector cargo run -p mcp-server-examples --example servers_calculator_stdio
|
|
#[tokio::main]
|
|
async fn main() -> Result<()> {
|
|
// Initialize the tracing subscriber with file and stdout logging
|
|
tracing_subscriber::fmt()
|
|
.with_env_filter(EnvFilter::from_default_env().add_directive(tracing::Level::DEBUG.into()))
|
|
.with_writer(std::io::stderr)
|
|
.with_ansi(false)
|
|
.init();
|
|
|
|
tracing::info!("Starting Calculator MCP server");
|
|
|
|
// Create an instance of our calculator router
|
|
let service = Calculator.serve(stdio()).await.inspect_err(|e| {
|
|
tracing::error!("serving error: {:?}", e);
|
|
})?;
|
|
|
|
service.waiting().await?;
|
|
Ok(())
|
|
}
|