Skip to content

Tool.InputSchema silently defaults to {"type":"object"} when absent from JSON, masking missing required field #1575

@jwoo-msft

Description

@jwoo-msft

Describe the bug

Tool.InputSchema has a field initializer = McpJsonUtilities.DefaultMcpToolSchema that defaults to {"type":"object"}. When deserializing a JSON payload that omits inputSchema entirely, System.Text.Json leaves the field at its default rather than throwing. This silently accepts a spec-violating Tool definition.

Per the MCP spec (2025-03-26 through 2025-11-25), inputSchema is required on Tool ("required": ["inputSchema", "name"]). A missing inputSchema in JSON should cause deserialization to fail, not silently produce a valid-looking default.

To reproduce

string json = """{"name":"frob"}"""; // no inputSchema
Tool? tool = JsonSerializer.Deserialize<Tool>(json);
// Expected: throws (inputSchema is required per spec)
// Actual: succeeds, tool.InputSchema.ValueKind == Object, raw = {"type":"object"}

Expected behavior

Deserialization should fail when inputSchema is absent. Either add [JsonRequired] to the property, or validate in the setter that the value was explicitly provided.

Impact

Consumers using Tool for manifest deserialization cannot detect missing inputSchema after deserialization — the default masks the authoring error. This affects Windows MCP manifest validation (WMSS/ODR).

Version: ModelContextProtocol 0.4.0-preview.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions