Skip to content

Refactor MCP server table management in Agent class#664

Merged
threepointone merged 1 commit into
mainfrom
fix-mcp-storage-table
Nov 19, 2025
Merged

Refactor MCP server table management in Agent class#664
threepointone merged 1 commit into
mainfrom
fix-mcp-storage-table

Conversation

@threepointone

Copy link
Copy Markdown
Contributor

Moved creation and deletion of the cf_agents_mcp_servers table from AgentMCPClientStorage to the Agent class. Removed redundant create and destroy methods from AgentMCPClientStorage and updated MCPClientManager to reflect these changes. Added comments to clarify usage in demo and test code.

Moved creation and deletion of the cf_agents_mcp_servers table from AgentMCPClientStorage to the Agent class. Removed redundant create and destroy methods from AgentMCPClientStorage and updated MCPClientManager to reflect these changes. Added comments to clarify usage in demo and test code.
@changeset-bot

changeset-bot Bot commented Nov 19, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 375f212

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agents Patch

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

claude Bot commented Nov 19, 2025

Copy link
Copy Markdown

Claude Code Review

Summary: This refactoring improves the architecture by centralizing table lifecycle management in the Agent class. The changes are clean and well-tested.

Issues Found: None. PR looks good.

Analysis:

The refactoring moves MCP table creation/deletion from AgentMCPClientStorage to the Agent class constructor/destructor, which makes sense because:

  1. Better separation of concerns: AgentMCPClientStorage is now purely a data access layer (CRUD operations), while Agent owns the lifecycle of all its tables
  2. Consistency: The MCP table is now created/dropped alongside other agent tables (cf_agents_state, cf_agents_schedules, cf_agents_queues) in packages/agents/src/index.ts:434-444 and packages/agents/src/index.ts:1325
  3. Timing guarantees: Table creation happens during Agent construction before MCPClientManager needs it, eliminating the race condition from the previous create() call
  4. Interface simplification: Removes create() and destroy() methods from MCPClientStorage interface since storage implementations shouldn't manage their own schemas

Testing coverage: Excellent - the test suite in packages/agents/src/tests/mcp/client-manager.test.ts comprehensively covers MCP storage operations without needing the removed methods, confirming they were redundant.

@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2025

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@664

commit: 375f212

@threepointone
threepointone merged commit 36d03e6 into main Nov 19, 2025
6 checks passed
@threepointone
threepointone deleted the fix-mcp-storage-table branch November 19, 2025 11:38
@threepointone threepointone mentioned this pull request Nov 19, 2025
naji247 pushed a commit to agentcathq/agents that referenced this pull request Nov 20, 2025
Moved creation and deletion of the cf_agents_mcp_servers table from AgentMCPClientStorage to the Agent class. Removed redundant create and destroy methods from AgentMCPClientStorage and updated MCPClientManager to reflect these changes. Added comments to clarify usage in demo and test code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants