Repository navigation
docs(examples): show MCP client best practice in examples and docs - #2760
Closed
mattzcarey wants to merge 3 commits into
Closed
mattzcarey wants to merge 3 commits into
mattzcarey wants to merge 3 commits into
Conversation
|
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
Contributor
|
✅ agents import sizes: no significant changes ( |
mattzcarey
force-pushed
the
docs/mcp-client-examples
branch
from
October 29, 2026 11:52
f9f2dc6 to
c46ca91
Compare
mattzcarey
force-pushed
the
docs/mcp-client-examples
branch
from
October 29, 2026 18:59
c46ca91 to
3a112ac
Compare
- examples with a server list (mcp-client, ai-chat, codemode, assistant) get a Reconnect button for failed servers, backed by reconnectMcpServer() - mcp-client's callTool returns the link from MCPAuthorizationRequiredError and the browser opens it - the playground's MCP OAuth demo shows the real API: addMcpServer's authenticating result, onMcpUpdate's servers map, the actual states, re-authorization and reconnecting - docs: a best-practices list in mcp-client.md; the client snippet reads state (not connectionState) and offers Authorize / Reconnect; agent-class.md adds servers from a callable with a stable id; retries.md explains the quick attempts versus durable reconnects
… Think waits - mcp-client's Reconnect opens the authorization link reconnectMcpServer returns - the playground's state list keeps not-connected, which getMcpServers emits for a stored server with no live connection - AIChatAgent waits for restored MCP tools by default; Think needs waitForMcpConnections
mattzcarey
force-pushed
the
docs/mcp-client-examples
branch
from
October 29, 2026 19:28
3a112ac to
b9324a5
Compare
Member
Author
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.
The MCP client examples and docs now show how to use the client well. Every example with a server list has a "Reconnect" button for failed servers,
examples/mcp-clienthands the user the link when a tool call needs re-authorization, andmcp-client.mdhas a short best-practices list.Stacked on #2759, part of the work on #2658. With #2758, a server stopped for a reason only a person can fix (authorization refused, the step-up limit) needs an explicit "Reconnect". The examples and docs also had mistakes worth fixing while here:
onMcpUpdateas an array and checked aneedsAuthfield that doesn't exist, and listed anot-connectedstate that isn't onemcp-client.mdreadserver.connectionState, but the field isstateagent-class.mdadded a server fromonConnect, so it ran on every WebSocket connectionChanges by file:
mcp-client,ai-chat,codemode: areconnectServercallable callingreconnectMcpServer(id), and a Reconnect button onfailedservers that opens the new link if one comes backmcp-client:callToolcatchesMCPAuthorizationRequiredErrorand returns the link, and the browser opens itOAuthDemo: snippets for connecting, rendering fromgetMcpServers(), re-authorization and reconnectingmcp-client.md;agent-class.mdadds servers from a callable with a stableid;retries.mdexplains how the quick in-place attempts differ from durable reconnectspnpm run checkpasses, including typechecking all 80 example projects. I haven't clicked through the UIs in a browser.