Skip to content

Commit e4e3e5b

Browse files
committed
bug #774 [MCP Bundle] Adopt new interface of MCP server (chr-hertel)
This PR was merged into the main branch. Discussion ---------- [MCP Bundle] Adopt new interface of MCP server | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Docs? | no | Issues | | License | MIT Follows modelcontextprotocol/php-sdk#103 Commits ------- 6099b4d Adopt new interface of MCP server
2 parents 0eeb101 + 6099b4d commit e4e3e5b

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/mcp-bundle/src/Command/McpCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ public function __construct(
3232
protected function execute(InputInterface $input, OutputInterface $output): int
3333
{
3434
$transport = new StdioTransport(logger: $this->logger);
35-
$this->server->connect($transport);
36-
37-
$transport->listen();
35+
$this->server->run($transport);
3836

3937
return Command::SUCCESS;
4038
}

src/mcp-bundle/src/Controller/McpController.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{
2727
public function __construct(
2828
private Server $server,
29-
private HttpMessageFactoryInterface $psrHttpFactory,
29+
private HttpMessageFactoryInterface $httpMessageFactory,
3030
private HttpFoundationFactoryInterface $httpFoundationFactory,
3131
private ResponseFactoryInterface $responseFactory,
3232
private StreamFactoryInterface $streamFactory,
@@ -36,18 +36,15 @@ public function __construct(
3636

3737
public function handle(Request $request): Response
3838
{
39-
$psrRequest = $this->psrHttpFactory->createRequest($request);
40-
4139
$transport = new StreamableHttpTransport(
42-
$psrRequest,
40+
$this->httpMessageFactory->createRequest($request),
4341
$this->responseFactory,
4442
$this->streamFactory,
4543
$this->logger ?? new NullLogger(),
4644
);
4745

48-
$this->server->connect($transport);
49-
$psrResponse = $transport->listen();
50-
51-
return $this->httpFoundationFactory->createResponse($psrResponse);
46+
return $this->httpFoundationFactory->createResponse(
47+
$this->server->run($transport),
48+
);
5249
}
5350
}

0 commit comments

Comments
 (0)