Skip to main content

harn_vm/mcp_server/
defs.rs

1use std::collections::BTreeMap;
2
3use crate::value::VmClosure;
4
5/// A tool extracted from a Harn tool_registry, ready to serve over MCP.
6pub struct McpToolDef {
7    pub name: String,
8    pub title: Option<String>,
9    pub description: String,
10    pub input_schema: serde_json::Value,
11    pub output_schema: Option<serde_json::Value>,
12    pub annotations: Option<serde_json::Value>,
13    pub icons: Option<serde_json::Value>,
14    pub handler: VmClosure,
15}
16
17/// A static resource to serve over MCP.
18pub struct McpResourceDef {
19    pub uri: String,
20    pub name: String,
21    pub title: Option<String>,
22    pub description: Option<String>,
23    pub mime_type: Option<String>,
24    pub text: String,
25}
26
27/// A parameterized resource template (RFC 6570 URI template).
28pub struct McpResourceTemplateDef {
29    pub uri_template: String,
30    pub name: String,
31    pub title: Option<String>,
32    pub description: Option<String>,
33    pub mime_type: Option<String>,
34    pub completions: BTreeMap<String, McpCompletionSource>,
35    pub handler: VmClosure,
36}
37
38/// Static or computed suggestions for a prompt/resource-template argument.
39#[derive(Default)]
40pub struct McpCompletionSource {
41    pub values: Vec<String>,
42    pub handler: Option<VmClosure>,
43}
44
45/// A prompt argument definition.
46pub struct McpPromptArgDef {
47    pub name: String,
48    pub description: Option<String>,
49    pub required: bool,
50    pub completion: Option<McpCompletionSource>,
51}
52
53/// A prompt template to serve over MCP.
54pub struct McpPromptDef {
55    pub name: String,
56    pub title: Option<String>,
57    pub description: Option<String>,
58    pub arguments: Option<Vec<McpPromptArgDef>>,
59    pub handler: VmClosure,
60}