-
-
Notifications
You must be signed in to change notification settings - Fork 958
feat: mcp bundle tool integration #7595
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
d136520 to
b904a0d
Compare
rvanlaak
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.
Exciting that the mcp repo's schema PR is merged now, and you're able to spend time on API Platform integration.
Tried reviewing this PR without checking it out and testing it, so please feel free to ignore all my comments / suggestions / nitpicks 🙌 Just trying to provide you with another pov at some classes.
src/Mcp/Metadata/Operation/Factory/OperationMetadataFactory.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php
Outdated
Show resolved
Hide resolved
Yeah it was the missing part + now I can also test out to use only the json-schema component's of API Platform to produce MCP SDK's schemas! |
This PR was merged into the main branch. Discussion ---------- [MCP Bundle] bump php-sdk to 0.3 | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | api-platform/core#7595 | License | MIT Commits ------- ce5758f bump php-sdk to 0.3
This PR was merged into the main branch. Discussion ---------- [MCP Bundle] bump php-sdk to 0.3 | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | api-platform/core#7595 | License | MIT Commits ------- ce5758fc bump php-sdk to 0.3
192498f to
7ff8ba8
Compare
13f91e9 to
cc5f55c
Compare
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.
Pull request overview
This PR integrates MCP (Model Context Protocol) tool and resource capabilities into API Platform, enabling developers to expose their API resources as MCP tools and resources with automatic JSON Schema generation, structured content support, and seamless integration with Symfony's serializer and validation systems.
Changes:
- Added
McpToolandMcpResourcemetadata classes that extendHttpOperationfor defining MCP capabilities - Implemented MCP-specific state providers and processors for handling tool calls and resource reads
- Added comprehensive test coverage for MCP functionality including validation, custom results, and markdown content
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php | Added test assertion for new mcp.enabled configuration option |
| tests/Functional/McpTest.php | Added comprehensive functional tests covering MCP tools, resources, validation, and content handling |
| tests/Fixtures/app/config/routing_test.php | Added MCP route imports and removed outdated comments |
| tests/Fixtures/app/config/config_common.yml | Added MCP bundle configuration with HTTP transport and session settings |
| tests/Fixtures/app/AppKernel.php | Registered McpBundle and MonologBundle when MCP is available |
| tests/Fixtures/TestBundle/Entity/McpBook.php | Created test entity demonstrating MCP tool integration with Doctrine entities |
| tests/Fixtures/TestBundle/ApiResource/McpWithMarkdown.php | Created test resource for markdown content generation |
| tests/Fixtures/TestBundle/ApiResource/McpTools.php | Created test resource demonstrating custom results and validation |
| tests/Fixtures/TestBundle/ApiResource/McpToolAttribute.php | Created test resource using #[McpTool] attribute |
| tests/Fixtures/TestBundle/ApiResource/McpResourceExample.php | Created test resource using #[McpResource] attribute |
| src/Symfony/Bundle/Resources/config/mcp/state.php | Configured MCP state processors and handler service |
| src/Symfony/Bundle/Resources/config/mcp/mcp.php | Configured core MCP services including loader and IRI converter |
| src/Symfony/Bundle/Resources/config/mcp/events.php | Configured MCP event-based state processing |
| src/Symfony/Bundle/DependencyInjection/Configuration.php | Added mcp configuration section |
| src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php | Registered MCP metadata classes and loaded MCP service configuration |
| src/Metadata/Tests/Extractor/Adapter/resources.yaml | Added mcp field to test resources |
| src/Metadata/Tests/Extractor/Adapter/XmlResourceAdapter.php | Added support for building MCP operations in XML |
| src/Metadata/Resource/Factory/MetadataCollectionFactoryTrait.php | Added logic to process MCP operations during resource metadata building |
| src/Metadata/McpTool.php | Created metadata class for defining MCP tools |
| src/Metadata/McpResource.php | Created metadata class for defining MCP resources |
| src/Metadata/ApiResource.php | Added mcp property to store MCP operations |
| src/Mcp/State/ToolProvider.php | Implemented state provider for MCP tool requests |
| src/Mcp/State/StructuredContentProcessor.php | Implemented processor for generating structured MCP responses |
| src/Mcp/Server/Handler.php | Implemented MCP request handler |
| src/Mcp/Routing/IriConverter.php | Added IRI converter decorator for MCP operations |
| src/Mcp/Metadata/Operation/Factory/OperationMetadataFactory.php | Implemented factory for retrieving MCP operation metadata |
| src/Mcp/Capability/Registry/Loader.php | Implemented loader for registering MCP tools and resources |
| composer.json | Added MCP SDK and bundle dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
320f687 to
f750e9c
Compare
Rework of #7458
Now with a simpler approach, this gives the ability to add McpTool (upcoming McpResource) to any API Platform environment giving access to:
item_uri_template)CallToolResult(from the php-sdk itself for images, sound etc.)TODO:
#[McpTool]attribute#[McpResource]Because MCP uses JSON-RPC under the hood with some particular response objects (from php-sdk) we can not change returned headers yet (we'll work on an extension point).