diff --git a/src/mcp-bundle/src/Command/McpCommand.php b/src/mcp-bundle/src/Command/McpCommand.php index ee992be21..f939ffc10 100644 --- a/src/mcp-bundle/src/Command/McpCommand.php +++ b/src/mcp-bundle/src/Command/McpCommand.php @@ -32,9 +32,7 @@ public function __construct( protected function execute(InputInterface $input, OutputInterface $output): int { $transport = new StdioTransport(logger: $this->logger); - $this->server->connect($transport); - - $transport->listen(); + $this->server->run($transport); return Command::SUCCESS; } diff --git a/src/mcp-bundle/src/Controller/McpController.php b/src/mcp-bundle/src/Controller/McpController.php index 29f501083..645a0b3e2 100644 --- a/src/mcp-bundle/src/Controller/McpController.php +++ b/src/mcp-bundle/src/Controller/McpController.php @@ -26,7 +26,7 @@ { public function __construct( private Server $server, - private HttpMessageFactoryInterface $psrHttpFactory, + private HttpMessageFactoryInterface $httpMessageFactory, private HttpFoundationFactoryInterface $httpFoundationFactory, private ResponseFactoryInterface $responseFactory, private StreamFactoryInterface $streamFactory, @@ -36,18 +36,15 @@ public function __construct( public function handle(Request $request): Response { - $psrRequest = $this->psrHttpFactory->createRequest($request); - $transport = new StreamableHttpTransport( - $psrRequest, + $this->httpMessageFactory->createRequest($request), $this->responseFactory, $this->streamFactory, $this->logger ?? new NullLogger(), ); - $this->server->connect($transport); - $psrResponse = $transport->listen(); - - return $this->httpFoundationFactory->createResponse($psrResponse); + return $this->httpFoundationFactory->createResponse( + $this->server->run($transport), + ); } }