ToolSearch drops required field from MCP tool schema

Resolved 💬 2 comments Opened Feb 28, 2026 by anatolykoptev Closed Mar 28, 2026

Bug Description

When loading deferred MCP tools via ToolSearch, a required field (query) is silently dropped from the tool's JSON Schema. This causes the tool call to fail with a validation error on the server side, because the client never knew the field existed.

Steps to Reproduce

  1. Register an MCP server (streamable-http) with a tool that has 5 properties, 3 of which are required:
type CodeCompareInput struct {
    RepoA    string `json:"repo_a" jsonschema_description:"First repository"`
    RepoB    string `json:"repo_b" jsonschema_description:"Second repository"`
    Query    string `json:"query" jsonschema_description:"What to compare"`
    Focus    string `json:"focus,omitempty" jsonschema_description:"Subdirectory filter"`
    Language string `json:"language,omitempty" jsonschema_description:"Language filter"`
}
  1. The MCP server correctly advertises this schema via tools/list:
{
  "properties": {
    "repo_a": { "type": "string" },
    "repo_b": { "type": "string" },
    "query": { "type": "string" },
    "focus": { "type": "string" },
    "language": { "type": "string" }
  },
  "required": ["repo_a", "repo_b", "query"],
  "additionalProperties": false
}

Verified via direct curl:

curl -s http://127.0.0.1:8897/mcp -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | jq '.result.tools[] | select(.name=="code_compare")'
  1. Call ToolSearch with query +go-code repo_analyze — it returns 5 tools including code_compare.
  1. Observed: The schema returned by ToolSearch for code_compare is missing the query property entirely:
{
  "properties": {
    "repo_a": { "type": "string" },
    "repo_b": { "type": "string" },
    "focus": { "type": "string" },
    "language": { "type": "string" }
  },
  "required": ["repo_a", "repo_b"],
  "additionalProperties": false
}
  1. Claude calls the tool without query (since the schema says it doesn't exist).
  1. The MCP server correctly rejects the call:
MCP error -32602: invalid params: validating "arguments": validating root: required: missing properties: ["query"]

Key Detail

Another tool from the same MCP server (repo_analyze) also has a query field with identical struct tags — and ToolSearch loads it correctly. Both tools are returned in the same ToolSearch response.

| Tool | query in server schema | query in ToolSearch result |
|------|---|---|
| repo_analyze | ✅ present | ✅ present |
| code_compare | ✅ present | ❌ missing |

Environment

  • Claude Code version: latest (2026-02-28)
  • Model: claude-opus-4-6
  • MCP server: custom Go server using github.com/modelcontextprotocol/go-sdk v1.4.0
  • Transport: streamable-http
  • OS: Linux (Ubuntu)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗