[Server] Keep injectable parameters out of the published inputSchema (#482)
This commit is contained in:
parent
ff0b5fadc8
commit
e173367c5f
1 changed files with 156 additions and 18 deletions
|
|
@ -16,6 +16,7 @@
|
|||
use Mcp\Exception\ClientException;
|
||||
use Mcp\Schema\Content\TextContent;
|
||||
use Mcp\Server;
|
||||
use Mcp\Server\ClientGateway;
|
||||
use Mcp\Server\RequestContext;
|
||||
use Mcp\Server\Transport\StdioTransport;
|
||||
|
||||
|
|
@ -38,5 +39,20 @@ Server::builder()
|
|||
name: 'summarize',
|
||||
description: 'Summarizes text by asking the client to sample.',
|
||||
)
|
||||
->addTool(
|
||||
static function (ClientGateway $client, string $text): string {
|
||||
try {
|
||||
$result = $client->sample($text, maxTokens: 64);
|
||||
} catch (ClientException $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
assert($result->content instanceof TextContent);
|
||||
|
||||
return sprintf('%s said: %s', $result->model, $result->content->text);
|
||||
},
|
||||
name: 'summarize_via_gateway',
|
||||
description: 'Summarizes text through a directly injected gateway.',
|
||||
)
|
||||
->build()
|
||||
->run(new StdioTransport());
|
||||
|
|
|
|||
Loading…
Reference in a new issue