MCP Spec Compliant Strict JSON Schema Validation (Draft 2020-12) for Registration#2645
Merged
crivetimihai merged 2 commits intomainfrom Feb 7, 2026
Merged
Conversation
a0511c6 to
97532ac
Compare
Member
|
Good spec compliance improvement. Defaulting to Draft 2020-12 when LGTM — ready to merge. |
…prompt registration Closes #2348 Add JSON_SCHEMA_VALIDATION_STRICT config option (default: true) to reject invalid JSON schemas during tool/prompt registration. When enabled, invalid schemas cause a 400 error instead of being silently persisted with a warning log. Default to Draft 2020-12 validator when $schema field is missing, per MCP spec. Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
- Remove unrelated VALIDATION_STRICT=true additions from docker-compose files
- Remove unrelated comment on existing validation_strict field in config.py
- Fix typo in configuration.md ("may valid schemas may" -> "may")
- Restore trailing newline in config.schema.json files
- Add tests for non-strict mode (json_schema_validation_strict=False)
- Add test for Draft 2020-12 default validator selection
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
97532ac to
f1d6ee1
Compare
crivetimihai
approved these changes
Feb 7, 2026
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
…Registration (IBM#2645) * feat: add strict JSON Schema validation (Draft 2020-12) for tool and prompt registration Closes IBM#2348 Add JSON_SCHEMA_VALIDATION_STRICT config option (default: true) to reject invalid JSON schemas during tool/prompt registration. When enabled, invalid schemas cause a 400 error instead of being silently persisted with a warning log. Default to Draft 2020-12 validator when $schema field is missing, per MCP spec. Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * fix: remove unrelated changes, fix typo, add missing test coverage - Remove unrelated VALIDATION_STRICT=true additions from docker-compose files - Remove unrelated comment on existing validation_strict field in config.py - Fix typo in configuration.md ("may valid schemas may" -> "may") - Restore trailing newline in config.schema.json files - Add tests for non-strict mode (json_schema_validation_strict=False) - Add test for Draft 2020-12 default validator selection Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
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.
🐛 Bug-fix PR
Closes #2348
📌 Summary
Fixed an issue where invalid JSON schemas for tools and prompts were being silently persisted with only a warning log, leading to potential runtime errors in downstream components.
Key Changes:
$schemafield is now explicitly set to Draft 2020-12, as mandated by the MCP Schema Specification.JSON_SCHEMA_VALIDATION_STRICThas been added (defaults toTrue) to control this behavior, with valid documentation.🔁 Reproduction Steps
{"type": "object", "properties": {"p": {"type": "UNKNOWN_TYPE"}}}).Invalid tool input schema: ....🐞 Root Cause
validate_tool_schemaandvalidate_prompt_schemadatabase listeners caughtjsonschema.exceptions.SchemaErrorbut effectively ignored it by only logging a warning and allowing the transaction to commit.💡 Fix Description
json_schema_validation_strictin Settings to allow opting out of strict mode (for legacy compatibility).mcpgateway/db.pyto:settings.json_schema_validation_strict. IfTrue,SchemaErroris caught and re-raised asValueError, aborting the DB transaction.jsonschema.Draft202012Validatorif$schemais missing.🧪 Verification
make lintmake testmake coverage📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)