Ability to set custom protocol version (#117)
This commit is contained in:
parent
85549cb835
commit
09596c0382
3 changed files with 124 additions and 4 deletions
|
|
@ -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, [
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Mcp\Server;
|
||||
|
||||
use Mcp\Schema\Enum\ProtocolVersion;
|
||||
use Mcp\Schema\Implementation;
|
||||
use Mcp\Schema\ServerCapabilities;
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ class Configuration
|
|||
public readonly ServerCapabilities $capabilities,
|
||||
public readonly int $paginationLimit = 50,
|
||||
public readonly ?string $instructions = null,
|
||||
public readonly ?ProtocolVersion $protocolVersion = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ final class InitializeHandler implements RequestHandlerInterface
|
|||
$this->configuration->capabilities ?? new ServerCapabilities(),
|
||||
$this->configuration->serverInfo ?? new Implementation(),
|
||||
$this->configuration?->instructions,
|
||||
null,
|
||||
$this->configuration?->protocolVersion,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue