[MCP] Make storage observer resilient to duplicates and bad documents#9673
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the MCP adapter’s storage observer initialization to tolerate duplicate prompt/tool names (instead of throwing on duplicate dictionary keys), and adds integration tests to ensure listing prompts/tools no longer crashes when duplicates exist.
Changes:
- Deduplicate prompt definitions by name during
McpStorageObserverinitialization. - Deduplicate tool definitions by name during
McpStorageObserverinitialization. - Add a test-only
IMcpStorageimplementation that can return duplicate definitions, plus new integration tests covering the duplicate-name scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/HotChocolate/Adapters/src/Adapters.Mcp.Core/McpStorageObserver.cs | Deduplicates prompt/tool definitions during initial load to avoid crashing on duplicate names. |
| src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/MultiCollectionMcpStorage.cs | Adds a test IMcpStorage implementation that returns definitions verbatim (including duplicates). |
| src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/IntegrationTestBase.cs | Adds integration tests asserting duplicates are deduped and list operations don’t crash. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Properties/McpAdapterResources.Designer.cs: Language not supported
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Properties/McpAdapterResources.Designer.cs: Language not supported
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Properties/McpAdapterResources.Designer.cs: Language not supported
No description provided.