Skip to content

fix(mcp): keep links from stale-session recovery and other review follow-ups - #2761

Closed
mattzcarey wants to merge 3 commits into
docs/mcp-client-examplesfrom
fix/mcp-review-followups
Closed

mattzcarey wants to merge 3 commits into
docs/mcp-client-examplesfrom
fix/mcp-review-followups

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Fixes the last review findings on the stack. The worst: a resumed session the server had forgotten, when restarted into OAuth, was recorded as authorization-failed instead of waiting for the user with a working link. Three smaller fixes come with it: a server waiting for a scheduled reconnect reports its real error, a late 401 reuses a token another request just refreshed, and old link-expiry jobs can't stall.

Stacked on #2760, part of the work on #2658. Details:

  • stale-session recovery: the fresh session's link stayed on the connection, but the discovery result left it out, and feat(mcp): durable reconnect and authorization-expiry jobs #2662's refusal rule reads "authenticating with no link" as refused. The result now carries the link.
  • retry errors: a failure that schedules a reconnect now sets the connection's error. addMcpServer() and getMcpServers() show it instead of "Connection failed".
  • late 401s: a small fetch wrapper records the token each 401 was sent with. If a newer token exists by the time that request's turn comes, the SDK retries with it instead of refreshing again. The manager also warns once if the SDK stops exposing the auth provider the turns wrap.
  • expiry jobs without savedAt: they count as old, so their link expires at the next run. Only this unreleased stack wrote such jobs, but this is cheap insurance if feat(mcp): durable reconnect and authorization-expiry jobs #2662 ships before fix(mcp): stop MCP recovery from retrying or minting links on its own #2758.

pnpm run check and the full agents suite pass. New tests cover the stale-session case and the error message, and both fail without the fix.

@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3f5beb7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

@agent-think

agent-think Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (b9324a53 → 3f5beb70, workflow run)

@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2761

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2761

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2761

hono-agents

npm i https://pkg.pr.new/hono-agents@2761

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2761

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2761

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2761

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2761

commit: 3f5beb7

…y errors, refresh once for late 401s

- a resumed session the server forgot, restarted into OAuth, kept its link
  only in the connection; discovery now returns it, so the server waits for
  the user instead of being recorded as refused
- a failure that schedules a reconnect sets the connection's error, so
  addMcpServer() and getMcpServers() report it instead of "Connection failed"
- a 401 compares against the token its own request carried, so one arriving
  after another request refreshed retries with the new token instead of
  refreshing again; warn if the SDK stops exposing its auth provider
- an auth-expiry job without savedAt expires its link on the next run
- shorter changeset for reconnectMcpServer
@mattzcarey

Copy link
Copy Markdown
Member Author

Replaced by #2782 (MCP client changes) and #2783 (examples).

@mattzcarey mattzcarey closed this Oct 30, 2026
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.

1 participant