feat: Add output schema support to MCP tools (#153)
This commit is contained in:
parent
4c3e5e61c7
commit
c0938a19bd
1 changed files with 605 additions and 55 deletions
|
|
@ -65,13 +65,16 @@ final class CallToolHandler implements RequestHandlerInterface
|
|||
|
||||
$result = $this->referenceHandler->handle($reference, $arguments);
|
||||
|
||||
$structuredContent = null;
|
||||
if (!$result instanceof CallToolResult) {
|
||||
$result = new CallToolResult($reference->formatResult($result));
|
||||
$structuredContent = $reference->extractStructuredContent($result);
|
||||
$result = new CallToolResult($reference->formatResult($result), structuredContent: $structuredContent);
|
||||
}
|
||||
|
||||
$this->logger->debug('Tool executed successfully', [
|
||||
'name' => $toolName,
|
||||
'result_type' => \gettype($result),
|
||||
'structured_content' => $structuredContent,
|
||||
]);
|
||||
|
||||
return new Response($request->getId(), $result);
|
||||
|
|
|
|||
Loading…
Reference in a new issue