Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/Transports/HttpServerTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ class HttpServerTransport implements LoggerAwareInterface, LoopAwareInterface, S

protected LoopInterface $loop;

private ?SocketServer $socket = null;
protected ?SocketServer $socket = null;

private ?HttpServer $http = null;
protected ?HttpServer $http = null;

/** @var array<string, ThroughStream> clientId => SSE Stream */
private array $activeSseStreams = [];
protected array $activeSseStreams = [];

private bool $listening = false;
protected bool $listening = false;

private bool $closing = false;
protected bool $closing = false;

private string $ssePath;
protected string $ssePath;

private string $messagePath;
protected string $messagePath;

/**
* @param string $host Host to bind to (e.g., '127.0.0.1', '0.0.0.0').
Expand All @@ -61,10 +61,10 @@ class HttpServerTransport implements LoggerAwareInterface, LoopAwareInterface, S
* @param array|null $sslContext Optional SSL context options for React SocketServer (for HTTPS).
*/
public function __construct(
private readonly string $host = '127.0.0.1',
private readonly int $port = 8080,
private readonly string $mcpPathPrefix = 'mcp', // e.g., /mcp/sse, /mcp/message
private readonly ?array $sslContext = null // For enabling HTTPS
protected readonly string $host = '127.0.0.1',
protected readonly int $port = 8080,
protected readonly string $mcpPathPrefix = 'mcp', // e.g., /mcp/sse, /mcp/message
protected readonly ?array $sslContext = null // For enabling HTTPS
) {
$this->logger = new NullLogger();
$this->loop = Loop::get();
Expand Down Expand Up @@ -129,7 +129,7 @@ public function listen(): void
}

/** Creates the main request handling callback for ReactPHP HttpServer */
private function createRequestHandler(): callable
protected function createRequestHandler(): callable
{
return function (ServerRequestInterface $request) {
$path = $request->getUri()->getPath();
Expand All @@ -154,7 +154,7 @@ private function createRequestHandler(): callable
}

/** Handles a new SSE connection request */
private function handleSseRequest(ServerRequestInterface $request): Response
protected function handleSseRequest(ServerRequestInterface $request): Response
{
$clientId = 'sse_' . bin2hex(random_bytes(16));
$this->logger->info('New SSE connection', ['clientId' => $clientId]);
Expand Down Expand Up @@ -208,7 +208,7 @@ private function handleSseRequest(ServerRequestInterface $request): Response
}

/** Handles incoming POST requests with messages */
private function handleMessagePostRequest(ServerRequestInterface $request): Response
protected function handleMessagePostRequest(ServerRequestInterface $request): Response
{
$queryParams = $request->getQueryParams();
$clientId = $queryParams['clientId'] ?? null;
Expand Down