diff --git a/packages/http/src/Ip/ClientIpResolver.php b/packages/http/src/Ip/ClientIpResolver.php index 910bcfc3e..0074c29e8 100644 --- a/packages/http/src/Ip/ClientIpResolver.php +++ b/packages/http/src/Ip/ClientIpResolver.php @@ -21,7 +21,7 @@ public function resolve(IpAddress|string|null $remoteAddress, RequestHeaders $he { $remoteAddress = $this->parse($remoteAddress); - if ($remoteAddress === null || ! $this->trustedProxies->trusts($remoteAddress)) { + if (! $remoteAddress instanceof IpAddress || ! $this->trustedProxies->trusts($remoteAddress)) { return $remoteAddress; } diff --git a/packages/mcp/src/McpRequestHandler.php b/packages/mcp/src/McpRequestHandler.php index 99919585f..9f2b35c73 100644 --- a/packages/mcp/src/McpRequestHandler.php +++ b/packages/mcp/src/McpRequestHandler.php @@ -200,6 +200,7 @@ private function listResources(McpServerDefinition $server): array ]; } } + return ['resources' => $resources]; } diff --git a/packages/mcp/src/StdioTransport.php b/packages/mcp/src/StdioTransport.php index 283a95d76..13f25b5fe 100644 --- a/packages/mcp/src/StdioTransport.php +++ b/packages/mcp/src/StdioTransport.php @@ -42,6 +42,7 @@ public function run(McpServerDefinition $server, mixed $input, mixed $output): v continue; } + $line = trim($line); if ($line === '') { diff --git a/packages/support/src/Ip/IpAddress.php b/packages/support/src/Ip/IpAddress.php index b59f6680d..223b6666d 100644 --- a/packages/support/src/Ip/IpAddress.php +++ b/packages/support/src/Ip/IpAddress.php @@ -16,13 +16,6 @@ */ final class IpAddress implements Stringable, Equable { - /** - * The packed representation of the address. IPv4-mapped IPv6 addresses, such as `::ffff:127.0.0.1`, are narrowed to their IPv4 form. - * - * @internal - */ - private(set) string $bytes; - /** * Whether the address is an IPv4 address. */ @@ -49,10 +42,13 @@ private function __construct( * The address as it was given. */ private(set) string $value, - string $bytes, - ) { - $this->bytes = $bytes; - } + /** + * The packed representation of the address. IPv4-mapped IPv6 addresses, such as `::ffff:127.0.0.1`, are narrowed to their IPv4 form. + * + * @internal + */ + private(set) string $bytes, + ) {} /** * Creates an address from the given notation, throwing when it is not an address. diff --git a/src/Tempest/Framework/Testing/Http/HttpRouterTester.php b/src/Tempest/Framework/Testing/Http/HttpRouterTester.php index 075824c85..15c636153 100644 --- a/src/Tempest/Framework/Testing/Http/HttpRouterTester.php +++ b/src/Tempest/Framework/Testing/Http/HttpRouterTester.php @@ -314,7 +314,7 @@ public function makePsrRequest( $_POST = is_array($body) ? $body : []; - $server = $this->ip === null ? $_SERVER : [...$_SERVER, 'REMOTE_ADDR' => $this->ip->toString()]; + $server = $this->ip instanceof IpAddress ? [...$_SERVER, 'REMOTE_ADDR' => $this->ip->toString()] : $_SERVER; return ServerRequestFactory::fromGlobals($server)->withUploadedFiles($files); } diff --git a/tests/Integration/Mcp/McpStdioTest.php b/tests/Integration/Mcp/McpStdioTest.php index 27d2e4710..adfce95bc 100644 --- a/tests/Integration/Mcp/McpStdioTest.php +++ b/tests/Integration/Mcp/McpStdioTest.php @@ -90,6 +90,7 @@ public function socket_timeouts_do_not_stop_the_message_loop(): void fclose($pipe); } + stream_set_timeout($input, seconds: 0, microseconds: 25_000); $server = $this->container->get(McpConfig::class)->servers[StdioMcpServer::class];