Skip to content

Proactive Schema Sanitization for MCP Tools - #2096

Merged
ql-owo-lp merged 3 commits into
mainfrom
schema-sanitization-fix-8077596153217320016
Jan 13, 2026
Merged

ql-owo-lp merged 3 commits into
mainfrom
schema-sanitization-fix-8077596153217320016

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

In this change, we are going to focus on resolving Schema Validation Errors users are complaining about in GitHub issues (e.g., modelcontextprotocol/servers#3144, anthropics/claude-code/issues/10606), specifically where strict MCP clients reject tools due to minor schema defects like missing "type": "object".

Today, I have chosen Track 1: The Friction Fighter to focus on: Proactive Schema Sanitization because it directly addresses the user's need for reliability and compatibility, ensuring that tools generated from various upstream sources (like OpenAPI specs) work seamlessly even with strict clients.

  • The Investigation Report:

    • Source: GitHub Issues (modelcontextprotocol/servers#3144, anthropics/claude-code/issues/10606).
    • Problem: Strict MCP clients (like Claude Code) validate tool input schemas rigorously. If a tool definition (often generated from upstream configs) has properties but is missing "type": "object", the client rejects the tool or crashes the session.
    • Impact: Users face "silent failures" or explicit validation errors for tools that should otherwise work.
  • The Implementation:

    • New Logic: Implemented SanitizeJSONSchema in server/pkg/tool/schema_sanitizer.go. This function recursively walks the JSON schema. If it detects a schema object with properties but no type, it injects "type": "object".
    • Integration: Updated ConvertMCPToolToProto in server/pkg/tool/converters.go to call SanitizeJSONSchema before converting the schema to a protobuf struct. This ensures that all tools registered via this path (e.g., from dynamic configs) are sanitized before being exposed to clients.
    • Testing: Added server/pkg/tool/schema_sanitizer_test.go with unit tests covering simple and nested schema sanitization scenarios. Verified that go test ./server/pkg/tool/ passes.
  • The Continuity Check:

    • Updated server/roadmap.md:
      • Added "Proactive Schema Sanitization" to Implemented Features.
      • Added "Multi-Model Advisor" and "MCP Server Aggregator/Proxy" to recommended features based on research.
  • Testing & CI:

    • Unit tests in server/pkg/tool/ passed.
    • The fix is targeted and includes tests for the specific failure mode.

PR created automatically by Jules for task 8077596153217320016 started by @ql-owo-lp

- Implements `SanitizeJSONSchema` to automatically fix common schema issues (missing `type: object`).
- Integrates sanitization into `ConvertMCPToolToProto`.
- Resolves compatibility issues with strict MCP clients like Claude Code.
- Updates roadmap with new planned features.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@codecov

codecov Bot commented Jan 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/pkg/tool/schema_sanitizer.go 76.47% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@ql-owo-lp

Copy link
Copy Markdown
Contributor

@jules the git hub actions are failing. Failing GitHub actions:

  • ci-success
  • ui-test (1/2)

CodeQL Summary:
View all branch alerts.

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

@jules the git hub actions are failing. Failing GitHub actions:

  • ci-success
  • ui-test (1/2)

CodeQL Summary:
View all branch alerts.

Thank you for the report. I see that the ui-test is failing. Based on the logs from a local run, it seems like there are some connectivity issues and potentially flaky tests (checkConnection failed with operation was canceled and connection refused). This might be due to the environment setup or timing. My changes to schema_sanitizer.go and converters.go are strictly backend logic for tool schema sanitization and shouldn't directly impact the UI connectivity or the stack-composer tests unless the server is crashing or behaving unexpectedly during startup.

However, I noticed make update-screenshots failed because it wasn't available in the root Makefile, but it is in ui/Makefile. I'll try to investigate if my changes caused any regression in how the server handles tool registration which might affect the UI. I will also re-verify the tests.

google-labs-jules Bot and others added 2 commits January 12, 2026 20:14
- Implements `SanitizeJSONSchema` to automatically fix common schema issues (missing `type: object`).
- Integrates sanitization into `ConvertMCPToolToProto`.
- Resolves compatibility issues with strict MCP clients like Claude Code.
- Updates roadmap with new planned features.
- Adds unit tests for schema sanitization.
@ql-owo-lp
ql-owo-lp marked this pull request as ready for review January 13, 2026 09:19
@ql-owo-lp
ql-owo-lp merged commit 47d3743 into main Jan 13, 2026
30 checks passed
@ql-owo-lp
ql-owo-lp deleted the schema-sanitization-fix-8077596153217320016 branch January 13, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant