pub mod error;
pub mod response;
pub mod status;
pub use error::McpError;
pub use response::{json_err, json_ok, json_result};
pub use status::StatusInfo;
pub mod prelude {
pub use rmcp::{
ServerHandler, ServiceExt,
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
model::{ServerCapabilities, ServerInfo},
schemars, tool, tool_handler, tool_router,
transport::stdio,
};
pub use serde::Deserialize;
pub use crate::{json_err, json_ok, json_result};
pub use crate::status::StatusInfo;
}
use rmcp::ServiceExt;
use rmcp::model::{Implementation, ServerCapabilities, ServerInfo};
pub fn server_info(name: &str, description: &str) -> ServerInfo {
ServerInfo {
server_info: Implementation {
name: name.to_string(),
..Implementation::from_build_env()
},
instructions: Some(description.into()),
capabilities: ServerCapabilities::builder().enable_tools().build(),
..Default::default()
}
}
pub async fn run<S>(server: S) -> Result<(), Box<dyn std::error::Error>>
where
S: rmcp::ServerHandler,
{
let service = server.serve(rmcp::transport::stdio()).await?;
service.waiting().await?;
Ok(())
}