[MCP] Move IMcpStorage to abstractions and add StorageFactory delegate - #9631
#9631[MCP] Move IMcpStorage to abstractions and add StorageFactory delegate#9631tobias-tengler merged 3 commits intomainChilliCream/graphql-platform:mainfrom tte/align-mcp-configuration-to-openapiChilliCream/graphql-platform:tte/align-mcp-configuration-to-openapiCopy head branch name to clipboard
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors MCP storage registration by moving IMcpStorage (and related types) into the MCP abstractions package and switching MCP setup to use an options-based StorageFactory delegate, while also tightening misconfiguration diagnostics (OpenAPI + MCP) and adding coverage for these failure modes.
Changes:
- Introduces
McpSetup.StorageFactoryand updates MCP builder extensions (regular + Fusion) to configure storage via named options instead of DI registration. - Updates
McpManager/schema service wiring and endpoint mapping to throw clearerInvalidOperationExceptions when required setup is missing; adds tests for these cases. - Moves MCP storage DTOs + resources into
Adapters.Mcp.Abstractions(includingIMcpStorage, tool/prompt definitions, and resx resources).
Reviewed changes
Copilot reviewed 15 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Extensions/OpenApiSetupTests.cs | Adds test asserting OpenAPI manager throws when storage is not configured. |
| src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Endpoints/HttpEndpointIntegrationTests.cs | Adds integration test asserting endpoint mapping fails when AddOpenApi() wasn’t called. |
| src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/Extensions/McpSetupTests.cs | Adds test asserting MCP manager throws when storage is not configured. |
| src/HotChocolate/Adapters/test/Adapters.Mcp.Tests/CoreIntegrationTests.cs | Adds integration test asserting endpoint mapping fails when AddMcp() wasn’t called. |
| src/HotChocolate/Adapters/src/Fusion.Adapters.Mcp/Extensions/FusionGatewayBuilderExtensions.cs | Refactors Fusion MCP registration to add warmup + configure storage via McpSetup.StorageFactory. |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/OpenApiManager.cs | Updates missing-storage exception message to reference IOpenApiDefinitionStorage and new guidance text. |
| src/HotChocolate/Adapters/src/Adapters.OpenApi.AspNetCore/Extensions/OpenApiEndpointRouteBuilderExtensions.cs | Adds explicit error when endpoints are mapped without OpenAPI services registered. |
| src/HotChocolate/Adapters/src/Adapters.Mcp/Extensions/McpRequestExecutorBuilderExtensions.cs | Refactors MCP registration and storage configuration via McpSetup.StorageFactory; adds warmup task + skipIf. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Core/McpRegistration.cs | Extends registration to carry the schema’s IMcpStorage instance. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Core/McpManager.cs | Creates storage from StorageFactory, includes it in registrations, and disposes it on manager disposal. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Core/HotChocolate.Adapters.Mcp.Core.csproj | Removes embedded resource configuration (resources moved to abstractions). |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Core/Extensions/ServiceCollectionExtensions.cs | Updates schema service wiring to source storage via McpManager rather than DI IMcpStorage registration. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Core/Extensions/McpEndpointRouteBuilderExtensions.cs | Updates missing-service exception message when mapping MCP endpoints without AddMcp(). |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Storage/PromptStorageEventArgs.cs | Adds new abstractions type for prompt storage change notifications. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Storage/PromptDefinition.cs | Adds prompt definition abstraction. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Storage/OperationToolStorageEventArgs.cs | Adds new abstractions type for tool storage change notifications. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Storage/OperationToolDefinition.cs | Adds operation-tool definition abstraction (including validation and view resource URI calculation). |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Storage/IMcpStorage.cs | Adds IMcpStorage abstraction (observable + async retrieval APIs). |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Properties/McpAdapterResources.resx | Adds resource strings moved into abstractions. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Properties/McpAdapterResources.Designer.cs | Adds generated strongly-typed resource accessor moved into abstractions. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/HotChocolate.Adapters.Mcp.Abstractions.csproj | Adds resx embedding + internal visibility to downstream MCP assemblies. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Extensions/StringExtensions.cs | Adds shared string casing/formatting helpers to abstractions. |
| src/HotChocolate/Adapters/src/Adapters.Mcp.Abstractions/Configuration/McpSetup.cs | Adds StorageFactory to MCP per-schema setup options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var registration = lazy.Value; | ||
|
|
||
| if (registration.Storage is IDisposable disposableStorage) | ||
| { | ||
| disposableStorage.Dispose(); | ||
| } | ||
|
|
||
| registration.ExecutorProxy.Dispose(); |
There was a problem hiding this comment.
McpManager.Dispose() disposes IMcpStorage only when it implements IDisposable. If a storage implementation uses IAsyncDisposable (common for I/O resources), it will never be disposed, which can leak handles/watchers/connections. Consider adding async disposal support (e.g., implement IAsyncDisposable on McpManager and dispose async storages) or explicitly document/enforce IDisposable on IMcpStorage implementations.
No description provided.