Make MCP working-directory validation regex-portable - #80
Open
jonathanhefner wants to merge 1 commit into
Open
Conversation
Replace the 1.1.0 `cwd` regular expression with direct `anyOf`
alternatives for the forms defined by §7.2.1. Use `const` for exact
`${PLUGIN_ROOT}` and `${PLUGIN_DATA}` values and simple prefix patterns
for rooted paths so validators do not depend on noncapturing groups or
engine-specific `$` behavior.
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.
Problem
The
mcp.jsonschema validatescwdwith one regular expression containing noncapturing groups and$alternatives. Noncapturing groups are outside the portable regular-expression subset recommended by JSON Schema, and$has different end-of-string behavior across regular-expression engines.In particular, Python-style engines allow
$to match before a terminal newline. They therefore accept${PLUGIN_ROOT}\nand${PLUGIN_DATA}\n, although neither value has one of the forms required by §7.2.1.Resolution
Replace the single expression with
anyOfalternatives that represent the accepted forms directly:./.${PLUGIN_ROOT}.${PLUGIN_ROOT}/.${PLUGIN_DATA}.${PLUGIN_DATA}/.Use
constfor the exact placeholder values and simple start-anchored patterns for the prefix forms. This removes both noncapturing groups and end anchors while preserving thecwdconstraints defined by §7.2.1.anyOfexpresses the actual requirement: a value must have at least one accepted form. The alternatives happen to be mutually exclusive, but it is not a separate contract to enforce withoneOf.The correction applies to the 1.1.0 working draft. The published 1.0.0 schema retains its canonical contents.
Validation
An AI agent:
schemas/1.1.0/mcp.schema.jsonas Draft 2020-12 with Ajv.Follow-up to #79.