Repository navigation
Fix plugin MCP names and isolate invalid schemas - #988
Conversation
🦋 Changeset detectedLatest commit: 581207c The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Scope checkThis PR changes 683 lines across 26 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
upgrade-emdash
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
|
/review |
There was a problem hiding this comment.
Solid implementation overall — capability gating, hex-encoded tool names to avoid plugin-id collisions, admin scope + ADMIN role enforced before dispatch, and good test coverage (capability filter, sandbox-not-loaded guard, scope check, ID collision). The delegation to handlePluginApiRoute is a clean reuse strategy.
Findings are mostly DX/footgun concerns at the definePlugin boundary plus a couple of manifest cross-validation gaps. No correctness or auth bugs that block merge.
Notes:
- Trusted (
definePlugin) plugins skip several validations that sandboxed plugins get frompluginManifestSchema— tool-name shape, route existence, and capability declaration. Silent filtering vs. early errors. getPluginRouteMetafalls back to{ public: false }for any route on an existing sandboxed plugin, so MCP tools pointing at nonexistent sandboxed routes register fine and fail at call time. The catch-all route has the same behavior, so this matches existing semantics — flagging only as DX context.- One coverage gap: no test for
requireRole(ADMIN)rejecting a non-admin user holding anadmin-scoped token (the defense-in-depth branch). - Sandboxed plugin MCP tools have no input schema in
ManifestMcpToolEntry, so they all fall back toz.record(z.string(), z.unknown())— MCP clients lose introspection. Future work, but worth tracking.
|
Review submitted successfully (review ID 4270626524) with 6 line-anchored comments and a summary body. Key findings:
No blocking issues — auth/correctness paths check out. |
ascorbic
left a comment
There was a problem hiding this comment.
Excellent work. One thing that would be good would be if there was a way we could provide a schema for tool inputs so we can validate and describe them. While we can't serialise a Zod schema directly, maybe a JSON schema would work?
Can you include docs in the PR too, as it will also make it easier to review.
Agreed on both. I’ll add docs in this PR, and I’ll look at adding a constrained I’ll keep the JSON Schema subset conservative: object root, No |
|
Done. I added docs for plugin MCP tools and added manifest-side |
|
/review |
There was a problem hiding this comment.
Reviewing on top of the existing rounds (ask-bonk + ascorbic). Most of the substantive concerns from the earlier passes — capability cross-check, route cross-check, tool-name shape validation, JSON Schema introspection, dual-check coverage, admin-only intent comment, runtime dedup — have been addressed. A few remaining things worth a look, all DX/robustness rather than auth/correctness:
- One bad
inputSchemafrom a trusted plugin can take down the whole MCP endpoint becausejsonSchemaObjectToZodis called inline duringcreateMcpServerand has no isolation. Trusted plugins skip the Zod manifest validation that sandboxed plugins get, so the JSON Schema is unvalidated untilz.fromJSONSchemathrows. pluginToolNamecollision detection looks for__within a single segment, but two distinct valid scoped IDs can still collapse to the same generated name when a dash sits on either side of the slash boundary (@a-/bvs@a/-bboth →a___b__foo). Narrow but real.- No dedicated unit test file for
pluginToolName— the integration tests cover the happy paths but the ambiguous-segment / hash-fallback branches aren't directly exercised.
No blocking issues from me.
|
Review submitted successfully (review ID 4303523122) with three line-anchored comments and a summary body. Key findings (all non-blocking, DX/robustness rather than auth/correctness):
Prior reviewers' concerns (capability/route cross-validation, JSON Schema introspection, dual-check coverage, runtime dedup, admin-only intent comment, real-implementation testing) all look addressed. |
42a37df to
581207c
Compare
|
Thanks for the detailed review @danielmlr! Addressed these in Both plugin API endpoints now return the generated MCP name, and the admin consent list displays it. Schema conversion is guarded in both loading paths, with conversion still lazy for built plugins. The collision handling, regression coverage, changeset, and documentation are updated. Local build, lint, typecheck, docs build, and relevant tests passed. English and Arabic screenshots are in the PR description. Ready for another look |
danielmlr
left a comment
There was a problem hiding this comment.
Thanks for sticking with this one, Mason, and for rebuilding it on top of the MCP support that landed in the meantime.
Everything from my last review is covered.
What does this PR do?
Scoped plugin IDs produced MCP names containing
@and/. This fixes the generated names and displays them in the admin consent list. Duplicate generated names are skipped with a warning, and unreadable serialized schemas no longer prevent other tools from loading in either the sandboxed or built-plugin path.Existing MCP-safe plugin IDs keep their names. The changeset explains how to update saved calls using old scoped names. Addresses the latest review on the plugin MCP support already in main.
Type of change
Your connection to this change
This continues my existing plugin-MCP contribution in #988 and addresses the specific fixes requested in its maintainer review. I reviewed the complete replacement commit before approving its submission.
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.No new translatable strings: the changed display is an MCP identifier supplied by the API. Arabic RTL was checked. A feature design is not applicable to this bug fix.
AI assistance disclosure
Screenshots / test output
Local validation for
581207cf1, based on upstream9f7eb2288:The screenshots use the real PluginManager component and styles. The before fixture omits the new API field to reproduce the legacy display. The after fixtures show the server-generated name in English and Arabic, with MCP consent off.
Hosted CI is reported separately by GitHub.