[Server] Simplify server entrypoint with run-based transport lifecycle (#103)

* feat: replace connect/listen flow with run lifecycle

* feat(transport): add phpstan generics for typed transport returns

* refactor: standardize variable naming for MCP server instances in transport handling

* test: remove unnecessary phpstan-ignore annotation in DocBlockTestFixture
This commit is contained in:
Kyrian Obikwelu 2025-10-10 18:52:06 +01:00 • committed by GitHub
commit 2dbd411194
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -108,8 +108,8 @@ $server = Server::builder()
->build();
$transport = new StdioTransport();
$server->connect($transport);
$transport->listen();
$server->run($transport);
```
### 3. Configure Your MCP Client
@ -175,15 +175,13 @@ $server = Server::builder()
**STDIO Transport** (Command-line integration):
```php
$transport = new StdioTransport();
$server->connect($transport);
$transport->listen();
$server->run($transport);
```
**HTTP Transport** (Web-based communication):
```php
$transport = new StreamableHttpTransport($request, $responseFactory, $streamFactory);
$server->connect($transport);
$response = $transport->listen();
$response = $server->run($transport);
// Handle $response in your web application
```