Skip to main content

harn_vm/mcp_server/
defs.rs

1use std::collections::BTreeMap;
2
3use crate::value::VmClosure;
4
5/// Script-supplied metadata for a Harn-served MCP endpoint.
6#[derive(Clone, Debug, Default, Eq, PartialEq)]
7pub struct McpServerMetadata {
8    pub name: Option<String>,
9    pub version: Option<String>,
10    pub instructions: Option<String>,
11}
12
13/// A tool extracted from a Harn tool_registry, ready to serve over MCP.
14pub struct McpToolDef {
15    pub name: String,
16    pub title: Option<String>,
17    pub description: String,
18    pub input_schema: serde_json::Value,
19    pub output_schema: Option<serde_json::Value>,
20    pub annotations: Option<serde_json::Value>,
21    pub icons: Option<serde_json::Value>,
22    /// Protocol extension metadata projected as the MCP `_meta` field.
23    pub meta: Option<serde_json::Value>,
24    pub handler: VmClosure,
25}
26
27/// A static resource to serve over MCP.
28pub struct McpResourceDef {
29    pub uri: String,
30    pub name: String,
31    pub title: Option<String>,
32    pub description: Option<String>,
33    pub mime_type: Option<String>,
34    /// Protocol extension metadata projected on both discovery and content.
35    pub meta: Option<serde_json::Value>,
36    pub text: String,
37}
38
39/// A parameterized resource template (RFC 6570 URI template).
40pub struct McpResourceTemplateDef {
41    pub uri_template: String,
42    pub name: String,
43    pub title: Option<String>,
44    pub description: Option<String>,
45    pub mime_type: Option<String>,
46    pub completions: BTreeMap<String, McpCompletionSource>,
47    pub handler: VmClosure,
48}
49
50/// Static or computed suggestions for a prompt/resource-template argument.
51#[derive(Default)]
52pub struct McpCompletionSource {
53    pub values: Vec<String>,
54    pub handler: Option<VmClosure>,
55}
56
57/// A prompt argument definition.
58pub struct McpPromptArgDef {
59    pub name: String,
60    pub description: Option<String>,
61    pub required: bool,
62    pub completion: Option<McpCompletionSource>,
63}
64
65/// A prompt template to serve over MCP.
66pub struct McpPromptDef {
67    pub name: String,
68    pub title: Option<String>,
69    pub description: Option<String>,
70    pub arguments: Option<Vec<McpPromptArgDef>>,
71    pub handler: VmClosure,
72}