restructure into multiple crates

add mcp server collection
This commit is contained in:
milan
2026-04-07 00:06:13 +02:00
parent 2dbac8a91a
commit ee17e74753
21 changed files with 2095 additions and 164 deletions
+47
View File
@@ -0,0 +1,47 @@
use chrono::{Datelike, Local};
use rmcp::model::{Implementation, ServerCapabilities, ServerInfo};
use rmcp::{tool, tool_handler, tool_router, ServerHandler};
use rmcp::handler::server::tool::ToolRouter;
use crate::McpServerHandler;
#[derive(Debug, Clone)]
pub struct DateTimeHandler {
tool_router: ToolRouter<Self>
}
impl McpServerHandler for DateTimeHandler {
fn new() -> Self {
DateTimeHandler { tool_router: Self::tool_router() }
}
}
#[tool_router]
impl DateTimeHandler {
#[tool(description = "returns the local datetime in ISO 8601", annotations(read_only_hint = true))]
fn get_local_datetime() -> String {
Local::now().format("%+").to_string()
}
#[tool(description = "returns the utc datetime in ISO 8601", annotations(read_only_hint = true))]
fn get_utc_datetime() -> String {
Local::now().format("%+").to_string()
}
#[tool(description = "return current week number in year", annotations(read_only_hint = true))]
fn get_week() -> String {
Local::now().iso_week().week().to_string()
}
#[tool(description = "return current weekday as 3-character-string (e.g. Mon, Tue, ...)", annotations(read_only_hint = true))]
fn get_weekday() -> String {
Local::now().weekday().to_string()
}
}
#[tool_handler]
impl ServerHandler for DateTimeHandler {
fn get_info(&self) -> ServerInfo {
ServerInfo::new(ServerCapabilities::builder().enable_tools().build())
.with_instructions("A simple clock/datetime provider. It is read only and thus safe to use.".to_string()).with_server_info(Implementation::new("datetime", env!("CARGO_PKG_VERSION")))
}
}