Skip to content

Commit 6fd7513

Browse files
ochafikclaude
andcommitted
fix: Ensure tools/list returns valid JSON Schema for all tools
- Always return inputSchema as object (never undefined) - Keep filter for enabled tools only in list - Update test to match behavior (only enabled tools in list) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 8b51250 commit 6fd7513

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/app-bridge.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ describe("App <-> AppBridge integration", () => {
989989
expect(result.tools.map((t) => t.name)).toEqual(["tool3"]);
990990
});
991991

992-
it("includes both enabled and disabled tools in list", async () => {
992+
it("only includes enabled tools in list", async () => {
993993
const appCapabilities = { tools: { listChanged: true } };
994994
app = new App(testAppInfo, appCapabilities, { autoResize: false });
995995

@@ -1015,10 +1015,10 @@ describe("App <-> AppBridge integration", () => {
10151015

10161016
const result = await bridge.sendListTools({});
10171017

1018-
// Both tools should be in the list
1019-
expect(result.tools).toHaveLength(2);
1018+
// Only enabled tool should be in the list
1019+
expect(result.tools).toHaveLength(1);
10201020
expect(result.tools.map((t) => t.name)).toContain("enabled-tool");
1021-
expect(result.tools.map((t) => t.name)).toContain("disabled-tool");
1021+
expect(result.tools.map((t) => t.name)).not.toContain("disabled-tool");
10221022
});
10231023
});
10241024

src/app.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -329,21 +329,22 @@ export class App extends Protocol<Request, Notification, Result> {
329329
this.onlisttools = async (_params, _extra) => {
330330
const tools: Tool[] = Object.entries(this._registeredTools)
331331
.filter(([_, tool]) => tool.enabled)
332-
.map(
333-
([name, tool]) =>
334-
<Tool>{
335-
name,
336-
description: tool.description,
337-
inputSchema: tool.inputSchema
338-
? z.toJSONSchema(tool.inputSchema as ZodSchema)
339-
: undefined,
340-
outputSchema: tool.outputSchema
341-
? z.toJSONSchema(tool.outputSchema as ZodSchema)
342-
: undefined,
343-
annotations: tool.annotations,
344-
_meta: tool._meta,
345-
},
346-
);
332+
.map(([name, tool]) => {
333+
const result: Tool = {
334+
name,
335+
description: tool.description,
336+
inputSchema: tool.inputSchema
337+
? z.toJSONSchema(tool.inputSchema as ZodSchema)
338+
: { type: "object" as const, properties: {} },
339+
};
340+
if (tool.annotations) {
341+
result.annotations = tool.annotations;
342+
}
343+
if (tool._meta) {
344+
result._meta = tool._meta;
345+
}
346+
return result;
347+
});
347348
return { tools };
348349
};
349350
}

0 commit comments

Comments
 (0)