Fix missing instructions from builder to handler (#90)
This commit is contained in:
parent
d06b57d285
commit
cbd1b298e9
5 changed files with 16 additions and 15 deletions
|
|
@ -20,6 +20,7 @@ logger()->info('Starting MCP Stdio Calculator Server...');
|
||||||
|
|
||||||
$server = Server::builder()
|
$server = Server::builder()
|
||||||
->setServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
|
->setServerInfo('Stdio Calculator', '1.1.0', 'Basic Calculator over STDIO transport.')
|
||||||
|
->setInstructions('This server supports basic arithmetic operations: add, subtract, multiply, and divide. Send JSON-RPC requests to perform calculations.')
|
||||||
->setContainer(container())
|
->setContainer(container())
|
||||||
->setLogger(logger())
|
->setLogger(logger())
|
||||||
->setDiscovery(__DIR__, ['.'])
|
->setDiscovery(__DIR__, ['.'])
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,3 @@ parameters:
|
||||||
identifier: return.type
|
identifier: return.type
|
||||||
count: 1
|
count: 1
|
||||||
path: src/Schema/Result/ReadResourceResult.php
|
path: src/Schema/Result/ReadResourceResult.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Property Mcp\\Server\\Builder\:\:\$instructions is never read, only written\.$#'
|
|
||||||
identifier: property.onlyWritten
|
|
||||||
count: 1
|
|
||||||
path: src/Server/Builder.php
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -362,14 +362,17 @@ final class Builder
|
||||||
jsonRpcHandler: JsonRpcHandler::make(
|
jsonRpcHandler: JsonRpcHandler::make(
|
||||||
registry: $registry,
|
registry: $registry,
|
||||||
referenceProvider: $registry,
|
referenceProvider: $registry,
|
||||||
implementation: $this->serverInfo,
|
configuration: new Configuration(
|
||||||
|
$this->serverInfo,
|
||||||
|
$registry->getCapabilities(),
|
||||||
|
$this->paginationLimit, $this->instructions,
|
||||||
|
),
|
||||||
toolCaller: $toolCaller,
|
toolCaller: $toolCaller,
|
||||||
resourceReader: $resourceReader,
|
resourceReader: $resourceReader,
|
||||||
promptGetter: $promptGetter,
|
promptGetter: $promptGetter,
|
||||||
sessionStore: $sessionStore,
|
sessionStore: $sessionStore,
|
||||||
sessionFactory: $sessionFactory,
|
sessionFactory: $sessionFactory,
|
||||||
logger: $logger,
|
logger: $logger,
|
||||||
paginationLimit: $this->paginationLimit,
|
|
||||||
),
|
),
|
||||||
logger: $logger,
|
logger: $logger,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ use Mcp\Exception\HandlerNotFoundException;
|
||||||
use Mcp\Exception\InvalidInputMessageException;
|
use Mcp\Exception\InvalidInputMessageException;
|
||||||
use Mcp\Exception\NotFoundExceptionInterface;
|
use Mcp\Exception\NotFoundExceptionInterface;
|
||||||
use Mcp\JsonRpc\MessageFactory;
|
use Mcp\JsonRpc\MessageFactory;
|
||||||
use Mcp\Schema\Implementation;
|
|
||||||
use Mcp\Schema\JsonRpc\Error;
|
use Mcp\Schema\JsonRpc\Error;
|
||||||
use Mcp\Schema\JsonRpc\HasMethodInterface;
|
use Mcp\Schema\JsonRpc\HasMethodInterface;
|
||||||
use Mcp\Schema\JsonRpc\Request;
|
use Mcp\Schema\JsonRpc\Request;
|
||||||
use Mcp\Schema\JsonRpc\Response;
|
use Mcp\Schema\JsonRpc\Response;
|
||||||
use Mcp\Schema\Request\InitializeRequest;
|
use Mcp\Schema\Request\InitializeRequest;
|
||||||
|
use Mcp\Server\Configuration;
|
||||||
use Mcp\Server\Handler;
|
use Mcp\Server\Handler;
|
||||||
use Mcp\Server\Session\SessionFactoryInterface;
|
use Mcp\Server\Session\SessionFactoryInterface;
|
||||||
use Mcp\Server\Session\SessionInterface;
|
use Mcp\Server\Session\SessionInterface;
|
||||||
|
|
@ -66,7 +66,7 @@ class JsonRpcHandler
|
||||||
public static function make(
|
public static function make(
|
||||||
ReferenceRegistryInterface $registry,
|
ReferenceRegistryInterface $registry,
|
||||||
ReferenceProviderInterface $referenceProvider,
|
ReferenceProviderInterface $referenceProvider,
|
||||||
Implementation $implementation,
|
Configuration $configuration,
|
||||||
ToolCallerInterface $toolCaller,
|
ToolCallerInterface $toolCaller,
|
||||||
ResourceReaderInterface $resourceReader,
|
ResourceReaderInterface $resourceReader,
|
||||||
PromptGetterInterface $promptGetter,
|
PromptGetterInterface $promptGetter,
|
||||||
|
|
@ -81,7 +81,7 @@ class JsonRpcHandler
|
||||||
sessionStore: $sessionStore,
|
sessionStore: $sessionStore,
|
||||||
methodHandlers: [
|
methodHandlers: [
|
||||||
new Notification\InitializedHandler(),
|
new Notification\InitializedHandler(),
|
||||||
new Handler\Request\InitializeHandler($registry->getCapabilities(), $implementation),
|
new Handler\Request\InitializeHandler($configuration),
|
||||||
new Handler\Request\PingHandler(),
|
new Handler\Request\PingHandler(),
|
||||||
new Handler\Request\ListPromptsHandler($referenceProvider, $paginationLimit),
|
new Handler\Request\ListPromptsHandler($referenceProvider, $paginationLimit),
|
||||||
new Handler\Request\GetPromptHandler($promptGetter),
|
new Handler\Request\GetPromptHandler($promptGetter),
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use Mcp\Schema\JsonRpc\Response;
|
||||||
use Mcp\Schema\Request\InitializeRequest;
|
use Mcp\Schema\Request\InitializeRequest;
|
||||||
use Mcp\Schema\Result\InitializeResult;
|
use Mcp\Schema\Result\InitializeResult;
|
||||||
use Mcp\Schema\ServerCapabilities;
|
use Mcp\Schema\ServerCapabilities;
|
||||||
|
use Mcp\Server\Configuration;
|
||||||
use Mcp\Server\Handler\MethodHandlerInterface;
|
use Mcp\Server\Handler\MethodHandlerInterface;
|
||||||
use Mcp\Server\Session\SessionInterface;
|
use Mcp\Server\Session\SessionInterface;
|
||||||
|
|
||||||
|
|
@ -26,8 +27,7 @@ use Mcp\Server\Session\SessionInterface;
|
||||||
final class InitializeHandler implements MethodHandlerInterface
|
final class InitializeHandler implements MethodHandlerInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly ?ServerCapabilities $capabilities = new ServerCapabilities(),
|
public readonly ?Configuration $configuration = null,
|
||||||
public readonly ?Implementation $serverInfo = new Implementation(),
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +44,11 @@ final class InitializeHandler implements MethodHandlerInterface
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
$message->getId(),
|
$message->getId(),
|
||||||
new InitializeResult($this->capabilities, $this->serverInfo),
|
new InitializeResult(
|
||||||
|
$this->configuration->capabilities ?? new ServerCapabilities(),
|
||||||
|
$this->configuration->serverInfo ?? new Implementation(),
|
||||||
|
$this->configuration?->instructions,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue