Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Configuration
* @param CacheInterface|null $cache Optional PSR-16 Cache instance for registry/state.
* @param ContainerInterface $container PSR-11 DI Container for resolving handlers/dependencies.
* @param int $paginationLimit Maximum number of items to return for list methods.
* @param string|null $instructions Instructions describing how to use the server and its features.
*/
public function __construct(
public readonly Implementation $serverInfo,
Expand All @@ -35,5 +36,6 @@ public function __construct(
public readonly ?CacheInterface $cache,
public readonly ContainerInterface $container,
public readonly int $paginationLimit = 50,
public readonly ?string $instructions = null,
) {}
}
3 changes: 2 additions & 1 deletion src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ public function handleInitialize(InitializeRequest $request, SessionInterface $s

$serverInfo = $this->configuration->serverInfo;
$capabilities = $this->configuration->capabilities;
$instructions = $this->configuration->instructions;

return new InitializeResult($protocolVersion, $capabilities, $serverInfo);
return new InitializeResult($protocolVersion, $capabilities, $serverInfo, $instructions);
}

public function handlePing(PingRequest $request): EmptyResult
Expand Down
19 changes: 18 additions & 1 deletion src/ServerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ final class ServerBuilder

private ?int $paginationLimit = 50;

private ?string $instructions = null;

/** @var array<
* array{handler: array|string,
* name: string|null,
Expand Down Expand Up @@ -120,6 +122,20 @@ public function withPaginationLimit(int $paginationLimit): self
return $this;
}

/**
* Configures the instructions describing how to use the server and its features.
*
* This can be used by clients to improve the LLM's understanding of available tools, resources,
* etc. It can be thought of like a "hint" to the model. For example, this information MAY
* be added to the system prompt.
*/
public function withInstructions(string $instructions): self
{
$this->instructions = $instructions;

return $this;
}

/**
* Provides a PSR-3 logger instance. Defaults to NullLogger.
*/
Expand Down Expand Up @@ -257,7 +273,8 @@ public function build(): Server
loop: $loop,
cache: $cache,
container: $container,
paginationLimit: $this->paginationLimit ?? 50
paginationLimit: $this->paginationLimit ?? 50,
instructions: $this->instructions,
);

$sessionHandler = $this->createSessionHandler();
Expand Down