Skip to content

fix: escape html in external oauth error message#28091

Open
agents-git-bot[bot] wants to merge 1 commit intoproductionfrom
sync-docs-pr-841
Open

fix: escape html in external oauth error message#28091
agents-git-bot[bot] wants to merge 1 commit intoproductionfrom
sync-docs-pr-841

Conversation

@agents-git-bot
Copy link
Contributor

@agents-git-bot agents-git-bot bot commented Feb 4, 2026

Summary

This PR syncs documentation changes from cloudflare/agents#841 which fixed an XSS vulnerability in OAuth error handling for MCP clients.

Changes

  • OAuth callback handler simplified: The customHandler no longer receives MCPClientOAuthResult with error information. It now simply closes the popup window, and errors are handled automatically by the SDK.
  • New error field: Added documentation for the error field in MCPServer type, which stores connection errors for UI display.
  • Security improvement: Error messages from external OAuth providers are automatically escaped to prevent XSS attacks, making them safe to display directly in UIs.
  • Updated examples: All OAuth integration examples now demonstrate the correct pattern of displaying errors from connection state instead of handling them in script alerts.

Files Changed

  • /agents/guides/oauth-mcp-client/ - Updated OAuth integration guide with new error handling patterns
  • /agents/model-context-protocol/mcp-client-api/ - Added error field to MCPServer type documentation

Related

@github-actions github-actions bot added product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/s labels Feb 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

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

Updates documentation to reflect security improvements in OAuth error handling:

- Remove MCPClientOAuthResult from customHandler signature (no longer receives error info)
- Document new `error` field in MCPServer type that stores connection errors
- Update examples to display errors from connection state instead of script alerts
- Add note that error messages are automatically escaped to prevent XSS attacks
- Simplify customHandler examples to only close popup (errors handled separately)

Related to cloudflare/agents#841

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@agents-git-bot agents-git-bot bot changed the title docs: Fix XSS vulnerability in MCP OAuth error handling fix: escape html in external oauth error message Feb 4, 2026
@mattzcarey
Copy link
Contributor

looks good to me. @threepointone to go with the PR

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/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants