|
@@ -90,7 +90,7 @@ The library now uses Jsonrpc.Server from jsonrpc-glib-1.0 for handling JSON-RPC
|
|
|
- Proper STDIO transport handling
|
|
- Proper STDIO transport handling
|
|
|
- Automatic message parsing and formatting
|
|
- Automatic message parsing and formatting
|
|
|
|
|
|
|
|
-### Mcp.Core.McpError
|
|
|
|
|
|
|
+### Mcp.Core.Error
|
|
|
|
|
|
|
|
Error domain for MCP-specific errors.
|
|
Error domain for MCP-specific errors.
|
|
|
|
|
|
|
@@ -102,12 +102,48 @@ public static const int INVALID_REQUEST = -32600;
|
|
|
public static const int METHOD_NOT_FOUND = -32601;
|
|
public static const int METHOD_NOT_FOUND = -32601;
|
|
|
public static const int INVALID_PARAMS = -32602;
|
|
public static const int INVALID_PARAMS = -32602;
|
|
|
public static const int INTERNAL_ERROR = -32603;
|
|
public static const int INTERNAL_ERROR = -32603;
|
|
|
-public static const int RESOURCE_NOT_FOUND = -32604;
|
|
|
|
|
-public static const int TRANSPORT_ERROR = -32605;
|
|
|
|
|
|
|
+public static const int NOT_FOUND = -32604;
|
|
|
|
|
+public static const int INVALID_ARGUMENT = -32605;
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Convenience Constructors
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static Error PARSE (string message)
|
|
|
|
|
+public static Error INVALID_REQUEST (string message)
|
|
|
|
|
+public static Error METHOD_NOT_FOUND (string message)
|
|
|
|
|
+public static Error INVALID_PARAMS (string message)
|
|
|
|
|
+public static Error INTERNAL_ERROR (string message)
|
|
|
|
|
+public static Error NOT_FOUND (string message)
|
|
|
|
|
+public static Error INVALID_ARGUMENT (string message)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
## Types Namespace
|
|
## Types Namespace
|
|
|
|
|
|
|
|
|
|
+### Mcp.Core.InjectContentLength
|
|
|
|
|
+
|
|
|
|
|
+Utility class for injecting Content-Length headers into messages.
|
|
|
|
|
+
|
|
|
|
|
+#### Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static string process (string message)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Injects the Content-Length header into a JSON-RPC message.
|
|
|
|
|
+
|
|
|
|
|
+### Mcp.Core.StripContentLength
|
|
|
|
|
+
|
|
|
|
|
+Utility class for stripping Content-Length headers from messages.
|
|
|
|
|
+
|
|
|
|
|
+#### Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static string process (string message)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Removes the Content-Length header from a JSON-RPC message.
|
|
|
|
|
+
|
|
|
### Mcp.Types.Protocol.ServerInfo
|
|
### Mcp.Types.Protocol.ServerInfo
|
|
|
|
|
|
|
|
Information about the MCP server.
|
|
Information about the MCP server.
|
|
@@ -118,7 +154,8 @@ Information about the MCP server.
|
|
|
public ServerInfo (
|
|
public ServerInfo (
|
|
|
string name,
|
|
string name,
|
|
|
string version,
|
|
string version,
|
|
|
- string? description = null
|
|
|
|
|
|
|
+ string? description = null,
|
|
|
|
|
+ string? website_url = null
|
|
|
)
|
|
)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
@@ -128,6 +165,7 @@ public ServerInfo (
|
|
|
public string name { get; set; }
|
|
public string name { get; set; }
|
|
|
public string version { get; set; }
|
|
public string version { get; set; }
|
|
|
public string? description { get; set; }
|
|
public string? description { get; set; }
|
|
|
|
|
+public string? website_url { get; set; }
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Types.Protocol.ServerCapabilities
|
|
### Mcp.Types.Protocol.ServerCapabilities
|
|
@@ -138,11 +176,22 @@ Server capabilities configuration.
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public bool logging { get; set; }
|
|
public bool logging { get; set; }
|
|
|
|
|
+public Mcp.Types.Protocol.CompletionsCapabilities? completions { get; set; }
|
|
|
public Mcp.Types.Protocol.ResourcesCapabilities? resources { get; set; }
|
|
public Mcp.Types.Protocol.ResourcesCapabilities? resources { get; set; }
|
|
|
public Mcp.Types.Protocol.ToolsCapabilities? tools { get; set; }
|
|
public Mcp.Types.Protocol.ToolsCapabilities? tools { get; set; }
|
|
|
public Mcp.Types.Protocol.PromptsCapabilities? prompts { get; set; }
|
|
public Mcp.Types.Protocol.PromptsCapabilities? prompts { get; set; }
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
+### Mcp.Types.Protocol.CompletionsCapabilities
|
|
|
|
|
+
|
|
|
|
|
+Completion-related capabilities.
|
|
|
|
|
+
|
|
|
|
|
+#### Properties
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public bool list_changed { get; set; }
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
### Mcp.Types.Protocol.ResourcesCapabilities
|
|
### Mcp.Types.Protocol.ResourcesCapabilities
|
|
|
|
|
|
|
|
Resource-related capabilities.
|
|
Resource-related capabilities.
|
|
@@ -296,6 +345,62 @@ public string? audience { get; set; }
|
|
|
public bool? expire_time { get; set; }
|
|
public bool? expire_time { get; set; }
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
+### Mcp.Types.VariantUtils
|
|
|
|
|
+
|
|
|
|
|
+Utility functions for working with GLib.Variant data structures.
|
|
|
|
|
+
|
|
|
|
|
+#### Dictionary Builder Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static VariantBuilder new_dict_builder ()
|
|
|
|
|
+public static void add_string (VariantBuilder builder, string key, string value)
|
|
|
|
|
+public static void add_int (VariantBuilder builder, string key, int value)
|
|
|
|
|
+public static void add_bool (VariantBuilder builder, string key, bool value)
|
|
|
|
|
+public static void add_double (VariantBuilder builder, string key, double value)
|
|
|
|
|
+public static void add_variant (VariantBuilder builder, string key, Variant value)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Dictionary Access Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static bool has_key (Variant dict, string key)
|
|
|
|
|
+public static string get_string (Variant dict, string key, string? default_value = null)
|
|
|
|
|
+public static int get_int (Variant dict, string key, int default_value = 0)
|
|
|
|
|
+public static bool get_bool (Variant dict, string key, bool default_value = false)
|
|
|
|
|
+public static double get_double (Variant dict, string key, double default_value = 0.0)
|
|
|
|
|
+public static Variant? get_variant (Variant dict, string key)
|
|
|
|
|
+public static string[] get_string_array (Variant dict, string key)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Array Builder Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static VariantBuilder new_array_builder (string element_type)
|
|
|
|
|
+public static void add_string_element (VariantBuilder builder, string value)
|
|
|
|
|
+public static void add_int_element (VariantBuilder builder, int value)
|
|
|
|
|
+public static void add_bool_element (VariantBuilder builder, bool value)
|
|
|
|
|
+public static void add_double_element (VariantBuilder builder, double value)
|
|
|
|
|
+public static void add_variant_element (VariantBuilder builder, Variant value)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Array Access Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static int get_array_size (Variant array)
|
|
|
|
|
+public static string get_string_element (Variant array, int index)
|
|
|
|
|
+public static int get_int_element (Variant array, int index)
|
|
|
|
|
+public static bool get_bool_element (Variant array, int index)
|
|
|
|
|
+public static double get_double_element (Variant array, int index)
|
|
|
|
|
+public static Variant get_variant_element (Variant array, int index)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Conversion Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public static Json.Node? to_json (Variant variant)
|
|
|
|
|
+public static Variant? from_json (Json.Node node)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
## Resources Namespace
|
|
## Resources Namespace
|
|
|
|
|
|
|
|
### Mcp.Resources.Provider
|
|
### Mcp.Resources.Provider
|
|
@@ -415,7 +520,7 @@ Interface for tool executors.
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public abstract Mcp.Tools.Types.ToolDefinition get_definition () throws Error
|
|
public abstract Mcp.Tools.Types.ToolDefinition get_definition () throws Error
|
|
|
-public abstract async Mcp.Tools.Types.CallToolResult execute (Json.Object arguments) throws Error
|
|
|
|
|
|
|
+public abstract async Mcp.Tools.Types.CallToolResult execute (Variant arguments) throws Error
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Tools.BaseExecutor
|
|
### Mcp.Tools.BaseExecutor
|
|
@@ -432,17 +537,17 @@ protected BaseExecutor (Mcp.Tools.Types.ToolDefinition definition)
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public virtual Mcp.Tools.Types.ToolDefinition get_definition () throws Error
|
|
public virtual Mcp.Tools.Types.ToolDefinition get_definition () throws Error
|
|
|
-public async Mcp.Tools.Types.CallToolResult execute (Json.Object arguments) throws Error
|
|
|
|
|
-protected virtual void validate_arguments (Json.Object arguments) throws Error
|
|
|
|
|
|
|
+public async Mcp.Tools.Types.CallToolResult execute (Variant arguments) throws Error
|
|
|
|
|
+protected virtual void validate_arguments (Variant arguments) throws Error
|
|
|
protected Mcp.Tools.Types.CallToolResult create_text_result (string text)
|
|
protected Mcp.Tools.Types.CallToolResult create_text_result (string text)
|
|
|
protected Mcp.Tools.Types.CallToolResult create_text_results (string[] texts)
|
|
protected Mcp.Tools.Types.CallToolResult create_text_results (string[] texts)
|
|
|
protected Mcp.Tools.Types.CallToolResult create_error_result (Error error)
|
|
protected Mcp.Tools.Types.CallToolResult create_error_result (Error error)
|
|
|
-protected Mcp.Tools.Types.CallToolResult create_structured_result (string text, Json.Object structured_data)
|
|
|
|
|
-protected string? get_string_arg (Json.Object arguments, string name, string? default_value = null)
|
|
|
|
|
-protected bool get_bool_arg (Json.Object arguments, string name, bool default_value = false)
|
|
|
|
|
-protected int get_int_arg (Json.Object arguments, string name, int default_value = 0)
|
|
|
|
|
-protected double get_double_arg (Json.Object arguments, string name, double default_value = 0.0)
|
|
|
|
|
-protected abstract async Mcp.Tools.Types.CallToolResult do_execute (Json.Object arguments) throws Error
|
|
|
|
|
|
|
+protected Mcp.Tools.Types.CallToolResult create_structured_result (string text, Variant structured_data)
|
|
|
|
|
+protected string? get_string_arg (Variant arguments, string name, string? default_value = null)
|
|
|
|
|
+protected bool get_bool_arg (Variant arguments, string name, bool default_value = false)
|
|
|
|
|
+protected int get_int_arg (Variant arguments, string name, int default_value = 0)
|
|
|
|
|
+protected double get_double_arg (Variant arguments, string name, double default_value = 0.0)
|
|
|
|
|
+protected abstract async Mcp.Tools.Types.CallToolResult do_execute (Variant arguments) throws Error
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Tools.Manager
|
|
### Mcp.Tools.Manager
|
|
@@ -455,7 +560,7 @@ Manages tool executors and handles tool operations.
|
|
|
public void register_executor (string name, Mcp.Tools.Executor executor)
|
|
public void register_executor (string name, Mcp.Tools.Executor executor)
|
|
|
public void unregister_executor (string name)
|
|
public void unregister_executor (string name)
|
|
|
public async Gee.ArrayList<Mcp.Tools.Types.ToolDefinition> list_tools () throws Error
|
|
public async Gee.ArrayList<Mcp.Tools.Types.ToolDefinition> list_tools () throws Error
|
|
|
-public async Mcp.Tools.Types.CallToolResult call_tool (string name, Json.Object arguments) throws Error
|
|
|
|
|
|
|
+public async Mcp.Tools.Types.CallToolResult call_tool (string name, Variant arguments) throws Error
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Tools.Types.ToolDefinition
|
|
### Mcp.Tools.Types.ToolDefinition
|
|
@@ -465,7 +570,7 @@ Tool definition.
|
|
|
#### Constructor
|
|
#### Constructor
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
-public ToolDefinition (string name, Json.Object input_schema)
|
|
|
|
|
|
|
+public ToolDefinition (string name, Variant input_schema)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
#### Properties
|
|
#### Properties
|
|
@@ -474,8 +579,8 @@ public ToolDefinition (string name, Json.Object input_schema)
|
|
|
public string name { get; set; }
|
|
public string name { get; set; }
|
|
|
public string? title { get; set; }
|
|
public string? title { get; set; }
|
|
|
public string? description { get; set; }
|
|
public string? description { get; set; }
|
|
|
-public Json.Object input_schema { get; set; }
|
|
|
|
|
-public Json.Object? output_schema { get; set; }
|
|
|
|
|
|
|
+public Variant input_schema { get; set; }
|
|
|
|
|
+public Variant? output_schema { get; set; }
|
|
|
public Mcp.Tools.Types.ToolExecution? execution { get; set; }
|
|
public Mcp.Tools.Types.ToolExecution? execution { get; set; }
|
|
|
public Mcp.Tools.Types.ToolAnnotations? annotations { get; set; }
|
|
public Mcp.Tools.Types.ToolAnnotations? annotations { get; set; }
|
|
|
```
|
|
```
|
|
@@ -495,13 +600,14 @@ Result of calling a tool.
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public CallToolResult ()
|
|
public CallToolResult ()
|
|
|
|
|
+public CallToolResult (Gee.ArrayList<Mcp.Types.Common.ContentBlock> content)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
#### Properties
|
|
#### Properties
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public Gee.ArrayList<Mcp.Types.Common.ContentBlock> content { get; set; }
|
|
public Gee.ArrayList<Mcp.Types.Common.ContentBlock> content { get; set; }
|
|
|
-public Json.Object? structured_content { get; set; }
|
|
|
|
|
|
|
+public Variant? structured_content { get; set; }
|
|
|
public bool is_error { get; set; }
|
|
public bool is_error { get; set; }
|
|
|
```
|
|
```
|
|
|
|
|
|
|
@@ -512,25 +618,52 @@ public Json.Node to_json ()
|
|
|
public CallToolResult.from_json (Json.Node node) throws Error
|
|
public CallToolResult.from_json (Json.Node node) throws Error
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-### Mcp.Tools.Types.ToolExecution
|
|
|
|
|
|
|
+### Mcp.Tools.Types.ToolExecutionContext
|
|
|
|
|
|
|
|
-Tool execution settings.
|
|
|
|
|
|
|
+Context for tool execution with progress tracking.
|
|
|
|
|
|
|
|
#### Constructor
|
|
#### Constructor
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
-public ToolExecution (string task_support = "forbidden")
|
|
|
|
|
|
|
+public ToolExecutionContext (string tool_name, Variant arguments)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
#### Properties
|
|
#### Properties
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
-public string task_support { get; set; }
|
|
|
|
|
|
|
+public string tool_name { get; construct; }
|
|
|
|
|
+public Variant arguments { get; construct; }
|
|
|
|
|
+public bool supports_progress { get; set; }
|
|
|
|
|
+public bool task_support { get; set; }
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Methods
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public void report_progress (Mcp.Tools.Types.ToolProgress progress)
|
|
|
|
|
+public void add_annotation (Mcp.Tools.Types.ToolAnnotation annotation)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Mcp.Tools.Types.ToolProgress
|
|
|
|
|
+
|
|
|
|
|
+Progress information for long-running tools.
|
|
|
|
|
+
|
|
|
|
|
+#### Constructor
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public ToolProgress (double progress, string? message = null)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Properties
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public double progress { get; set; }
|
|
|
|
|
+public string? message { get; set; }
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Tools.Types.ToolAnnotations
|
|
### Mcp.Tools.Types.ToolAnnotations
|
|
|
|
|
|
|
|
-Tool annotations.
|
|
|
|
|
|
|
+Tool execution annotations.
|
|
|
|
|
|
|
|
#### Constructor
|
|
#### Constructor
|
|
|
|
|
|
|
@@ -543,6 +676,41 @@ public ToolAnnotations ()
|
|
|
```vala
|
|
```vala
|
|
|
public string? audience { get; set; }
|
|
public string? audience { get; set; }
|
|
|
public double? priority { get; set; }
|
|
public double? priority { get; set; }
|
|
|
|
|
+public Gee.ArrayList<Mcp.Tools.Types.ToolAnnotation> annotations { get; set; }
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Mcp.Tools.Types.ToolAnnotation
|
|
|
|
|
+
|
|
|
|
|
+Individual tool annotation.
|
|
|
|
|
+
|
|
|
|
|
+#### Constructor
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public ToolAnnotation (string type, Variant data)
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Properties
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public string type { get; set; }
|
|
|
|
|
+public Variant data { get; set; }
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+### Mcp.Tools.Types.ToolExecution
|
|
|
|
|
+
|
|
|
|
|
+Tool execution settings.
|
|
|
|
|
+
|
|
|
|
|
+#### Constructor
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public ToolExecution (string task_support = "forbidden")
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+#### Properties
|
|
|
|
|
+
|
|
|
|
|
+```vala
|
|
|
|
|
+public string task_support { get; set; }
|
|
|
|
|
+public bool supports_progress { get; set; }
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
## Prompts Namespace
|
|
## Prompts Namespace
|
|
@@ -555,7 +723,7 @@ Interface for prompt templates.
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public abstract Mcp.Prompts.Types.PromptDefinition get_definition ()
|
|
public abstract Mcp.Prompts.Types.PromptDefinition get_definition ()
|
|
|
-public abstract async Mcp.Prompts.Types.GetPromptResult get_prompt (Json.Object arguments) throws Error
|
|
|
|
|
|
|
+public abstract async Mcp.Prompts.Types.GetPromptResult get_prompt (Variant arguments) throws Error
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Prompts.BaseTemplate
|
|
### Mcp.Prompts.BaseTemplate
|
|
@@ -566,20 +734,21 @@ Base implementation for prompt templates.
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
protected BaseTemplate (string name, string? title = null, string? description = null)
|
|
protected BaseTemplate (string name, string? title = null, string? description = null)
|
|
|
|
|
+protected BaseTemplate (string name, string? title, string? description, Gee.ArrayList<Mcp.Prompts.Types.PromptArgument> arguments)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
#### Methods
|
|
#### Methods
|
|
|
|
|
|
|
|
```vala
|
|
```vala
|
|
|
public virtual Mcp.Prompts.Types.PromptDefinition get_definition ()
|
|
public virtual Mcp.Prompts.Types.PromptDefinition get_definition ()
|
|
|
-public virtual async Mcp.Prompts.Types.GetPromptResult get_prompt (Json.Object arguments) throws Error
|
|
|
|
|
-protected virtual void validate_arguments (Json.Object arguments) throws Error
|
|
|
|
|
-protected virtual Gee.ArrayList<Mcp.Prompts.Types.PromptMessage> generate_messages (Json.Object arguments)
|
|
|
|
|
|
|
+public virtual async Mcp.Prompts.Types.GetPromptResult get_prompt (Variant arguments) throws Error
|
|
|
|
|
+protected virtual void validate_arguments (Variant arguments) throws Error
|
|
|
|
|
+protected virtual Gee.ArrayList<Mcp.Prompts.Types.PromptMessage> generate_messages (Variant arguments)
|
|
|
protected void add_argument (string name, string? title = null, string? description = null, bool required = false)
|
|
protected void add_argument (string name, string? title = null, string? description = null, bool required = false)
|
|
|
-protected string substitute_variables (string template, Json.Object arguments)
|
|
|
|
|
-protected Mcp.Types.Common.TextContent create_text_content (string template, Json.Object arguments)
|
|
|
|
|
-protected Mcp.Prompts.Types.PromptMessage create_user_message (string template, Json.Object arguments)
|
|
|
|
|
-protected Mcp.Prompts.Types.PromptMessage create_assistant_message (string template, Json.Object arguments)
|
|
|
|
|
|
|
+protected string substitute_variables (string template, Variant arguments)
|
|
|
|
|
+protected Mcp.Types.Common.TextContent create_text_content (string template, Variant arguments)
|
|
|
|
|
+protected Mcp.Prompts.Types.PromptMessage create_user_message (string template, Variant arguments)
|
|
|
|
|
+protected Mcp.Prompts.Types.PromptMessage create_assistant_message (string template, Variant arguments)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Prompts.Manager
|
|
### Mcp.Prompts.Manager
|
|
@@ -592,7 +761,7 @@ Manages prompt templates and handles prompt operations.
|
|
|
public void register_template (string name, Mcp.Prompts.Template template)
|
|
public void register_template (string name, Mcp.Prompts.Template template)
|
|
|
public void unregister_template (string name)
|
|
public void unregister_template (string name)
|
|
|
public async Gee.ArrayList<Mcp.Prompts.Types.PromptDefinition> list_prompts () throws Error
|
|
public async Gee.ArrayList<Mcp.Prompts.Types.PromptDefinition> list_prompts () throws Error
|
|
|
-public async Mcp.Prompts.Types.GetPromptResult get_prompt (string name, Json.Object arguments) throws Error
|
|
|
|
|
|
|
+public async Mcp.Prompts.Types.GetPromptResult get_prompt (string name, Variant arguments) throws Error
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### Mcp.Prompts.Types.PromptDefinition
|
|
### Mcp.Prompts.Types.PromptDefinition
|
|
@@ -760,7 +929,7 @@ public class MyResourceProvider : Mcp.Resources.BaseProvider {
|
|
|
|
|
|
|
|
public override async Mcp.Types.Common.ResourceContents read_resource (string uri) throws Error {
|
|
public override async Mcp.Types.Common.ResourceContents read_resource (string uri) throws Error {
|
|
|
if (!storage.contains (uri)) {
|
|
if (!storage.contains (uri)) {
|
|
|
- throw new Mcp.Core.McpError.RESOURCE_NOT_FOUND ("Resource not found");
|
|
|
|
|
|
|
+ throw new Mcp.Core.Error.NOT_FOUND ("Resource not found");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return new Mcp.Types.Common.TextResourceContents (uri, storage[uri]);
|
|
return new Mcp.Types.Common.TextResourceContents (uri, storage[uri]);
|
|
@@ -773,29 +942,28 @@ public class MyResourceProvider : Mcp.Resources.BaseProvider {
|
|
|
```vala
|
|
```vala
|
|
|
public class MyTool : Mcp.Tools.BaseExecutor {
|
|
public class MyTool : Mcp.Tools.BaseExecutor {
|
|
|
public MyTool () {
|
|
public MyTool () {
|
|
|
- // Define input schema
|
|
|
|
|
- var input_schema = new Json.Object ();
|
|
|
|
|
- input_schema.set_string_member ("type", "object");
|
|
|
|
|
-
|
|
|
|
|
- var properties = new Json.Object ();
|
|
|
|
|
- var param = new Json.Object ();
|
|
|
|
|
- param.set_string_member ("type", "string");
|
|
|
|
|
- param.set_string_member ("description", "Parameter description");
|
|
|
|
|
- properties.set_object_member ("param", param);
|
|
|
|
|
|
|
+ // Define input schema using Variant
|
|
|
|
|
+ var input_schema = Mcp.Types.VariantUtils.new_dict_builder ();
|
|
|
|
|
+ input_schema.add ("{sv}", "type", new Variant.string ("object"));
|
|
|
|
|
|
|
|
- input_schema.set_object_member ("properties", properties);
|
|
|
|
|
|
|
+ var properties = Mcp.Types.VariantUtils.new_dict_builder ();
|
|
|
|
|
+ var param = Mcp.Types.VariantUtils.new_dict_builder ();
|
|
|
|
|
+ param.add ("{sv}", "type", new Variant.string ("string"));
|
|
|
|
|
+ param.add ("{sv}", "description", new Variant.string ("Parameter description"));
|
|
|
|
|
+ properties.add ("{sv}", "param", param.end ());
|
|
|
|
|
|
|
|
- var required = new Json.Array ();
|
|
|
|
|
- required.add_string_element ("param");
|
|
|
|
|
- input_schema.set_array_member ("required", required);
|
|
|
|
|
|
|
+ var required = new VariantBuilder (new VariantType ("as"));
|
|
|
|
|
+ required.add_value ("s", "param");
|
|
|
|
|
+ input_schema.add ("{sv}", "properties", properties.end ());
|
|
|
|
|
+ input_schema.add ("{sv}", "required", required.end ());
|
|
|
|
|
|
|
|
- var definition = new Mcp.Tools.Types.ToolDefinition ("my_tool", input_schema);
|
|
|
|
|
|
|
+ var definition = new Mcp.Tools.Types.ToolDefinition ("my_tool", input_schema.end ());
|
|
|
definition.description = "Description of my tool";
|
|
definition.description = "Description of my tool";
|
|
|
|
|
|
|
|
base (definition);
|
|
base (definition);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected override async Mcp.Tools.Types.CallToolResult do_execute (Json.Object arguments) throws Error {
|
|
|
|
|
|
|
+ protected override async Mcp.Tools.Types.CallToolResult do_execute (Variant arguments) throws Error {
|
|
|
string param = get_string_arg (arguments, "param");
|
|
string param = get_string_arg (arguments, "param");
|
|
|
|
|
|
|
|
// Process input
|
|
// Process input
|
|
@@ -816,30 +984,32 @@ public class MyTool : Mcp.Tools.BaseExecutor {
|
|
|
```vala
|
|
```vala
|
|
|
public class MyPrompt : Mcp.Prompts.BaseTemplate {
|
|
public class MyPrompt : Mcp.Prompts.BaseTemplate {
|
|
|
public MyPrompt () {
|
|
public MyPrompt () {
|
|
|
- base ("my_prompt", "My Prompt", "Description of my prompt");
|
|
|
|
|
|
|
+ var arguments = new Gee.ArrayList<Mcp.Prompts.Types.PromptArgument> ();
|
|
|
|
|
+
|
|
|
|
|
+ var topic_arg = new Mcp.Prompts.Types.PromptArgument ("topic");
|
|
|
|
|
+ topic_arg.description = "The topic to generate content for";
|
|
|
|
|
+ topic_arg.required = true;
|
|
|
|
|
+ arguments.add (topic_arg);
|
|
|
|
|
|
|
|
- // Add arguments
|
|
|
|
|
- add_argument ("topic", "Topic", "The topic to generate content for", true);
|
|
|
|
|
- add_argument ("style", "Style", "Writing style", false, "neutral");
|
|
|
|
|
|
|
+ var style_arg = new Mcp.Prompts.Types.PromptArgument ("style");
|
|
|
|
|
+ style_arg.description = "Writing style";
|
|
|
|
|
+ arguments.add (style_arg);
|
|
|
|
|
+
|
|
|
|
|
+ base ("my_prompt", "My Prompt", "Description of my prompt", arguments);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected override Gee.ArrayList<Mcp.Prompts.Types.PromptMessage> generate_messages (Json.Object arguments) {
|
|
|
|
|
- var messages = new Gee.ArrayList<Mcp.Prompts.Types.PromptMessage> ();
|
|
|
|
|
|
|
+ protected override async Mcp.Prompts.Types.GetPromptResult do_render (Variant arguments) throws Error {
|
|
|
|
|
+ string topic = Mcp.Types.VariantUtils.get_string (arguments, "topic");
|
|
|
|
|
+ string style = Mcp.Types.VariantUtils.get_string (arguments, "style", "neutral");
|
|
|
|
|
|
|
|
- string topic = get_string_arg (arguments, "topic");
|
|
|
|
|
- string style = get_string_arg (arguments, "style", "neutral");
|
|
|
|
|
|
|
+ string template = """Generate %s content about %s.""".printf (style, topic);
|
|
|
|
|
|
|
|
- string template = """Generate {{style}} content about {{topic}}.""";
|
|
|
|
|
|
|
+ var content = new Mcp.Types.Common.TextContent (template);
|
|
|
|
|
+ var message = new Mcp.Prompts.Types.PromptMessage ("user", content);
|
|
|
|
|
+ var messages = new Gee.ArrayList<Mcp.Prompts.Types.PromptMessage> ();
|
|
|
|
|
+ messages.add (message);
|
|
|
|
|
|
|
|
- messages.add (create_user_message (template, arguments));
|
|
|
|
|
- return messages;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private string? get_string_arg (Json.Object arguments, string name, string? default_value = null) {
|
|
|
|
|
- if (arguments.has_member (name)) {
|
|
|
|
|
- return arguments.get_string_member (name);
|
|
|
|
|
- }
|
|
|
|
|
- return default_value;
|
|
|
|
|
|
|
+ return new Mcp.Prompts.Types.GetPromptResult (messages);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
@@ -942,7 +1112,7 @@ Mcp.Core.McpError
|
|
|
```vala
|
|
```vala
|
|
|
try {
|
|
try {
|
|
|
// MCP operation
|
|
// MCP operation
|
|
|
-} catch (Mcp.Core.McpError e) {
|
|
|
|
|
|
|
+} catch (Mcp.Core.Error e) {
|
|
|
// Handle MCP-specific errors
|
|
// Handle MCP-specific errors
|
|
|
stderr.printf ("MCP Error [%d]: %s\n", e.code, e.message);
|
|
stderr.printf ("MCP Error [%d]: %s\n", e.code, e.message);
|
|
|
} catch (GLib.Error e) {
|
|
} catch (GLib.Error e) {
|