Repository navigation
Pure proxy: tools from the instance after sign-in; a snapshot only for directories - #1
Conversation
Replaces the first version's design notes. The package reads the tool list from the instance's public GET /mcp/catalog (or Bytebase Cloud's, when no BYTEBASE_URL is set) and forwards tool calls; it keeps no copy of Bytebase's tools. Covers every proxy state, the Cloud fallback rule, instructions, token storage and locking across processes, client identity, versioning, deletions and a two-slice plan. Reviewed in four rounds. Server side: bytebase docs/design/mcp-public-catalog.md. BYT-10055. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The proxy now reads <BYTEBASE_URL>/mcp/catalog at startup, or Bytebase Cloud's catalog when no instance is configured, and answers initialize and tools/list from it. It keeps no copy of Bytebase's tools. - States S1, S2, S4 and S5 from docs/DESIGN.md: instructions per state, with the instance's form paragraph for clients without forms and the package's form sentence where the instance's text cannot be read. - A catalog counts only as JSON with a valid tool list, because an instance without the route answers 200 with the console page; the protected-resource document tells an older Bytebase from another server. - A configured proxy never contacts Cloud; an unconfigured one reads only Cloud's catalog and runs nothing. - While there is no tool list, the catalog is retried with backoff and tools/list_changed announces it; once a session opens, its list wins. - Deleted src/tools.json, src/tools.ts, scripts/sync-tools.mjs and scripts/render-readme.mjs, and the fallback instructions; the README no longer lists tools and no longer calls Cursor or Claude Desktop local-command-only. Tests drive the built server over stdio against a fake Bytebase (test/fake-upstream.mjs), one per state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- S3: a stored sign-in opens the session inside initialize, without waiting for the lock or asking the user, and the instance's own instructions pass through verbatim. S4 starts its sign-in after initialized and announces the tools when the session opens. - D5: a call cancelled before its session opens is never sent; the proxy sets no timeout of its own; a call is resent only after an error showing the instance never received it. - D6: one OAuth client per (instance, client application), registered as "<client> via Bytebase MCP", and the client's own clientInfo is forwarded, so consent and audit show the real client. - D7: one sign-in file per (instance, client), written only under its lock (a directory created already holding its owner's PID, abandoned when that process is gone). Opening a session holds the lock through sign-in; a refresh holds it until its result is on disk, and uses newer tokens on disk instead of refreshing again. The PKCE verifier stays in memory, a refused credential is deleted only if the file still holds it, and the browser leg holds a machine-wide lock on the callback port. The sign-in URL is printed only once the callback listener is up. - D9: the commands are serve, status and logout; login and whoami are gone. Tests in test/sessions.test.mjs drive two proxy processes against the fake Bytebase, which now has an OAuth server with single-use refresh tokens and an MCP endpoint: sign-in as the real client, S3, S4, the refresh race, the first-sign-in race, cancellation, status and logout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The public catalog route (bytebase/bytebase#22184) is dropped: its only consumer was a directory scan of an unconfigured package. A tool-list snapshot now ships in the package for that case only; a configured proxy lists only its instance's tools, empty until sign-in, with the client's cursors passed through. Reviewed in five rounds (persona readers, check readers, codex adversarial). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sers - No URL (S1): lists the bundled snapshot and its instructions after a "no instance" note; tool calls return the fix. A configured proxy never reads the snapshot. - Configured without a session (S3, S4): an empty tool list, instructions named by a probe of the instance's protected-resource document, the package's form sentence for clients without forms, and a sign-in right after initialized; tools are announced when the session opens. The probe runs alongside a stored-sign-in opening, so a slow warm start no longer reports the instance as unreachable. - A background sign-in waits out initialize's opening, which may not sign in, and signs in itself if that opening failed (stale credentials answered after the initialize bound used to leave no browser prompt). - Removed src/catalog.ts and the catalog paths; status reports whether the URL answers as Bytebase and counts only sign-ins that hold tokens. - Restored src/tools.ts, scripts/sync-tools.mjs (ported to the session code) and scripts/render-readme.mjs, with the copy of the snapshot into dist/. Reseeded src/tools.json from Bytebase main at 9daf6b307f (13 tools, current instructions), and the README's tools table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tools/list passes the client's cursor to the session and the instance's nextCursor back, so the instance pages its own list. sync-tools reads every page. - A tools/list after the instance ended the session (Bytebase does after an hour idle) reopens it with the stored sign-in and asks once more; a tools/list that still cannot be answered is a JSON-RPC error with the reason, since tools/list has no error result. - A configured proxy whose instance cannot be reached at startup retries with backoff (capped at 5 minutes) and opens the browser only once the instance answers; a sign-in that fails or times out is not restarted. Tests: a fake that pages one tool at a time, a fake that forgets its sessions, a fake that goes away, and one that starts after the proxy. The retry loop is mutation-checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tool call during an outage resets the session, and tools/list then answered an empty list with no attempt to reconnect, so the client stayed without tools after Bytebase recovered. Now only a proxy that has never signed in lists nothing (D2); with a stored sign-in, tools/list reopens the session without a browser (D5), and reports a JSON-RPC error with the reason while the instance is still down (rule 4), so the client keeps its last good list. Found by the Codex stop-time review. The test takes the fake down (connections refused, tokens kept), makes a failing call, and brings it back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/list reopened a dropped session through Upstream.open, which joins any opening in progress; when that opening was the interactive one, waiting on a browser sign-in or another process's lock, tools/list waited for minutes and the client timed out. Now tools/list answers an empty list while a sign-in is under way (D2: no session yet; the tools are announced when it opens), and a quiet reopen with the stored sign-in is bounded at 10 seconds, after which it answers a JSON-RPC error with the reason. Found by the Codex stop-time review. Tests hold the sign-in's lock from another live process: one during startup (empty list at once, tools announced once the lock is released), one after an outage (error within the bound). The bound is mutation-checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When tools/list gave up after its bound, the reopen underneath carried on and still sent that tools/list to Bytebase once the session opened, so every timed-out request left a stray call queued. The bound now aborts the request's signal: the reopen still completes, but the request is never sent. Found by the Codex stop-time review; the bound test now counts the tools/list requests that reach the fake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tools/list that gives up after its bound answers "still connecting" while the reconnect carries on. Nothing then told the client to list again, so a client that never re-lists by itself stayed on its last list. The proxy now follows that reconnect and sends tools/list_changed once the session opens (D2), once per wait. The bound test waits for the notification after releasing the held lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit sent tools/list_changed whenever tools/list hit its bound. With a session already open and Bytebase merely slow, the "reopen" resolved at once, so every slow list was announced, the client re-listed, and the cycle never ended. Now only a wait spent reopening a dropped session ends in an announcement. Found by the Codex stop-time review; a test with a slow fake tools/list checks that no announcement follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Opening a session when the instance cannot be reached at startup was the proxy's only unbounded retry. It now waits 1s doubling to a 5-minute ceiling, ten retries in all (about 14 minutes), then logs and stops until the client restarts. D5 says so. The schedule is a pure function (src/retry.ts), unit-tested in test/config.test.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A deleted sign-in file left its refresh token valid on Bytebase for up to 30 days, so a copy of the file (a backup, a synced config folder) kept working. logout now revokes each stored refresh token at the revocation endpoint the instance advertises, then deletes the sign-in under its own lock, so it never races a refresh. If the instance cannot be reached it still deletes and says the grant expires on its own. It does not sign anyone out of the Bytebase console. D9 and the README say so, and name logout as the way to switch accounts. The fake Bytebase now serves revocation; the status/logout test checks the stored refresh token was revoked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- logout: the discovery and revoke requests had no timeout, so an instance that accepted the connection and never answered kept logout from deleting the local credentials. Each request now waits at most 5 seconds; the sign-ins are deleted either way (D9). Found by the Codex stop-time review. - After Bytebase revokes the grant mid-session (its reauthorize tool, the account-switch path), the proxy refused the SDK's sign-in, as it must outside an opening, but kept the dead session, so every later call failed the same way and no browser ever opened. A refused sign-in in an open session now counts as never received (Bytebase answered 401, the call did not run): the session is dropped, reopened with a browser sign-in, and the call is sent. D7 says so. Tests: a revoke endpoint that never answers, and a grant revoked while a session is open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reconnecting after a never-received error (a revoked grant, an outage, an ended session) closed the old session at once, which aborted any other call still in flight on it, one Bytebase had already accepted and may have run. The proxy reported an error, and a retried write would run twice. Now the old session is retired: new requests reconnect at once, calls in flight on it finish and return their results, and it closes after the last of them. The session retired is the one the request failed on, never one another call already reopened. reset() still closes at once, for shutdown. D5 says so. Found by the Codex stop-time review. The test revokes the grant while a slow call is in flight, signs in again for a second call, and checks the first returns its result and was sent once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Whether the provider may start a browser sign-in was one flag on the shared provider, set while any session opened. A retired session that lived on for its in-flight calls could run its own OAuth attempt in that window (its event stream reconnecting after a revoke): it was allowed to sign in too, opening a second tab and overwriting the PKCE verifier the real sign-in needed, and the failure cut off its in-flight call. D7 says a sign-in starts only while a session is being opened; the permission now travels with that opening's own async context and ends with it, so a retired session's attempts are refused. Found by the Codex stop-time review. The fake ends open event streams on a revoke; the in-flight test holds the browser step and requires a single sign-in and the accepted call's result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous commit stopped a retired session from opening a browser, but the SDK saves a new PKCE verifier and asks for a new state before it asks to redirect, and both lived on the shared provider. A retired session's refused attempt still overwrote the verifier the active sign-in needed, so Bytebase rejected its code exchange. The verifier, state and pending callback now belong to the opening's permit, and nothing outside an opening in progress can write them. Found by the Codex stop-time review. The fake Bytebase now verifies PKCE as Bytebase does, which the in-flight test needed to see this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The directory holds OAuth registrations and refresh tokens: credentials, not configuration. Under ~/.config they sat where people often sync or keep dotfile repositories. The default is now ~/.bytebase-mcp, like ~/.aws or mcp-remote's ~/.mcp-auth; BYTEBASE_MCP_HOME still overrides it, and XDG_CONFIG_HOME no longer applies. Nothing is published, so nothing migrates. D7, the README, the CLI help and server.json say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Peter's test in Claude Code: an approval form vanished after about a minute and the call failed with "MCP error -32001: Request timed out". Category: D5's "the proxy sets no timeout of its own" was stated for the client-to-Bytebase direction only, so the Bytebase-to-client direction was missed. D5 now lists every forwarded request by direction with its timeout and who can cancel it, under one rule: a request belongs to its sender; the proxy adds no deadline and no cancellation and passes the sender's cancellation on. - A form from Bytebase is forwarded with no deadline (the SDK default was 60 seconds; Bytebase allows 10 minutes, confirmationLifetime). - When Bytebase withdraws a form, the cancellation reaches the client, which takes the form down. The upstream handler now passes its signal. - The proxy numbers its requests to the client from 1. The SDK numbers from 0, and its own cancellation handler ignores request ID 0 (`if (!requestId) return`), so a client on this SDK would have kept the first withdrawn form up. Bytebase's Go SDK already numbers from 1. Tests (through the stdio seam): a form answered after 62 seconds reaches the fake Bytebase (the one deliberately slow test: the SDK's default cannot be shortened from outside), and a form the fake withdraws is taken down in the client. The fake streams responses for these tests, sends the form within the call as Bytebase does, and numbers requests from 1 like Bytebase. Mutation-checked: dropping the signal or the ID change fails the withdrawal test; before the fix the slow test failed at 60 seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README is what npm, Glama and the MCP Registry show to people installing the package, so its Development section is now two lines and a link. CONTRIBUTING.md holds build and test, testing at four levels (npm test, the directory view in the MCP Inspector, scripts/check-live.mjs against a real instance, a real client from a packed tarball), which Bytebase build can complete sign-in (the consent page needs the bundled frontend), launching a tarball (`npx -y --package=<abs path>`; a bare absolute path fails with "Permission denied"), keeping test sign-ins apart with BYTEBASE_MCP_HOME, a manual checklist, and the snapshot and release steps moved from the README. Each command was run: the two npx forms from another folder, re-packing a different tarball at the same path (npx installs the new one; npm 11.6.1), the Inspector's CLI mode, and status/logout. check-live.mjs no longer labels its first count "bundled": a configured, signed-out server lists nothing until sign-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CONTRIBUTING.md and check-live.mjs said the first call opens the browser sign-in. A configured proxy without a session opens it right after the client initializes (D5); the first call only waits for it. Found by the Codex stop-time review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same correction as the previous commit, in the Setup section users read on npm and Glama. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After Bytebase's reauthorize, the proxy signs in again on the next call, but the client keeps the instructions naming the old account until it reinitializes. A successful reauthorize result now gets one more text item telling the user to reconnect this server: that opens the sign-in and refreshes the instructions. Bytebase's own text is kept, and every other result passes through unchanged. Rule 4 names this as the one addition to a forwarded result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After reauthorize, a reconnect starts signed out (the stored tokens are revoked), and a signed-out start carries no account line (D4), so the account signed in as is named only from the start after that. The note promised it one reconnect too early. It now says what reconnecting fixes: the instructions stop naming the previous account. Rule 4 says the same. Found by the Codex stop-time review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The note said the client's instructions still name the previous account. That holds only when the session started signed in (S2), with Bytebase's own instructions; after a signed-out start the instructions named no account. The proxy now remembers which start it had and adds that sentence only after a signed-in start; the reconnect advice stays for every successful reauthorize. Rule 4 says so. Found by the Codex stop-time review; a test covers the signed-out start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Read through
Two more that I'd settle before publishing to npm (neither blocks the merge):
|
- --help: sign-in starts when the server starts, not on the first tool call. - --help and README: status shows the instance and the stored sign-ins; it has no tool list. - Pin @modelcontextprotocol/sdk to 1.32.2: server.ts relies on the private _oninitialize and _requestMessageId. - openInBrowser hands only http(s) URLs to the OS; the URL is still printed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Items 1-4 above are fixed in #2, stacked on this branch (base
Items 5-7 are untouched and left for you. |
|
Thanks, Adela. All seven hold up. Items 1–4 land through #2 (approved, and stacked into this branch). The rest:
|
Three versions of the note each claimed something about the client's instructions that the proxy cannot fully know: older Bytebase releases send no instructions, so even a signed-in start may name no account. The sentence is deleted; the note keeps the advice that is always right: reconnect this server and sign in as the account you want. Rule 4 says why the note makes no claim about the instructions. Found by the Codex stop-time review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r, 3.25.0 snapshot - States/D5: a gateway's 502, 503 or 504 at startup reads as unreachable, so the note no longer blames BYTEBASE_URL and the startup sign-in retries instead of giving up (a first run had no tools until a client restart). - D5: the sign-in URL is opened only if http(s), and on Windows through rundll32 rather than cmd, which would run what a | or ^ in the URL introduces. The choice is a pure browserCommand with a unit test; the README says Windows is untested and where to find the printed URL. - D3: the snapshot comes from the latest release. Regenerated from 3.25.0: the same 13 tools and instructions as before, now labeled with the release. - --help: logout revokes, then forgets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3fe427b to
2e8c7e2
Compare
D5's unreachable covers the SDK's discovery errors too, which carry the status only in their text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
D5: only an opening that has not opened the browser is retried. After it has, any failure, a gateway's 5xx or a network error included, is a failed sign-in, so the user is not sent a second browser tab. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adela-bytebase
left a comment
There was a problem hiding this comment.
Re-read at 6a90232. All seven items are addressed, CI is green, and build plus all 37 tests pass locally. Windows is still untested, as the README now says.
|
Heads-up: merging this triggered Cause: The repo being private is not what failed here. Per the npm docs, trusted publishing works from a private repo; only provenance is not generated. But the workflow passes To get it published (needs an npm
One timing rule from the docs: a new trusted publisher configuration must complete its first successful publish within 2 days or it expires, so it's best set up right before publishing. |
Design doc and implementation for BYT-10055. Squash on merge: the history includes a superseded first revision.
A configured proxy gets every tool and instruction from its Bytebase instance, after sign-in. A snapshot of the tool list ships in the package for one purpose, letting MCP directories (Glama) list Bytebase when no instance is configured, and a configured proxy never reads it.
This replaces the first version's bundled
src/tools.json, which every user saw until a live list arrived, and which went stale within a week. An earlier revision on this PR instead read a publicGET /mcp/catalogroute. That route was built in bytebase/bytebase#22184 and then closed, because its only consumer was a directory scan. Bytebase needs no change.How the proxy behaves
initializetools/listtools/callBYTEBASE_URLBYTEBASE_URLinitialized;tools/list_changedwhen the session opensSign-in and tokens:
<app> via Bytebase MCP), so Bytebase's consent page shows the real client and audit records a distinct client ID per app.~/.bytebase-mcp/<instance>/<app>.json(0600). They're credentials, so they stay out of~/.config.state, callback) belongs to the session opening that started it.Reconnecting:
reauthorize).tools/listnever waits on a browser sign-in. A quiet reopen is capped at 10 seconds, and the client is told to list again once the reopen opens.Commands:
statusshows the instance and the stored sign-ins, without signing in.logoutrevokes each refresh token at Bytebase, then deletes it. It does not sign you out of the console. It's also how you switch accounts: log out, reconnect, sign in as the other account.Commits
docs/DESIGN.md): the revision-1 design, thendocs: revision 2, reviewed in five rounds (persona readers, check readers, codex adversarial). It has been updated with every later change.sync-toolsand the README tools table restored, and the snapshot reseeded (13 tools, current instructions; later relabeled from the 3.25.0 release);tools/list, and the startup retry.tools/list, announcing after a reopen, retiring a replaced session, and sign-in state belonging to its opening;logoutrevocation with a 5-second limit, the retry cap, signing in again afterreauthorize, and the move to~/.bytebase-mcp;rundll32instead ofcmd; the snapshot comes from the latest release (3.25.0: the same tools as before, now labeled with the release); the README says Windows is untested.CONTRIBUTING.md: the local testing flow (four levels, a Bytebase build that can complete sign-in, launching a packed tarball, a manual checklist), with the README's Development section cut to a link.Verification
Unit and integration tests (37): they drive the built server over stdio against a fake Bytebase. The fake checks PKCE and has single-use refresh tokens, and it can:
A unit test covers the browser command chosen for each platform. The key fixes are mutation-checked. CI is green on Node 20 and 22.
Live check (13 of 13) against a real Bytebase built from
main:reauthorize, then signing in again, works;logoutrevokes for real: Bytebase refuses the old refresh token with HTTP 400.Consent was approved by a script, since the build had no frontend.
Found against real Bytebase, server side: access tokens carry no unique
jtiand are timestamped to the second, whilereauthorizeblocks a revoked access token by its exact string. A sign-in within the same second as areauthorizetherefore gets a token Bytebase already counts as revoked. Only automation is that fast, but it's worth ajti.Open for review
tools/list_changed? A configured user's first run needs it to show the tools after sign-in; a client that ignores it shows them after a restart.Decided
reauthorizeresult gets a note to reconnect this server and sign in as the account wanted; the only addition the proxy makes to a forwarded result.~/.bytebase-mcp; the OS keychain only if a security review asks.Not in this change
Publishing to npm or the registry, making the repository public, the Glama claim, tool annotations, URL elicitation, headless sign-in, and Windows and confirmation-form manual runs.
🤖 Generated with Claude Code