Repository navigation
feat(mcp): add a declarative MCP tool server extension package - #625
Merged
Merged
Conversation
Adds @jimhoyd/urlcode-mcp, a new optional operator-installed extension following the packages/forms and packages/store conventions: the extension owns JSON-RPC 2.0 framing, protocol version negotiation, exact request-id round-tripping, and initialize/ping/tools-list/tools-call dispatch, while project YAML declares only bounded tools (name, description, a request.body.schema-shaped input schema, and a trusted project handler). Fixes the specific defect the evidence in #573 reported (a hand-written 232-line JSON-RPC implementation that used something other than the actual client-supplied JSON-RPC id as the response id): the response id is always read verbatim from the request's own id field, of every JSON-RPC-legal shape, and a message with no id (a notification) never gets a response. Tool input validation reuses core's bounded body-schema validator instead of reimplementing it: packages/core/src/body-schema.ts is now also published as the public @jimhoyd/urlcode/body-schema subpath (assertBodySchema, bodySchemaIssues, bodySchemaLine), the same code request.body.schema itself runs. Tool handlers are trusted project code loaded via core's existing loadExtensionHooks/functionFile machinery, matching forms' onSubmit hook. Core's dependency boundary is preserved (core never imports packages/mcp); the new package resolves core through the same file:../.. workspace link scripts/check-workspace-links.ts enforces. mcp is wired into verify:workspaces, the package-audit budget, and the CI workspace-verify/ workspace-integration matrices (scripts/ci-plan.ts, .github/workflows/ci.yml), but is deliberately left out of the signed extension-bundles/init --with composition system and the six-package pack-sources reproducible-build set: like forms and store initially, it ships private and workspace-only. Deferred (documented in packages/mcp/README.md "What this does not implement" and tracked as follow-up issues): the Streamable HTTP transport's optional GET/SSE stream and Mcp-Session-Id resumption, JSON-RPC batching (removed by the 2025-06-18 MCP revision and refused outright here), resources/prompts primitives, tool outputSchema/structuredContent, and tools/list pagination. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 24, 2026
[Request]: promote @jimhoyd/urlcode-mcp to init --with and the signed extension-bundles release
#629
Closed
# Conflicts: # llms-full.txt # package.json # scripts/ci-plan.ts # test/ci-release.test.ts
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
Implements the triage decision on #573: a new optional operator-installed extension,
@jimhoyd/urlcode-mcp, rather than a core route handler. Follows thepackages/forms/packages/storeconventions (schema,RuntimeExtensionactivation, own README/SECURITY.md/package.json).initialize/ping/tools/list/tools/calldispatch and error codes. Project YAML declares only bounded tools (name, description, arequest.body.schema-shaped input schema, and a trusted project handler) — no JSON-RPC mechanics in project config.idhere is always read verbatim from the request's ownidfield (any JSON-RPC-legal string/integer, or a notification with noidat all getting no response), covered explicitly by a dedicated test.packages/core/src/body-schema.tsis now also published as the public@jimhoyd/urlcode/body-schemasubpath (assertBodySchema,bodySchemaIssues,bodySchemaLine) — the exact coderequest.body.schemaitself runs.loadExtensionHooks/functionFilemachinery (the same mechanismforms'onSubmithook uses), rather than a second dynamic-import/path-resolution implementation.packages/mcp(scripts/check-core-boundaries.tspasses), and the new package resolves core through the samefile:../..workspace linkscripts/check-workspace-links.tsenforces.Design decisions
mount,serverName/serverVersionand boundedtoolsmap (mirrors howstorelets one extension serve multiple mounted collections).GETon the mount answers405(the MCP spec's own guidance when a server doesn't offer the optional SSE stream).initialize,ping,tools/list,tools/call, plus accepting thenotifications/initializednotification. Standard JSON-RPC error codes (-32700/-32600/-32601/-32602/-32603).isError: truetool result, and the real error is handed to an optional operatoronToolError(error, {server, tool})callback (best-effort; never affects the response). This is the explicit host-owned-error mechanism the triage decision called for.packages/mcp/README.md"What this does not implement", and to be filed as follow-up issues): the Streamable HTTP transport's optional GET/SSE stream andMcp-Session-Idresumption, JSON-RPC batching (removed by the 2025-06-18 MCP revision and refused outright here), theresources/promptsprimitives, tooloutputSchema/structuredContent, andtools/listpagination. This keeps the tool surface minimal ("MCP over HTTP becomes declarative", not a full-featured MCP server) as directed.formsandstorebefore their promotion,@jimhoyd/urlcode-mcpshipsprivate: true, workspace-only (no npm, no signedextension-bundles@v…release, noinit --withscaffold). It's wired intoverify:workspaces, the package-audit budget, and the CIworkspace-verify/workspace-integrationmatrices, but intentionally left out of the signed-bundle composition system and the six-packagepack-sourcesreproducible-build set — expanding those is a separate, larger decision out of this PR's scope.CI wiring
package.json:verify:workspacesandverify:workspace-integrationnow include@jimhoyd/urlcode-mcp.scripts/ci-plan.ts:mcpadded to the workspace package matrix, dependency maps and path-classification regexes (no other package depends on it; it depends only on core)..github/workflows/ci.yml: theworkspace-integrationjob's build step now builds@jimhoyd/urlcode-mcptoo.scripts/package-audit.ts: budget entry for the new package (measured well under budget: ~13.7 KB packed / ~44 KB unpacked vs. a 45 KB / 140 KB budget).test/ci-release.test.ts: updated to match the above.Tests
packages/mcp/test/mcp.test.ts: 11 focused interoperability tests — a real HTTP round trip viastartServer, coveringinitialize(protocol negotiation, exact request-id fidelity across every JSON-RPC-legal id shape),notifications/initialized(202, no body),tools/list,tools/call(success, schema-validation-32602with structured issues, unknown-tool-32602, a thrown handler becoming a genericisErrorresult while the real error reachesonToolError), protocol-level failures (-32700parse error,-32600invalid envelope/batching,-32601unknown method), and transport-level rules (content-type, method, size, sub-path).npm run typecheck,npm run build,npm run lint,npm run check(docs + code) all pass at the root.npm run verifyinpackages/mcppasses (typecheck, build, test).npm run audit:packagespasses for all seven workspace packages.test/extensions.test.ts,test/http-policy.test.tsandtest/ci-release.test.tssuites directly (34 + N + 23 tests, all passing) to confirm the newbody-schemaexport and CI-plan changes don't regress existing extension/body-schema/CI-classification behavior.What's left
tools/listpagination,outputSchema/structuredContent,resources/prompts) and [Request]: promote @jimhoyd/urlcode-mcp to init --with and the signed extension-bundles release #629 (init --with mcpscaffold + signedextension-bundles@v…distribution).mcpto the signedextension-bundles@v…release set or thepack-sourcessix-package reproducible-build proof; that's an explicit, separate promotion decision (same statusforms/storestarted from).Refs #573
🤖 Generated with Claude Code