Ability to set custom protocol version (#117)

This commit is contained in:
ineersa 2025-11-07 18:37:01 -05:00 • committed by GitHub
commit 09596c0382
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ use Mcp\Capability\Registry\Loader\LoaderInterface;
use Mcp\Capability\Registry\ReferenceHandler;
use Mcp\JsonRpc\MessageFactory;
use Mcp\Schema\Annotations;
use Mcp\Schema\Enum\ProtocolVersion;
use Mcp\Schema\Implementation;
use Mcp\Schema\ServerCapabilities;
use Mcp\Schema\ToolAnnotations;
@ -63,6 +64,8 @@ final class Builder
private ?string $instructions = null;
private ?ProtocolVersion $protocolVersion = null;
/**
* @var array<int, RequestHandlerInterface<mixed>>
*/
@ -288,6 +291,13 @@ final class Builder
return $this;
}
public function setProtocolVersion(?ProtocolVersion $protocolVersion): self
{
$this->protocolVersion = $protocolVersion;
return $this;
}
/**
* Manually registers a tool handler.
*
@ -404,7 +414,7 @@ final class Builder
$messageFactory = MessageFactory::make();
$capabilities = $registry->getCapabilities();
$configuration = new Configuration($this->serverInfo, $capabilities, $this->paginationLimit, $this->instructions);
$configuration = new Configuration($this->serverInfo, $capabilities, $this->paginationLimit, $this->instructions, $this->protocolVersion);
$referenceHandler = new ReferenceHandler($container);
$requestHandlers = array_merge($this->requestHandlers, [