Skip to content

Feature: Strict JSON Schema validation with actionable error messages in CLI mode #1005

@andylbrummer

Description

@andylbrummer

Problem

When using npx @modelcontextprotocol/inspector --cli --method tools/list, the inspector silently accepts invalid JSON Schema constructs that MCP clients like Claude Code reject. This makes debugging MCP server issues extremely difficult.

Example: Invalid schema accepted by inspector but rejected by Claude Code

The Go SDK's jsonschema package generates true for interface{} types:

{
  "name": "info",
  "outputSchema": {
    "type": "object",
    "properties": {
      "data": true,  // Invalid - should be a type definition
      "topic": { "type": "string" }
    }
  }
}

The inspector's tools/list returns this without any warning, but Claude Code rejects it with:

[ERROR] MCP server "my-server" Failed to fetch tools: [
  {
    "code": "custom",
    "path": ["tools", 7, "outputSchema", "properties", "data"],
    "message": "Invalid input"
  }
]

Other problematic patterns not caught:

  • "type": ["null", "boolean"] - nullable type syntax
  • Bare true for any-type fields (from Go's interface{})
  • Missing required type fields

Proposed Solution

Add a --strict flag (or make it default) that validates tool schemas against JSON Schema Draft-07/2020-12 and reports actionable errors:

$ npx @modelcontextprotocol/inspector --cli --method tools/list --strict ./my-server

Error: Invalid JSON Schema in tool "info"
  Path: outputSchema.properties.data
  Issue: Bare 'true' is not a valid type definition
  Suggestion: Use {"type": "object", "additionalProperties": true} for dynamic types

Error: Invalid JSON Schema in tool "get_tree"  
  Path: inputSchema.properties.show_ids.type
  Issue: Array type syntax ["null", "boolean"] may not be supported by all clients
  Suggestion: Use {"type": "boolean"} with "nullable": true, or make field optional

Benefits

  1. Faster debugging - Catch schema issues before deploying to MCP clients
  2. Better DX - Clear error messages with fix suggestions
  3. Ecosystem health - Encourage well-formed schemas across MCP servers

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliIssues and PRs specific to cli modeenhancementNew feature requestv2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions