httpmcp_rust/
handler_types.rs1use crate::context::RequestContext;
2use crate::error::Result;
3use crate::protocol::*;
4use futures::future::BoxFuture;
5use serde_json::Value;
6use std::collections::HashMap;
7
8pub type ToolHandler = Box<
10 dyn Fn(HashMap<String, Value>, RequestContext) -> BoxFuture<'static, Result<Value>>
11 + Send
12 + Sync,
13>;
14
15pub type ResourceListHandler = Box<
17 dyn Fn(
18 Option<String>,
19 RequestContext,
20 ) -> BoxFuture<'static, Result<(Vec<Resource>, Option<String>)>>
21 + Send
22 + Sync,
23>;
24
25pub type ResourceReadHandler = Box<
27 dyn Fn(String, RequestContext) -> BoxFuture<'static, Result<Vec<ResourceContents>>>
28 + Send
29 + Sync,
30>;
31
32pub type PromptHandler = Box<
34 dyn Fn(
35 String,
36 Option<HashMap<String, String>>,
37 RequestContext,
38 ) -> BoxFuture<'static, Result<(Option<String>, Vec<PromptMessage>)>>
39 + Send
40 + Sync,
41>;
42
43pub struct RegisteredTool {
45 pub meta: Tool,
46 pub handler: ToolHandler,
47}
48
49pub struct RegisteredResource {
51 pub meta: Resource,
52 pub list_handler: ResourceListHandler,
53 pub read_handler: ResourceReadHandler,
54}
55
56pub struct RegisteredPrompt {
58 pub meta: Prompt,
59 pub handler: PromptHandler,
60}