Change type of Tool.InputSchema to be JsonElement (#4)
* Change type of Tool.InputSchema to be JsonElement * Add schema validation in the InputSchema property setter. * Simplify AIFunction tool adapter. --------- Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
This commit is contained in:
parent
d23e065945
commit
3de19d38e4
1 changed files with 175 additions and 128 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System.Text.Json.Serialization;
|
||||
using ModelContextProtocol.Utils.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace ModelContextProtocol.Protocol.Types;
|
||||
|
||||
|
|
@ -23,6 +25,23 @@ public class Tool
|
|||
/// <summary>
|
||||
/// A JSON Schema object defining the expected parameters for the tool.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Needs to a valid JSON schema object that additionally is of type object.
|
||||
/// </remarks>
|
||||
[JsonPropertyName("inputSchema")]
|
||||
public JsonSchema? InputSchema { get; set; }
|
||||
public JsonElement InputSchema
|
||||
{
|
||||
get => _inputSchema;
|
||||
set
|
||||
{
|
||||
if (!McpJsonUtilities.IsValidMcpToolSchema(value))
|
||||
{
|
||||
throw new ArgumentException("The specified document is not a valid MPC tool JSON schema.", nameof(InputSchema));
|
||||
}
|
||||
|
||||
_inputSchema = value;
|
||||
}
|
||||
}
|
||||
|
||||
private JsonElement _inputSchema = McpJsonUtilities.DefaultMcpToolSchema;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue