Make logger nullable in Transport constructors (#152)

- BaseTransport: Accept ?LoggerInterface parameter and convert null to NullLogger
- StdioTransport: Change logger parameter to nullable
- StreamableHttpTransport: Change logger parameter to nullable
- InMemoryTransport: Fix missing parent::__construct() call and add logging
This commit is contained in:
Camille Islasse 2025-11-20 19:48:17 +01:00 • committed by GitHub
commit 470237ad0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,7 +18,6 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\Uid\Uuid;
/**
@ -45,7 +44,7 @@ class StreamableHttpTransport extends BaseTransport implements TransportInterfac
?ResponseFactoryInterface $responseFactory = null,
?StreamFactoryInterface $streamFactory = null,
array $corsHeaders = [],
LoggerInterface $logger = new NullLogger(),
?LoggerInterface $logger = null,
) {
parent::__construct($logger);
$sessionIdString = $this->request->getHeaderLine('Mcp-Session-Id');