Skip to content

Agents docs: Workers AI first, fix bugs, rewrite key pages#28501

Merged
threepointone merged 5 commits into
productionfrom
remove-openai
Feb 21, 2026
Merged

Agents docs: Workers AI first, fix bugs, rewrite key pages#28501
threepointone merged 5 commits into
productionfrom
remove-openai

Conversation

@threepointone

@threepointone threepointone commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Summary

A comprehensive pass over the Agents documentation: migrates examples to Workers AI, rewrites the landing page and several concept/reference pages, and fixes bugs across MCP docs.

Workers AI migration

Replaced OPENAI_API_KEY / OpenAI SDK references with Workers AI in pages where the provider was incidental to the feature being documented:

  • index.mdx — Removed .env / API key step from quickstart. The agents-starter now uses Workers AI by default.
  • using-ai-models.mdx — Streaming example uses workers-ai-provider + AI SDK. AI SDK section leads with Workers AI, shows OpenAI as a swap. Fixed multiple code bugs (env.AI.runthis.env.AI.run, undefined variable, wrong Gemini model name, missing type params).
  • store-and-sync-state.mdx — Model context example uses this.env.AI.run().
  • http-sse.mdx — SSE example uses createWorkersAI instead of createOpenAI.
  • browse-the-web.mdx — Browser scraping example uses this.env.AI.run(), added AI binding to wrangler config.
  • mcp-client-api.mdx — AI SDK integration example uses Workers AI instead of openai("gpt-4").

Intentionally kept as OpenAI: configuration.mdx (secrets management example), chat-agents.mdx (multi-provider comparison), slack-agent.mdx (full tutorial).

Landing page rewrite (index.mdx)

  • Opens with the problem (stateless vs stateful) instead of generic "what are agents" intro
  • Quickstart is 3 commands, no API key step, mentions you can swap providers
  • "What agents can do" scannable list with AIChatAgent called out
  • Both Agent (counter) and AIChatAgent (chat) code examples
  • Removed duplicated "add to existing project" code (lives in its own page)

Page rewrites

  • using-ai-models.mdx — Full rewrite. Clean intro, fixed all code bugs, Workers AI first throughout.
  • calling-llms.mdx — Rewrote from thin 37-line generic page to patterns-focused content: state as context, surviving disconnections, autonomous model calls, multi-model pipelines, caching and cost control.
  • agent-class.mdx — Fixed code bugs (ws.send(msg), missing new, fake storage.kv), cleaned up PartyKit references, added Layer 3: AIChatAgent section.
  • tools.mdx (MCP) — Full rewrite from 36-line stub to comprehensive reference covering tool definitions, results, error handling, descriptions, Zod validation, and usage with both createMcpHandler and McpAgent.
  • authorization.mdx (MCP) — Rewrote bottom half: auth context usage for both McpAgent (this.props) and createMcpHandler (getMcpAuthContext()), permission-based tool access with two approaches explained.

MCP docs bug fixes (13 files)

  • authorization.mdx — Removed orphaned <diagram> tag, fixed broken anchor, fixed "oAuth" → "OAuth", added pcx_content_type, replaced MyMCPServer.Router with .serve()
  • mcp-client-api.mdx — Fixed this.env bug in createMcpOAuthProvider, fixed import path for error utils, removed dead code
  • mcp-handler-api.mdx — Fixed misleading intro (stateless vs stateful), fixed storage.kvstorage.get/put, added missing State type, fixed onMcpRequestonRequest
  • remote-mcp-server.mdx — Fixed MyMCP.Router.serve(), fixed Auth0/WorkOS anchors pointing to #stytch, fixed https://localhosthttp://localhost
  • securing-mcp-server.mdx — Fixed apiHandlersapiRoute + apiHandler
  • test-remote-mcp-server.mdx — Fixed localhost protocol, typo, outdated claim
  • Minor fixes across index.mdx, transport.mdx, governance.mdx, mcp-servers-for-cloudflare.mdx, tools.mdx, oauth-mcp-client.mdx, connect-mcp-client.mdx — HTTP → HTTPS links, "streamble-http" → "streamable-http", unused imports, missing pcx_content_type, extends AgentAgent<Env> (8 instances)

Formatting

Ran prettier on all agents docs.

Test plan

  • Verify all internal links resolve
  • Run npm run check to validate frontmatter and types
  • Spot-check rendered code examples for syntax correctness
  • Verify MCP tool examples match the @modelcontextprotocol/sdk API

Replace OpenAI-specific examples with Workers AI / AI SDK usage across Agents docs. Examples now use an Env AI binding, createWorkersAI / workers-ai-provider, and streamText/generateText from the ai SDK instead of direct OpenAI clients or API keys. Updated WebSocket/SSE streaming, long-running model examples, and SQL/state persistence to consume this.env.AI.run streams/responses. Updated Wrangler/config mentions to use the ai binding and clarified AI Gateway/model routing guidance. Files changed: browse-the-web.mdx, http-sse.mdx, store-and-sync-state.mdx, using-ai-models.mdx, index.mdx.
Revise agent-class.mdx to clarify the Agent/Server/DurableObject layering, tighten wording, fix small code snippets (ws.send, storage access, Response usage), standardize PartyKit/Server references, and add a new Layer 3 section describing AIChatAgent. Replace calling-llms.mdx with a complete rewrite that focuses on using LLMs inside stateful Agents: explains state-as-context, surviving disconnections, autonomous model calls, multi-model pipelines, and caching; adds multiple TypeScript examples and Next Steps link cards, and updates the page tag to "AI".
@threepointone
threepointone requested a review from a team February 21, 2026 19:32
@threepointone
threepointone requested a review from a team as a code owner February 21, 2026 19:32
@github-actions github-actions Bot added product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/xl labels Feb 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/agents/ @irvinebroque, @rita3ko, @elithrar, @thomasgauvin, @threepointone, @whoiskatrin, @cloudflare/pcx-technical-writing, @cloudflare/ai-agents, @cloudflare/dev-plat-leads

@github-actions

github-actions Bot commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

Preview URL: https://14d3c453.preview.developers.cloudflare.com
Preview Branch URL: https://remove-openai.preview.developers.cloudflare.com

Files with changes (up to 15)

Original Link Updated Link
https://developers.cloudflare.com/agents/guides/remote-mcp-server/ https://remove-openai.preview.developers.cloudflare.com/agents/guides/remote-mcp-server/
https://developers.cloudflare.com/agents/concepts/calling-llms/ https://remove-openai.preview.developers.cloudflare.com/agents/concepts/calling-llms/
https://developers.cloudflare.com/agents/model-context-protocol/tools/ https://remove-openai.preview.developers.cloudflare.com/agents/model-context-protocol/tools/
https://developers.cloudflare.com/agents/model-context-protocol/authorization/ https://remove-openai.preview.developers.cloudflare.com/agents/model-context-protocol/authorization/
https://developers.cloudflare.com/agents/ https://remove-openai.preview.developers.cloudflare.com/agents/
https://developers.cloudflare.com/agents/api-reference/using-ai-models/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/using-ai-models/
https://developers.cloudflare.com/agents/api-reference/retries/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/retries/
https://developers.cloudflare.com/agents/concepts/agent-class/ https://remove-openai.preview.developers.cloudflare.com/agents/concepts/agent-class/
https://developers.cloudflare.com/agents/api-reference/mcp-handler-api/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/mcp-handler-api/
https://developers.cloudflare.com/agents/api-reference/agents-api/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/agents-api/
https://developers.cloudflare.com/agents/guides/test-remote-mcp-server/ https://remove-openai.preview.developers.cloudflare.com/agents/guides/test-remote-mcp-server/
https://developers.cloudflare.com/agents/api-reference/mcp-client-api/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/mcp-client-api/
https://developers.cloudflare.com/agents/api-reference/store-and-sync-state/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/store-and-sync-state/
https://developers.cloudflare.com/agents/api-reference/browse-the-web/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/browse-the-web/
https://developers.cloudflare.com/agents/api-reference/http-sse/ https://remove-openai.preview.developers.cloudflare.com/agents/api-reference/http-sse/

threepointone and others added 2 commits February 21, 2026 19:59
- authorization.mdx: remove orphaned <diagram> tag, fix broken anchor
  (#3 -> #2), fix "oAuth" -> "OAuth", add pcx_content_type, rewrite
  permission code to use correct MCP tool handler signature, replace
  MyMCPServer.Router with .serve(), remove unused DirectoryListing import
- mcp-client-api.mdx: fix this.env bug in createMcpOAuthProvider (capture
  env before returning object literal), fix import path for error utils,
  remove dead code after return, replace OpenAI example with Workers AI
- mcp-handler-api.mdx: fix misleading intro (stateless vs stateful, not
  SSE), fix storage.kv -> storage.get/put, fix {} as ExecutionContext,
  wrap global McpServer in factory function, fix "accessable" typo
- remote-mcp-server.mdx: fix MyMCP.Router -> .serve(), fix Auth0/WorkOS
  anchors pointing to #stytch, fix https://localhost -> http://localhost,
  fix broken MCP client link
- securing-mcp-server.mdx: fix apiHandlers -> apiRoute + apiHandler
- test-remote-mcp-server.mdx: fix https -> http localhost, fix "lets you
  to test" typo, remove outdated claim about Claude Desktop
- tools.mdx: add missing tags, add .js extension to import, remove
  unused Render import, fix stale repo link
- governance.mdx: add pcx_content_type, remove empty import
- index.mdx: fix http -> https links for Claude and Cursor
- mcp-servers-for-cloudflare.mdx: fix "streamble-http" typo, remove
  unused Render import, fix link to source code -> docs
- transport.mdx: remove unused Render/TabItem/Tabs imports
- oauth-mcp-client.mdx: fix extends Agent -> Agent<Env> (5 instances)
- connect-mcp-client.mdx: fix extends Agent -> Agent<Env> (3 instances)

Co-authored-by: Cursor <cursoragent@cursor.com>
tools.mdx: Full rewrite from 36-line stub to comprehensive reference.
Covers tool definitions, results, error handling, descriptions best
practices, Zod input validation, and usage with both createMcpHandler
and McpAgent. All examples use the factory function pattern.

mcp-handler-api.mdx: Add missing State type definition in stateful
example, fix onMcpRequest -> onRequest in Worker handler, remove
unused Render import.

authorization.mdx: Rewrite bottom half to show auth context usage
for both McpAgent (this.props) and createMcpHandler (getMcpAuthContext),
with proper type definitions. Clarify the two permission approaches
(check inside handler vs conditional registration) and when to use each.

Co-authored-by: Cursor <cursoragent@cursor.com>
@threepointone threepointone changed the title Agents docs: Workers AI first, fix bugs, rewrite landing page Agents docs: Workers AI first, fix bugs, rewrite key pages Feb 21, 2026
@threepointone
threepointone merged commit ece9057 into production Feb 21, 2026
9 checks passed
@threepointone
threepointone deleted the remove-openai branch February 21, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/xl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants