Skip to content

Pure proxy: tools from the instance after sign-in; a snapshot only for directories - #1

Merged
zchpeter merged 30 commits into
mainfrom
byt-10055-pure-proxy
Nov 24, 2026
Merged

zchpeter merged 30 commits into
mainfrom
byt-10055-pure-proxy

Conversation

@zchpeter

@zchpeter zchpeter commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 public GET /mcp/catalog route. 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

State initialize tools/list tools/call
No BYTEBASE_URL "No instance connected" note + the snapshot's instructions The snapshot Error result: set BYTEBASE_URL
Signed in The instance's own instructions, verbatim The session's, the client's cursors passed through Forwarded
Configured, not signed in yet A note naming the instance (+ a confirm-before-write sentence for clients without forms) Empty. Sign-in starts after initialized; tools/list_changed when the session opens Waits for the sign-in, then forwards
Unreachable / not Bytebase A note with the reason Empty. An unreachable instance (no answer, or a gateway's 502/503/504) is retried 10 times (1s doubling to 5 min, about 14 min), then the proxy stops until a client restart Error result with the reason

Sign-in and tokens:

  • One OAuth client per client app (<app> via Bytebase MCP), so Bytebase's consent page shows the real client and audit records a distinct client ID per app.
  • Sign-ins live in ~/.bytebase-mcp/<instance>/<app>.json (0600). They're credentials, so they stay out of ~/.config.
  • One lock per sign-in guards every write, across processes and within one; single-use refresh tokens are never sent twice.
  • An in-progress sign-in's state (PKCE verifier, state, callback) belongs to the session opening that started it.
  • The sign-in URL is always printed, and opened in a browser only if it is http(s), never through a shell.

Reconnecting:

  • A cancelled call is never sent.
  • A call is resent only when Bytebase never received it, on a session reopened with the stored sign-in (after a 1-hour idle expiry, an outage, or a grant revoked by reauthorize).
  • Reopening never cuts off calls already in flight: they may have run, so they finish and return their results.
  • tools/list never 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:

  • status shows the instance and the stored sign-ins, without signing in.
  • logout revokes 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

  1. The design (docs/DESIGN.md): the revision-1 design, then docs: revision 2, reviewed in five rounds (persona readers, check readers, codex adversarial). It has been updated with every later change.
  2. Revision 1's slices: catalog states (superseded), then sessions, sign-in and the token lock (kept).
  3. Revision 2, slice 1:
    • the snapshot for unconfigured proxies only, with the catalog removed;
    • sync-tools and the README tools table restored, and the snapshot reseeded (13 tools, current instructions; later relabeled from the 3.25.0 release);
    • a fix for a slow warm start that swallowed the browser sign-in.
  4. Revision 2, slice 2: cursor pass-through, every reader taking every page, recovery for tools/list, and the startup retry.
  5. Follow-ups:
    • from the Codex stop-time review: outage recovery, never waiting on a sign-in, aborting a timed-out tools/list, announcing after a reopen, retiring a replaced session, and sign-in state belonging to its opening;
    • from review discussion: logout revocation with a 5-second limit, the retry cap, signing in again after reauthorize, and the move to ~/.bytebase-mcp;
    • from Peter's test in Claude Code: confirmation forms forwarded with no deadline (they vanished after the SDK's 60 seconds) and Bytebase's withdrawal passed on; D5 now lists every forwarded request by direction.
  6. Adela's review:
    • Review fixes for #1: help text, SDK pin, http(s)-only sign-in URL #2, stacked into this branch: help text, the SDK pinned to exactly 1.32.2 (the proxy writes two private SDK fields), and only http(s) sign-in URLs opened;
    • then: a gateway's 502/503/504 counts as unreachable at startup; on Windows the browser opens through rundll32 instead of cmd; 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.
  7. 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:

  • page its list;
  • forget sessions;
  • go down and come back;
  • answer slowly;
  • stall revocation;
  • answer like a gateway in front of a down instance (502/503/504);
  • revoke a grant mid-session.

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:

  • the snapshot shows only when unconfigured;
  • a first run starts empty, signs in, and announces the instance's 13 tools;
  • a tool call runs;
  • a warm start passes the instance's account line through;
  • reauthorize, then signing in again, works;
  • logout revokes 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 jti and are timestamped to the second, while reauthorize blocks a revoked access token by its exact string. A sign-in within the same second as a reauthorize therefore gets a token Bytebase already counts as revoked. Only automation is that fast, but it's worth a jti.

Open for review

  • Which clients honor 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.
  • Does Claude Code have its own timeout on confirmation forms, now that the proxy's is gone?

Decided

  • A successful reauthorize result gets a note to reconnect this server and sign in as the account wanted; the only addition the proxy makes to a forwarded result.
  • Credentials stay in 0600 files under ~/.bytebase-mcp; the OS keychain only if a security review asks.
  • Left as is: if Bytebase already ended a session and its reopen takes longer than 10 seconds, the client isn't told when it opens; it recovers on its next request.
  • No safety-net limit on forms beyond Bytebase's own 10 minutes; a form left up after Bytebase gave up does nothing.

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

zchpeter and others added 3 commits November 22, 2026 12:37
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>
@zchpeter zchpeter changed the title Pure proxy: read the tool list from Bytebase, keep no bundle (design) Pure proxy: read the tool list from Bytebase, keep no bundle Nov 22, 2026
zchpeter and others added 3 commits November 22, 2026 22:55
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>
@zchpeter zchpeter changed the title Pure proxy: read the tool list from Bytebase, keep no bundle Pure proxy: tools from the instance after sign-in; a snapshot only for directories Nov 23, 2026
zchpeter and others added 19 commits November 22, 2026 23:28
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>
@adela-bytebase

Copy link
Copy Markdown
Collaborator

Read through src/ at a78e2fa. Five small things, all quick fixes:

  1. --help is stale (src/index.ts): it still says "the first tool call signs in". Sign-in now starts when the server starts.

  2. status doesn't show a tool list (--help in src/index.ts, and the Commands table in the README): both say it shows "the instance, its tool list and the stored sign-ins". The output has the instance, the probe result and the sign-ins, no tool list.

  3. Pin the SDK version (package.json): server.ts relies on two private SDK fields, _oninitialize and _requestMessageId. With ^1.32.2, a minor release that renames _requestMessageId would silently bring back the request-ID-0 cancellation bug. Suggest 1.32.2 exactly.

  4. Only open http(s) URLs in the browser (openInBrowser in src/auth.ts): the authorization URL comes from the instance's OAuth metadata and goes straight to open / xdg-open / cmd /c start. SDK 1.32.2 only rejects javascript:, data: and vbscript:, so a file:// or custom-scheme URL would be opened. Suggest checking the protocol first and only printing the URL otherwise.

  5. Startup retry skips 502/503/504 (isUnreachable in src/server.ts): while Bytebase restarts behind a reverse proxy, these don't count as unreachable, so the startup sign-in gives up instead of retrying. It recovers on the next request, but adding the three codes would cover the restart case.

Two more that I'd settle before publishing to npm (neither blocks the merge):

  1. Windows: the sign-in URL goes through cmd (openInBrowser in src/auth.ts): the Windows branch runs cmd /c start "" <url> and escapes only &. |, ^ and % are legal in a URL query and cmd still parses them, so an authorization_endpoint like http://x/?a|calc.exe runs a command. It needs a BYTEBASE_URL that points at a malicious or hijacked server, but this is the same class as mcp-remote's CVE-2025-6514. Suggest opening the URL without cmd, for example rundll32 url.dll,FileProtocolHandler <url> or PowerShell Start-Process with the URL as a single argument (neither tried on Windows here), together with the http(s) check from item 4. The PR already lists Windows as not yet run by hand, so this fits that pass.

  2. The snapshot lists tools that aren't released (src/tools.json, README tools table): it was reseeded from main at 9daf6b307f. Compared with the 3.24.1 snapshot it adds administer_workspace, get_gitops_workflow and request_access_grant, and drops get_skill. Directories (Glama) and the README will show tools that a 3.24.1 user doesn't get after sign-in. Suggest either generating the snapshot from a release tag only, or holding the npm publish until the release that ships these tools.

- --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>
@adela-bytebase

Copy link
Copy Markdown
Collaborator

Items 1-4 above are fixed in #2, stacked on this branch (base byt-10055-pure-proxy), so merging it lands them here:

  1. --help: sign-in starts when the server starts.
  2. --help and README: status no longer claims to show a tool list.
  3. @modelcontextprotocol/sdk pinned to 1.32.2.
  4. openInBrowser opens only http(s) URLs; anything else is logged, and the URL is still printed.

Items 5-7 are untouched and left for you.

@zchpeter

Copy link
Copy Markdown
Contributor Author

Thanks, Adela. All seven hold up. Items 1–4 land through #2 (approved, and stacked into this branch). The rest:

  1. Accepted. It goes a bit further than "recovers on the next request". During a 5xx the startup note says the server "does not answer as a Bytebase instance", which sends the user to check BYTEBASE_URL. And on a first run (no stored sign-in), the list stays empty with nothing for the agent to call, so only a client restart recovers. D5's "unreachable" will cover a gateway's 502/503/504, in both the startup note and the startup retry, with a test.
  2. Accepted, fixed here before publishing. The browser opens through rundll32 url.dll,FileProtocolHandler <url> with no shell, after the http(s) check from Review fixes for #1: help text, SDK pin, http(s)-only sign-in URL #2. A unit test checks the command chosen for each platform, including that Windows never runs cmd. Nobody has run the package on Windows, so the README will say so and point to the printed URL as the fallback.
  3. Mostly moot since 3.25.0 shipped (Nov 20). The 3.24.1 snapshot was the only release one to compare with. The 3.25.0 tag and 9daf6b307f register the same 13 tools, with no definition changes in backend/api/mcp between them. What's wrong is the label ("main at 9daf6b307f"). I'll regenerate it with sync-tools against a 3.25.0 instance, so it names the release.

zchpeter and others added 2 commits November 23, 2026 22:20
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>
@zchpeter
zchpeter force-pushed the byt-10055-pure-proxy branch from 3fe427b to 2e8c7e2 Compare November 24, 2026 03:27
zchpeter and others added 2 commits November 23, 2026 22:32
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 adela-bytebase left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zchpeter
zchpeter merged commit a985744 into main Nov 24, 2026
2 checks passed
@adela-bytebase

Copy link
Copy Markdown
Collaborator

Heads-up: merging this triggered npm-publish.yml (the PR changed package.json), and the run failed at Publish to npm with ENEEDAUTH. Nothing was published. Run: https://github.com/bytebase/bytebase-mcp/actions/runs/45368346163

Cause: @bytebase/bytebase-mcp doesn't exist on npm yet (npm view returns E404), so no trusted publisher is configured and the OIDC exchange has nothing to match. npm's docs tie ENEEDAUTH to exactly that.

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 --provenance explicitly, and the docs don't say whether that errors or is skipped from a private repo, so it may be the next thing to fail once auth works.

To get it published (needs an npm bytebase org owner):

  1. Decide the order of publishing and making the repo public, since it affects --provenance.
  2. Configure the trusted publisher for the package: Organization bytebase, Repository bytebase-mcp, Workflow npm-publish.yml. The setting lives under the package's settings, so the package may have to exist first (a manual first npm publish --access public); the docs don't state this either way.
  3. Re-run the workflow. If 0.1.0 was published by hand, the npm step skips itself and the MCP Registry step still registers it.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants