rust-sdk/examples/servers/src/task_stdio.rs
Dale Seo 5ccdfc07be
feat: add task-based stdio examples (#839)
* feat: add task-based stdio examples

* docs: add Tasks section to Chinese README
2026-05-13 09:22:29 -04:00

27 lines
801 B
Rust

use anyhow::Result;
use common::task_demo::TaskDemo;
use rmcp::{ServiceExt, transport::stdio};
use tracing_subscriber::{self, EnvFilter};
mod common;
/// Stdio server demonstrating task-based tool invocation.
///
/// Run a matching client with:
/// cargo run -p mcp-client-examples --example clients_task_stdio
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env().add_directive(tracing::Level::INFO.into()))
.with_writer(std::io::stderr)
.with_ansi(false)
.init();
tracing::info!("Starting task-demo MCP server");
let service = TaskDemo::new().serve(stdio()).await.inspect_err(|e| {
tracing::error!("serving error: {e:?}");
})?;
service.waiting().await?;
Ok(())
}