-
Notifications
You must be signed in to change notification settings - Fork 293
MCP client refactor - storage adapter #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Claude Code ReviewCritical Issues1. Missing await in async removeMcpServer(id: string) {
this.mcp.closeConnection(id); // Missing await
this.mcp.removeServer(id);
this.broadcastMcpServers();
}
Fix: Architecture Issues2. Storage adapter passed to OAuth provider is too broad (client-manager.ts:134-138) Consider creating a narrower interface for OAuth providers that only exposes KV operations. 3. Connection state race condition in restore (client-manager.ts:164-187) Testing Gaps4. No integration tests for OAuth flow 5. Cache invalidation not tested Minor Issues6. Inconsistent connection disposal (client-manager.ts:687-688) 7. Silent connection recreation (client-manager.ts:239-242) Summary: Address the missing await (#1) before merging. Consider #2 for security boundaries. Others are improvements for future PRs. |
commit: |
This PR introduces a storage adapter architecture for the MCP client manager, allowing custom storage backends for MCP server configurations. Changes: - Created advanced-client-api.mdx documenting the MCPStorageAdapter interface - Added security section to oauth-mcp-client.mdx about callback URL clearing - Updated mcp-client-api.mdx to link to advanced configuration guide These docs explain the new storage adapter pattern, OAuth security improvements, and provide examples for implementing custom storage backends. Related: cloudflare/agents#652
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 <[email protected]>
📚 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. |
deathbyknowledge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
| this._ParentClass.name, | ||
| "0.0.1" | ||
| ); | ||
| readonly mcp!: MCPClientManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ! is not needed if you set it in the constructor
packages/agents/src/index.ts
Outdated
| await this.mcp.ensureJsonSchema(); | ||
| } | ||
|
|
||
| await this._initializeMcpConnectionsFromStorage(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to move this._mcpConnectionsInitialized and this._initializeMcpConnectionsFromStorage inside the ClientManager constructor?
Ideally in the Agent constructor we'd just do this.mcp = new MCPClientManager(this._ParentClass.name, "0.0.1", ...) and forget about it right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the call to ensureJsonSchema() too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is super annoying. We need the name to make the called to the d-o-OauthClient. We dont have that in the constructor where this is defined :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can clean this up a bit tho
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: