-
Notifications
You must be signed in to change notification settings - Fork 441
Change type of Tool.InputSchema to be JsonElement #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -24,5 +25,5 @@ public class Tool | |||
/// A JSON Schema object defining the expected parameters for the tool. | |||
/// </summary> | |||
[JsonPropertyName("inputSchema")] | |||
public JsonSchema? InputSchema { get; set; } | |||
public JsonElement InputSchema { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all JsonElement
are valid JSON schemas, and not all JSON schemas are valid root-level schemas per the MCP specification. We should try to insert baseline validation (e.g. using a wrapper type or validation on the setter) to make sure we conform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roughly, this should be checking that the JsonElement
is an object and also contains a "type"
keyword that is set to "object"
. Everything else including the "properties"
keyword is optional IIRC.
This seems to be causing hangs in the Ubuntu debug leg. |
There appear to be general reliability issues with our integration testing, although this is the first time I see a hang happening. |
044a291
to
65a9f2e
Compare
65a9f2e
to
36333a0
Compare
The Ubuntu hand is happening on #9 as well, so whatever the issue is, it's already in main it seems. |
Adding validation to the property setter revealed a few bugs in the process :-) Merging since CI is borked right now. |
@@ -481,8 +481,8 @@ private sealed class McpAIFunction(IMcpClient client, Tool tool) : AIFunction | |||
["type"] = "object", | |||
["title"] = tool.Name, | |||
["description"] = tool.Description ?? string.Empty, | |||
["properties"] = tool.InputSchema?.Properties ?? [], | |||
["required"] = tool.InputSchema?.Required ?? [] | |||
["properties"] = new Dictionary<string, object?>(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this. Your changes are leaving the properties and required keywords empty. Was this an intentional change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code so that it always just forwards the JsonElement
in the Tool. It is now always guaranteed to be populated.
No description provided.