Skip to content

Conversation

@soyuka
Copy link
Member

@soyuka soyuka commented Oct 15, 2025

Q A
Branch? main
License MIT

Bringing MCP capabilities to API Platform !

This is huge as for every supported operation you will be able to activate MCP support by only setting mcp: true on your resource/operation.

TODO:

  • review this draft
  • add a mcp flag to operation/resource to be able to select which operations to expose (default will be none)
  • missing completion (probably do this in another PR)
  • annotations support
  • decide for formats and check if json-ld is not available how things work
  • test a tool when there's an URI variable
  • [Server] Handler context modelcontextprotocol/php-sdk#108 actually we had to create new RequestHandler and could not use the ones from the SDK because of this issue, I'm wondering if we could make something better

Because of the last issue, we're not using the default handler mechanics and we don't need the following compiler pass:

final class McpPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        if (!$container->hasDefinition('api_platform.mcp.server.builder')) {
            return;
        }

        $handlerServices = [
            'http_kernel' => new Reference('http_kernel'),
            'router' => new Reference('router'),
            'api_platform.mcp.operation_metadata_factory' => new Reference('api_platform.mcp.operation_metadata_factory'),
        ];

        $serviceLocatorRef = ServiceLocatorTagPass::register($container, $handlerServices);
        $container->getDefinition('api_platform.mcp.server.builder')
            ->addMethodCall('setContainer', [$serviceLocatorRef]);
    }
}

I'll keep that here in case we rollback to this implementation.

Note the mcp-bundle is still not released and the php-sdk development is heavily active therefore we should expect things to break, use this at your own risk.

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.

1 participant