[Client] Reject non-positive timeouts in Configuration (#415)

* [Client] Reject non-positive timeouts in Configuration

* [Client] Drop redundant comments on timeout validation
This commit is contained in:
Christopher Hertel 2026-08-14 08:22:20 +02:00 • committed by GitHub
commit d9b3c0ba4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,6 +11,7 @@
namespace Mcp\Client;
use Mcp\Exception\InvalidArgumentException;
use Mcp\Schema\ClientCapabilities;
use Mcp\Schema\Enum\ProtocolVersion;
use Mcp\Schema\Implementation;
@ -30,5 +31,12 @@ class Configuration
public readonly int $requestTimeout = 120,
public readonly int $maxRetries = 3,
) {
if ($initTimeout < 1) {
throw new InvalidArgumentException(\sprintf('The initialization timeout must be a positive number of seconds, got %d.', $initTimeout));
}
if ($requestTimeout < 1) {
throw new InvalidArgumentException(\sprintf('The request timeout must be a positive number of seconds, got %d.', $requestTimeout));
}
}
}