Repository navigation
Run the authoring MCP server on the official MCP SDK (#846, stdio) - #850
Merged
Merged
Conversation
Adds proofs/private-requests: a packed-consumer site where Better Auth 1.7.6 on node:sqlite owns accounts, sessions and its tables, an operator adapter mounts its native handler and turns its verified session into the request principal and #840's request-bound `identity` capability, and ordinary function routes implement owner-private requests and one reviewer-only approval with parameterized SQL. The adapter refuses before serving on a missing secret, an uninitialized schema, an origin or basePath mismatch, telemetry left on, or a disabled rate limiter; forwards only an exact allowlist of Better Auth paths (disabledPaths misses parametric routes); and supplies the admitted client address for throttling in a header it always overwrites. test/private-requests.integration.ts (npm run test:proof) packs this checkout, installs it into a copy of the site, and exercises setup, explicit policy approval, provider/target refusals, declarative fixtures with audit ready, and the HTTP flow including foreign-owner and reviewer denial, malformed input, concurrent approval, cancellation, sign-out, revocation and throttling. Core: explain/report state that an extension mount's subpaths are provider-defined and not inspected, and list the capabilities a registration declares on the routes it protects. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion verify:workspaces and the workspace-integration job now run npm run test:proof after test:addons. The proof packs the already-built core with --ignore-scripts, like the other packaging tests, so prepare never rebuilds dist under another test. Changes under proofs/ or to the proof's test are high-impact, so they select that job on a pull request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t a shell On Windows the proof's behavior passed but teardown did not: separate t.after hooks run in registration order, so the temp site was removed while the served runtime still held its SQLite files (EBUSY), the server-stop hook never ran, and the live child kept the test process alive until the job timeout. One unwind stack now attempts every closer, newest first. npm runs through npm_execpath under this Node, so Windows needs no shell (DEP0190). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thoring (#834) bootstrap, context, explain, review, plan-feature and mcp accept the operator's --policy. A verified policy pins the host file to its reviewed projectSha256, so no PROJECT_SHA256 export is needed; bootstrap and context repeat it in their emitted commands and drop it from prerequisites. The MCP server verifies it once at startup and its run_validate/run_test/run_audit runners forward the same file, and run_tests uses its grants. No tool argument can name, create or change a policy; an edited project still invalidates it until the operator reviews and replaces the file. An empty, unparseable or missing policy file is now named (#847). bootstrap no longer offers the site's data/ directory for serving, and its serving hint says operator code, credentials and data stay outside the project. The #843 proof now runs its connected MCP workflow: run_validate and run_test pass on the packed site with only the operator's flags. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…text-834 # Conflicts: # proofs/private-requests/README.md # test/private-requests.integration.ts
Describe what the SDK now owns (lifecycle, framing, version negotiation, JSON-RPC errors) and what URLCode keeps (tools, argument validation, in-order calls, the 1 MiB bounds), and how malformed input, oversized messages, closing stdin and client cancellation behave. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 28, 2026
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 and change
First stage of #846: the local authoring MCP server (
urlcode mcp,packages/core/src/mcp.ts) now uses the official MCP TypeScript SDK,@modelcontextprotocol/server2.1.0 (MIT, the current stable v2 line). The handwritten protocol code is deleted: line framing, JSON-RPC parsing, lifecycle state,protocolVersionnegotiation and ping.URLCode keeps:
The application HTTP server in
packages/mcpis the second stage and is untouched here.Glue the SDK needed (why
mcp.tsis 230 lines, not shorter)Three behaviours needed URLCode-side glue, found by tests:
endand rejects later replies. A client that sends its requests and closes stdin, like the [Request]: Prove an embedded upstream auth provider in one local URLCode application #843 proof's MCP check and most test helpers, lost every reply that wasn't instant. Input now reaches the transport through a pipe the server ends only after every received call has answered.StdioServerTransportretriesthis._buffer.subarray is not a functionendlessly when aReadableyields strings, which pins a CPU core. Real stdin yields Buffers;serveMcpaccepts anyReadable, so chunks are normalized to Buffers. Worth reporting upstream.tools/callrequests concurrently.create_routefollowed byrun_validatethen raced over the same file, and parallel compiles hit the compiler's capacity guard. Calls now run one at a time in arrival order, which is what the old server did.Net:
mcp.tsgoes from 222 to 230 lines (+49/−45). Protocol ownership moved upstream, but owned lines did not shrink. The saving is in maintaining the protocol, not in lines.Behaviour changes (no compatibility kept, per #841)
initializeare answered instead of refused with-32002; a secondinitializeis accepted.{}and invalid UTF-8 lines are ignored and the session continues; they no longer get-32700/-32600replies.isErrorresult naming the limit (was a-32603error).id(byReplyId).serverInfo.versionstill comes from one literal thatrelease:bumprewrites; its regex now targetsnew Server({name:'urlcode',version:…}).Legacy tool-name aliases (
recipes_showand others) and the deprecatedtargetargument alias are not removed here, to keep this reviewable. They are candidates for deletion under the no-compatibility decision.Verification
test/mcp-sdk-client.test.tsuses the official@modelcontextprotocol/client2.1.0 (dev dependency) to spawnurlcode mcpover stdio. It checks:structuredContent;-32602for bad arguments, an unknown tool and authoring tools without the flag, each naming the problem;isErrortool failure;run_validaterejecting while the session keeps working.test/mcp.test.ts: the three tests pinning handwritten framing are rewritten to the new rules (malformed frames ignored, oversized ends the session, a message split across bytes inside a UTF-8 character still parses).npm run verify: exit 0, corenpm test1,100/1,100, workspace suites,audit:packages,test:addons,test:proof(its MCP runner check goes through the new server).npm run test:packagepasses.@modelcontextprotocol/server,@modelcontextprotocol/core,zod), about 15.7 MiB installed (server 6.3, core 1.3, zod 8.0). Importing the SDK costs about 36 ms; importingdist/mcp.jstakes about 165 ms.better-authin the proof site already bringszod4, so a site using it shares one copy.Compatibility and security
No YAML, schema, CLI flag or tool-surface change. Protocol edge behaviour changed as listed above.
Authority is unchanged: tool gating (
--host-file,--allow-authoring,--policy), runner environments and project confinement are URLCode code paths the SDK does not touch.New runtime dependencies are pinned exactly; the SDK's optional validators and HTTP pieces are not imported.
Changes match the documented portable contract; docs/examples are updated where needed.
Relevant tests and package checks pass, or limitations are explained above.
No credentials, customer data or private project material are included.
Runtime/starter changes remain aligned where applicable.
🤖 Generated with Claude Code