MCP client refactor - storage adapter#652
Conversation
🦋 Changeset detectedLatest commit: 0966d6c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Claude Code ReviewArchitecture IssuesCritical: Race condition in OAuth flow (index.ts:482-487) Storage timing issue (client.ts:600-602) Code QualityMissing error handling in restoreConnectionsFromStorage (client.ts:223) Inconsistent state machine (client.ts:160-196) Type safety gap (client-storage.ts:79-85) Testing CoverageThe test file (client-manager.test.ts) has grown significantly (+1757 lines) but I cannot verify test quality without seeing the full file. Ensure tests cover:
Minor Issues
|
commit: |
Documents the MCP client manager refactoring that introduces a storage adapter interface and implements automatic OAuth credential cleanup for enhanced security. Changes: - Add new mcp-storage.mdx explaining storage adapter architecture - Document automatic OAuth credential cleanup after authentication - Add security notes about replay attack prevention - Document automatic connection restoration after hibernation - Update OAuth guide with security information Related PR: cloudflare/agents#652 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
📚 Documentation SyncI've created a documentation PR to sync these changes to cloudflare-docs: Docs PR: cloudflare/cloudflare-docs#26535 Documentation ChangesThis PR introduces a storage adapter architecture for the MCP client manager. The documentation includes:
Why These Docs MatterThis refactoring introduces a breaking change in how The OAuth security improvements are also worth documenting for user awareness. This is an automated sync from the intelligent documentation workflow. |
📚 Documentation syncDocumentation has been updated in cloudflare-docs to reflect these changes: Docs PR: cloudflare/cloudflare-docs#26535 Changes documented
The documentation covers:
🤖 Auto-generated comment |
- Add new storage-adapter.mdx page documenting the MCPStorageAdapter interface - Update mcp-client-api.mdx to reference storage adapter pattern - Document breaking change: MCPClientManager now requires storage option - Include migration guide for direct MCPClientManager usage - Document security improvements in OAuth credential handling Related to cloudflare/agents#652
Documentation UpdatedThe documentation for this PR has been updated in cloudflare-docs#26535. Documentation changes:
Please review the documentation PR when you have a chance. |
📚 Documentation sync completedThe documentation for this PR has been updated in the cloudflare-docs repository. Documentation PR: cloudflare/cloudflare-docs#26535 Updated documentation:
Key changes documented:
The documentation is ready for review alongside this PR. |
threepointone
left a comment
There was a problem hiding this comment.
paired and reviewd, ping when done and let's land this
threepointone
left a comment
There was a problem hiding this comment.
stampung pending a descriptive changeset
* move storage to the client manager * fix: url missing after page load * fix: dots * fix: callback handling is now in client manager with 2 stage storage. * some auth edge cases * make storage sync for the moment to reduce complexity * better default states * cancel button on frontend * remove openai from agents package.json * unify mcp storage * fix lock file * fix: tests * feat: more refactor * tools tests * update x402 * fix: types * update default model in playground * reasoning card * Apply suggestion from @mattzcarey * fix: from review * add smooth scrolling * fix: calling restore onstart and json schema the rest of the time * fix: oauth tests * remove smooth scroll :( * make tests smaller * rename to client for review * revert changes to mcp.connect() * make storage async * fix readonly nit * revert remove openai ai sdk provider * remove public storage api * add todos for ensureJsonSchema * fix: mcp server states and unify observability to the mcp client manager class. * remove callback cache * dead * createConnection. in memory method * add tests * changeset * formatting * claude comments * remove redundant checks
part one in a long saga. This moves all the mcp storage functions to the client manager, with an interface to try and make it less platform specific.
also cleans up the
_connectMcpServersInternalandmcp.connectinto..tested with: https://search-mcp.parallel.ai/mcp on https://workers-ai-playground.mattzcarey.workers.dev/
Other fun stuff here: