Add schema normalization middleware for invalid tool definitions#283
Merged
Add schema normalization middleware for invalid tool definitions#283
Conversation
- Created mcp.NormalizeInputSchema() to fix broken object schemas - Fixes issue where object schemas lack properties field - Integrated middleware into unified.go tool registration - Added comprehensive unit tests for normalization logic - Added integration tests to verify end-to-end behavior Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Consolidated three logging statements into a single structured logger call for consistency with the codebase. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Changed required field from []string to []interface{} for consistency with JSON schema handling.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add middleware to normalize inputSchema of tool definition
Add schema normalization middleware for invalid tool definitions
Jan 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some MCP servers return invalid JSON schemas for tool definitions. GitHub MCP Server v0.28.1's
get_committool declares"type": "object"but omits the requiredpropertiesfield, causing downstream validation failures per JSON Schema standards.Changes
internal/mcp/schema_normalizer.go: New middleware that detects object schemas missing bothpropertiesandadditionalProperties, adds emptypropertiesmap to satisfy validatorsinternal/server/unified.go: Integrated normalization inregisterToolsFromBackend()before storing tool metadataExample
Invalid schema from backend:
{ "name": "get_commit", "inputSchema": { "type": "object" } }Normalized automatically to:
{ "name": "get_commit", "inputSchema": { "type": "object", "properties": {} } }The middleware creates a copy to avoid mutating backend data and logs when normalization occurs for debugging.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.