Skip to content

Commit 571c215

Browse files
ochafikclaude
andcommitted
fix(registerTool): output validation, title in tools/list, outputSchema emission
- Output schema validation no longer returns parseResult.data (the validated structuredContent alone) instead of the full CallToolResult. - tools/list now includes the tool title field. - outputSchema is only emitted when the tool defines one (previously always emitted a placeholder { type: "object", properties: {} }). - Remove unused Request/Result imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d4083ab commit 571c215

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/app.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import {
2323
ReadResourceRequest,
2424
ReadResourceResult,
2525
ReadResourceResultSchema,
26-
Request,
27-
Result,
2826
Tool,
2927
ToolAnnotations,
3028
ToolListChangedNotification,
@@ -387,7 +385,6 @@ export class App extends ProtocolWithEvents<
387385
`Invalid output for tool ${name}: ${parseResult.error}`,
388386
);
389387
}
390-
return parseResult.data;
391388
}
392389
return result;
393390
}) as any,
@@ -433,20 +430,20 @@ export class App extends ProtocolWithEvents<
433430
.map(([name, tool]) => {
434431
const result: Tool = {
435432
name,
433+
title: tool.title,
436434
description: tool.description,
437435
inputSchema: (tool.inputSchema
438436
? z.toJSONSchema(tool.inputSchema as ZodSchema)
439437
: {
440438
type: "object" as const,
441439
properties: {},
442440
}) as Tool["inputSchema"],
443-
outputSchema: (tool.outputSchema
444-
? z.toJSONSchema(tool.outputSchema as ZodSchema)
445-
: {
446-
type: "object" as const,
447-
properties: {},
448-
}) as Tool["outputSchema"],
449441
};
442+
if (tool.outputSchema) {
443+
result.outputSchema = z.toJSONSchema(
444+
tool.outputSchema as ZodSchema,
445+
) as Tool["outputSchema"];
446+
}
450447
if (tool.annotations) {
451448
result.annotations = tool.annotations;
452449
}

0 commit comments

Comments
 (0)