feat(cloudflare): add official MCP provider - #232
Conversation
Summary by CodeRabbit
WalkthroughAdds a Cloudflare MCP provider with Sequence Diagram(s)sequenceDiagram
participant cloudflareMcpActionHandlers
participant withCloudflareMcpClient
participant CloudflareMCPServer
cloudflareMcpActionHandlers->>withCloudflareMcpClient: Invoke MCP tool with arguments
withCloudflareMcpClient->>CloudflareMCPServer: Send authenticated tools/call request
CloudflareMCPServer-->>withCloudflareMcpClient: Return tool result
withCloudflareMcpClient-->>cloudflareMcpActionHandlers: Normalize and return output
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/providers/cloudflare_mcp/executors.test.ts`:
- Around line 43-50: Update createMcpFetch so the authorization assertion
compares against the expected exact Bearer token rather than only matching the
“Bearer ” prefix. Reuse the test’s configured credential source where available,
ensuring incorrect or empty tokens fail the test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 15827156-2e46-48fa-9da6-7b6c91d400f7
📒 Files selected for processing (5)
src/providers/cloudflare_mcp/actions.tssrc/providers/cloudflare_mcp/definition.test.tssrc/providers/cloudflare_mcp/definition.tssrc/providers/cloudflare_mcp/executors.test.tssrc/providers/cloudflare_mcp/executors.ts
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/providers/cloudflare_mcp/executors.ts (2)
94-96: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the client input contract into a named interface.
withCloudflareMcpClientuses an inline object type in a multi-line function signature. Define a provider-localCloudflareMcpClientInputinterface and reuse it forlistCloudflareMcpToolsas appropriate.As per coding guidelines, prefer named options/input interfaces when a function signature spans multiple lines or crosses module boundaries.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/cloudflare_mcp/executors.ts` around lines 94 - 96, Define a provider-local CloudflareMcpClientInput interface for the accessToken, fetcher, and optional signal fields, then replace the inline input object type in withCloudflareMcpClient with that interface and reuse it in listCloudflareMcpTools where the same contract applies.Source: Coding guidelines
67-75: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd tests for cancellation during an active MCP request.
The current test only covers a signal that is already aborted before execution. Add coverage that aborts while
listToolsorcallToolis in flight and verifies the underlying fetch receives the signal and rejects without leaking the client.Also applies to: 80-89
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/providers/cloudflare_mcp/executors.ts` around lines 67 - 75, Add tests for active-request cancellation in listCloudflareMcpTools and the corresponding callTool flow: abort the signal while listTools or callTool is pending, verify the underlying fetch receives that signal and rejects, and confirm the MCP client is cleaned up without leaking. Retain the existing pre-aborted-signal coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/providers/cloudflare_mcp/executors.ts`:
- Around line 94-96: Define a provider-local CloudflareMcpClientInput interface
for the accessToken, fetcher, and optional signal fields, then replace the
inline input object type in withCloudflareMcpClient with that interface and
reuse it in listCloudflareMcpTools where the same contract applies.
- Around line 67-75: Add tests for active-request cancellation in
listCloudflareMcpTools and the corresponding callTool flow: abort the signal
while listTools or callTool is pending, verify the underlying fetch receives
that signal and rejects, and confirm the MCP client is cleaned up without
leaking. Retain the existing pre-aborted-signal coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a8c73cbd-841d-402e-bd5a-e1f064adca09
📒 Files selected for processing (2)
src/providers/cloudflare_mcp/executors.test.tssrc/providers/cloudflare_mcp/executors.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/providers/cloudflare_mcp/executors.test.ts
Summary
cloudflare_mcpprovider backed by Cloudflare’s official unified Streamable HTTP MCP endpointdocs,search, andexecutetools/listand require the expected official toolsAuthentication
API tokens are sent as
Authorization: Bearer <token>. Both user and account API tokens are supported; account tokens should include Account Resources: Read so the official MCP server can auto-detect the account.OAuth uses Cloudflare’s published authorization metadata:
https://mcp.cloudflare.com/authorizehttps://mcp.cloudflare.com/tokenuser:read account:read offline_accessThe open-source runtime uses bring-your-own OAuth clients. For Cloudflare MCP, register a public client through
https://mcp.cloudflare.com/registerusing the callback URL shown by Open Connector, then save the returned client ID in the OAuth Client configuration. No client secret is required (token_endpoint_auth_method=none).Implementation notes
https://mcp.cloudflare.com/mcpsearchandexecutepreserve JSON results when possible and plain text otherwisedocs) are returned directlyVerification
oxlint .oxfmt --check .node scripts/generate-catalog.tsnode scripts/typecheck.ts src scripts-all examplesvitest run— 59 files, 562 tests passed