Match mcp-name marker exactly in PyPI/NuGet ownership checks#1320
Open
koriyoshi2041 wants to merge 1 commit into
Open
Match mcp-name marker exactly in PyPI/NuGet ownership checks#1320koriyoshi2041 wants to merge 1 commit into
koriyoshi2041 wants to merge 1 commit into
Conversation
PyPI and NuGet ownership validation accepted the "mcp-name: <serverName>" marker via a substring check, so a README declaring a longer name that has the server name as a prefix (e.g. "mcp-name: io.github.alice/foo-evil" when validating "io.github.alice/foo") incorrectly passed. The docs require the $SERVER_NAME portion to match exactly, and npm already compares its mcpName field with ==. Add a shared ReadmeDeclaresMCPName helper that requires the matched name to end at a non-name character or end of content, and use it from both the PyPI and NuGet validators. Includes table-driven tests for the documented marker formats and the prefix cases.
12ff5d8 to
3e6daa9
Compare
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.
PyPI and NuGet ownership validation check for the
mcp-name: <serverName>marker with a plain substring match:Because nothing anchors the end of
serverName, a README that declares a longer name which merely has the server name as a prefix also passes. For example, validatingio.github.alice/foosucceeds against a README containing:That contradicts the documented contract — "the
$SERVER_NAMEportion MUST match the server name" indocs/modelcontextprotocol-io/package-types.mdx— and is inconsistent with npm, which compares themcpNamefield with==.This adds a shared
readmeDeclaresMCPNamehelper that findsmcp-name: <serverName>and requires the matched name to end at a non-name character (per the server-name grammar[a-zA-Z0-9._/-]) or at end of content. Both the documented HTML-comment form (<!-- mcp-name: name -->) and a baremcp-name: nameline still pass; prefix-only matches no longer do. PyPI and NuGet both use it.Added
mcpname_test.gowith table-driven cases (documented formats, end-of-content, hyphen/dot-suffixed longer names, and a second-occurrence exact match). The existingregistriespackage tests still pass.