php-sdk/tests/Unit/Fixtures/ThrowingRequest.php
Christopher Hertel c8ed07bba2
[Server] Handle malformed JSON-RPC input graceful (#412)
* Never let a throwable escape Protocol::processInput()

* Validate payload types in the schema hydration methods

* Stop leaking handler exception messages to the client
2026-08-14 22:34:01 +02:00

38 lines
962 B
PHP

<?php
/*
* This file is part of the official PHP MCP SDK.
*
* A collaboration between Symfony and the PHP Foundation.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Mcp\Tests\Unit\Fixtures;
use Mcp\Schema\JsonRpc\Request;
/**
* Stands in for a message class that fails with an unexpected throwable instead of a proper
* InvalidInputMessageException, e.g. through a PHP TypeError caused by an unvalidated payload.
*
* @author Christopher Hertel <mail@christopher-hertel.de>
*/
final class ThrowingRequest extends Request
{
public static function getMethod(): string
{
return 'test/throwing';
}
protected static function fromParams(?array $params): static
{
throw new \TypeError('Internal detail that must not leak to the client.');
}
protected function getParams(): ?array
{
return null;
}
}