prometheus_mcp/mcp/
utilities.rs1use crate::mcp::types::*;
2use crate::mcp::{PROTOCOL_VERSION, SERVER_NAME, SERVER_VERSION};
3use rpc_router::HandlerResult;
4use serde_json::json;
5
6pub async fn initialize(_request: InitializeRequest) -> HandlerResult<InitializeResult> {
8 let result = InitializeResult {
9 protocol_version: PROTOCOL_VERSION.to_string(),
10 server_info: Implementation {
11 name: SERVER_NAME.to_string(),
12 version: SERVER_VERSION.to_string(),
13 },
14 capabilities: ServerCapabilities {
15 experimental: None,
16 prompts: None,
17 resources: None,
18 tools: Some(json!({})),
19 roots: None,
20 sampling: None,
21 logging: None,
22 },
23 instructions: None,
24 };
25 Ok(result)
26}
27
28pub fn graceful_shutdown() {
30 }
32
33pub fn notifications_initialized() {}
35
36pub fn notifications_cancelled(_params: CancelledNotification) {
38 }
40
41pub async fn ping(_request: PingRequest) -> HandlerResult<EmptyResult> {
42 Ok(EmptyResult {})
43}
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[tokio::test]
50 async fn test_initialize() {
51 let req = InitializeRequest {
52 protocol_version: "1.0".into(),
53 capabilities: ClientCapabilities::default(),
54 client_info: Implementation {
55 name: "test".into(),
56 version: "0".into(),
57 },
58 };
59 let res = super::initialize(req).await.unwrap();
60 assert_eq!(res.server_info.name, crate::mcp::SERVER_NAME);
61 }
62}