server error if tool declares outputSchema but no structuredContent in result
This commit is contained in:
parent
a41b174330
commit
aeb7b8d741
1 changed files with 72 additions and 1 deletions
|
|
@ -198,7 +198,14 @@ export class McpServer {
|
|||
}
|
||||
}
|
||||
|
||||
if (tool.outputSchema && result.structuredContent) {
|
||||
if (tool.outputSchema) {
|
||||
if (!result.structuredContent) {
|
||||
throw new McpError(
|
||||
ErrorCode.InvalidParams,
|
||||
`Tool ${request.params.name} has an output schema but no structured content was provided`,
|
||||
);
|
||||
}
|
||||
|
||||
// if the tool has an output schema, validate structured content
|
||||
const parseResult = await tool.outputSchema.safeParseAsync(
|
||||
result.structuredContent,
|
||||
|
|
|
|||
Loading…
Reference in a new issue