fix(schema): make tool schemas provider compatible#50
Open
franktronics wants to merge 1 commit into
Open
Conversation
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.
Summary
Fix MCP tool schema compatibility with providers that strictly validate JSON Schema before accepting tools.
This covers schema failures such as:
regex lookaround is not supportedon email fieldspatternerrors on password fieldsresources/listorprompts/listand receivingMethod not foundChanges
patternkeywords from published tool input schemas.pattern$schemakeys are strippedresources/list,resources/templates/list, andprompts/listsucceedRelated work
This builds on the same compatibility issue addressed in #47.
PR #47 removes the known provider-incompatible email lookaround patterns from generated schemas. This PR keeps that fix and generalizes the protection at the MCP
tools/listboundary by stripping allpatternkeywords from published input schemas, while preserving runtime Zod validation.That also covers additional provider failures, such as password regex patterns rejected by DeepSeek-compatible providers.
Why
#47 fixed the known email lookaround regex issue, but other generated
patternkeywords can still be rejected by strict providers. For example, DeepSeek rejects password patterns such asdatabasePassword.pattern.Because these schemas are generated from OpenAPI and consumed by multiple providers with different JSON Schema subsets, the safer MCP boundary is to publish provider-compatible schemas and keep strict validation on the server side.
Testing
npx --yes pnpm@10.24.0 test -- src/server.test.tsnpx --yes pnpm@10.24.0 type-checknpx --yes pnpm@10.24.0 lintnpx --yes pnpm@10.24.0 buildManual smoke check:
tools/listreturns 524 tools0patternkeywordsresources/listreturns[]resources/templates/listreturns[]prompts/listreturns[]