use turbomcp::prelude::*;
#[derive(Clone)]
struct CleanServer;
#[turbomcp::server(
name = "clean-server",
version = "1.0.0",
description = "Minimal MCP server demonstrating clean architecture"
)]
impl CleanServer {
#[tool]
async fn current_time(&self) -> McpResult<String> {
Ok(chrono::Utc::now().to_rfc3339())
}
#[tool]
async fn echo(&self, message: String) -> McpResult<String> {
Ok(format!("Echo: {}", message))
}
#[tool]
async fn calculate(&self, operation: String, a: f64, b: f64) -> McpResult<f64> {
match operation.as_str() {
"add" => Ok(a + b),
"subtract" => Ok(a - b),
"multiply" => Ok(a * b),
"divide" if b != 0.0 => Ok(a / b),
"divide" => Err(McpError::invalid_params("Division by zero")),
_ => Err(McpError::invalid_params(format!(
"Unknown operation: {}",
operation
))),
}
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_writer(std::io::stderr)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
tracing::info!("Starting Clean Server...");
CleanServer.run_stdio().await?;
Ok(())
}