-
Notifications
You must be signed in to change notification settings - Fork 465
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When inspecting my tool using MCP Inspector, I am seeing a validation error because a nullable property is listed as required but when the property is null it doesn't get output in the return json.
To Reproduce
Return a complex object from any tool with a nullable property and make sure that property is null when you return it in the tool.
Expected behavior
Either the nullable property should not be listed as required or the property should appear in the json but with a null value.
Logs
N/A
Additional context
Here is the code that I have for a quick sample tool that produces the issue.
[McpServerToolType]
internal static class Items
{
[McpServerTool(Name = "ListItems", Title = "List Items", UseStructuredContent = true), Description("Will get a list of items.")]
public static async Task<ItemsResponse> ProcessAsync()
{
ItemsResponse itemsResponse = new(
[
new(1, "Item 1", "Label 1", true),
new(2, "Item 2", "Label 2", false),
new(3, "Item 3", null, true)
]);
return await Task
.FromResult(itemsResponse)
.ConfigureAwait(false);
}
}
internal sealed record ItemsResponse(List<ItemRecord> ItemRecords);
internal sealed record ItemRecord(int Id, string Description, string? Label, bool Active);
Details I see in MCP Inspector:
Tool listing:
{
"tools": [
{
"name": "ListItems",
"title": "List Items",
"description": "Will get a list of items.",
"inputSchema": {
"type": "object",
"properties": {}
},
"outputSchema": {
"type": "object",
"properties": {
"itemRecords": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"description": {
"type": "string"
},
"label": {
"type": [
"string",
"null"
]
},
"active": {
"type": "boolean"
}
},
"required": [
"id",
"description",
"label",
"active"
]
}
}
},
"required": [
"itemRecords"
]
},
"annotations": {
"title": "List Items"
}
}
]
}
Tool response:
{
"itemRecords": [
{
"id": 1,
"description": "Item 1",
"label": "Label 1",
"active": true
},
{
"id": 2,
"description": "Item 2",
"label": "Label 2",
"active": false
},
{
"id": 3,
"description": "Item 3",
"active": true
}
]
}
Validation message:

Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working