Skip to content

Commit b705c14

Browse files
committed
refactor: Rename sendCallTool/sendListTools to callTool/listTools
Avoid double-verb naming pattern for consistency with existing API.
1 parent 4024038 commit b705c14

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

src/app-bridge.test.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ describe("App <-> AppBridge integration", () => {
818818
await bridge.connect(bridgeTransport);
819819
});
820820

821-
it("bridge.sendCallTool calls app.oncalltool handler", async () => {
821+
it("bridge.callTool calls app.oncalltool handler", async () => {
822822
// App needs tool capabilities to handle tool calls
823823
const appCapabilities = { tools: {} };
824824
app = new App(testAppInfo, appCapabilities, { autoResize: false });
@@ -834,7 +834,7 @@ describe("App <-> AppBridge integration", () => {
834834

835835
await app.connect(appTransport);
836836

837-
const result = await bridge.sendCallTool({
837+
const result = await bridge.callTool({
838838
name: "test-tool",
839839
arguments: { foo: "bar" },
840840
});
@@ -849,7 +849,7 @@ describe("App <-> AppBridge integration", () => {
849849
]);
850850
});
851851

852-
it("bridge.sendListTools calls app.onlisttools handler", async () => {
852+
it("bridge.listTools calls app.onlisttools handler", async () => {
853853
// App needs tool capabilities to handle tool list requests
854854
const appCapabilities = { tools: {} };
855855
app = new App(testAppInfo, appCapabilities, { autoResize: false });
@@ -881,7 +881,7 @@ describe("App <-> AppBridge integration", () => {
881881

882882
await app.connect(appTransport);
883883

884-
const result = await bridge.sendListTools({});
884+
const result = await bridge.listTools({});
885885

886886
expect(receivedCalls).toHaveLength(1);
887887
expect(result.tools).toHaveLength(3);
@@ -907,7 +907,7 @@ describe("App <-> AppBridge integration", () => {
907907
await bridge.connect(bridgeTransport);
908908
await app.connect(appTransport);
909909

910-
await bridge.sendCallTool({
910+
await bridge.callTool({
911911
name: "test-tool",
912912
arguments: {},
913913
});
@@ -940,7 +940,7 @@ describe("App <-> AppBridge integration", () => {
940940
await bridge.connect(bridgeTransport);
941941
await app.connect(appTransport);
942942

943-
const result = await bridge.sendCallTool({
943+
const result = await bridge.callTool({
944944
name: "greet",
945945
arguments: { name: "Alice" },
946946
});
@@ -974,7 +974,7 @@ describe("App <-> AppBridge integration", () => {
974974
await app.connect(appTransport);
975975

976976
// Call the tool through bridge - should work automatically
977-
const result = await bridge.sendCallTool({
977+
const result = await bridge.callTool({
978978
name: "greet",
979979
arguments: { name: "Bob" },
980980
});
@@ -995,7 +995,7 @@ describe("App <-> AppBridge integration", () => {
995995

996996
// Try to call a tool that doesn't exist
997997
await expect(
998-
bridge.sendCallTool({
998+
bridge.callTool({
999999
name: "nonexistent",
10001000
arguments: {},
10011001
}),
@@ -1044,7 +1044,7 @@ describe("App <-> AppBridge integration", () => {
10441044
await app.connect(appTransport);
10451045

10461046
// Call first tool
1047-
const addResult = await bridge.sendCallTool({
1047+
const addResult = await bridge.callTool({
10481048
name: "add",
10491049
arguments: { a: 5, b: 3 },
10501050
});
@@ -1053,7 +1053,7 @@ describe("App <-> AppBridge integration", () => {
10531053
]);
10541054

10551055
// Call second tool
1056-
const multiplyResult = await bridge.sendCallTool({
1056+
const multiplyResult = await bridge.callTool({
10571057
name: "multiply",
10581058
arguments: { a: 5, b: 3 },
10591059
});
@@ -1080,15 +1080,15 @@ describe("App <-> AppBridge integration", () => {
10801080

10811081
// Should work when enabled
10821082
await expect(
1083-
bridge.sendCallTool({ name: "test-tool", arguments: {} }),
1083+
bridge.callTool({ name: "test-tool", arguments: {} }),
10841084
).resolves.toBeDefined();
10851085

10861086
// Disable tool
10871087
tool.disable();
10881088

10891089
// Should throw when disabled
10901090
await expect(
1091-
bridge.sendCallTool({ name: "test-tool", arguments: {} }),
1091+
bridge.callTool({ name: "test-tool", arguments: {} }),
10921092
).rejects.toThrow("Tool test-tool is disabled");
10931093
});
10941094

@@ -1114,15 +1114,15 @@ describe("App <-> AppBridge integration", () => {
11141114

11151115
// Valid input should work
11161116
await expect(
1117-
bridge.sendCallTool({
1117+
bridge.callTool({
11181118
name: "strict-tool",
11191119
arguments: { required: "hello" },
11201120
}),
11211121
).resolves.toBeDefined();
11221122

11231123
// Invalid input should fail
11241124
await expect(
1125-
bridge.sendCallTool({
1125+
bridge.callTool({
11261126
name: "strict-tool",
11271127
arguments: { wrong: "field" },
11281128
}),
@@ -1150,7 +1150,7 @@ describe("App <-> AppBridge integration", () => {
11501150
await app.connect(appTransport);
11511151

11521152
// Valid output should work
1153-
const result = await bridge.sendCallTool({
1153+
const result = await bridge.callTool({
11541154
name: "validated-output",
11551155
arguments: {},
11561156
});
@@ -1172,7 +1172,7 @@ describe("App <-> AppBridge integration", () => {
11721172
await app.connect(appTransport);
11731173

11741174
// First version
1175-
let result = await bridge.sendCallTool({
1175+
let result = await bridge.callTool({
11761176
name: "dynamic-tool",
11771177
arguments: {},
11781178
});
@@ -1183,7 +1183,7 @@ describe("App <-> AppBridge integration", () => {
11831183

11841184
// Should fail after removal
11851185
await expect(
1186-
bridge.sendCallTool({ name: "dynamic-tool", arguments: {} }),
1186+
bridge.callTool({ name: "dynamic-tool", arguments: {} }),
11871187
).rejects.toThrow("Tool dynamic-tool not found");
11881188

11891189
// Re-register with different behavior
@@ -1192,7 +1192,7 @@ describe("App <-> AppBridge integration", () => {
11921192
}));
11931193

11941194
// Should work with new version
1195-
result = await bridge.sendCallTool({
1195+
result = await bridge.callTool({
11961196
name: "dynamic-tool",
11971197
arguments: {},
11981198
});
@@ -1218,7 +1218,7 @@ describe("App <-> AppBridge integration", () => {
12181218

12191219
await app.connect(appTransport);
12201220

1221-
const result = await bridge.sendListTools({});
1221+
const result = await bridge.listTools({});
12221222

12231223
expect(result.tools).toHaveLength(3);
12241224
expect(result.tools.map((t) => t.name)).toContain("tool1");
@@ -1241,7 +1241,7 @@ describe("App <-> AppBridge integration", () => {
12411241
// Remove the tool after connecting
12421242
dummyTool.remove();
12431243

1244-
const result = await bridge.sendListTools({});
1244+
const result = await bridge.listTools({});
12451245

12461246
expect(result.tools).toEqual([]);
12471247
});
@@ -1260,7 +1260,7 @@ describe("App <-> AppBridge integration", () => {
12601260
dummy.remove();
12611261

12621262
// Initially no tools
1263-
let result = await bridge.sendListTools({});
1263+
let result = await bridge.listTools({});
12641264
expect(result.tools).toEqual([]);
12651265

12661266
// Add a tool
@@ -1269,7 +1269,7 @@ describe("App <-> AppBridge integration", () => {
12691269
}));
12701270

12711271
// Should now include the new tool
1272-
result = await bridge.sendListTools({});
1272+
result = await bridge.listTools({});
12731273
expect(result.tools.map((t) => t.name)).toEqual(["new-tool"]);
12741274

12751275
// Add another tool
@@ -1278,7 +1278,7 @@ describe("App <-> AppBridge integration", () => {
12781278
}));
12791279

12801280
// Should now include both tools
1281-
result = await bridge.sendListTools({});
1281+
result = await bridge.listTools({});
12821282
expect(result.tools).toHaveLength(2);
12831283
expect(result.tools.map((t) => t.name)).toContain("new-tool");
12841284
expect(result.tools.map((t) => t.name)).toContain("another-tool");
@@ -1301,14 +1301,14 @@ describe("App <-> AppBridge integration", () => {
13011301
await app.connect(appTransport);
13021302

13031303
// Initially all three tools
1304-
let result = await bridge.sendListTools({});
1304+
let result = await bridge.listTools({});
13051305
expect(result.tools).toHaveLength(3);
13061306

13071307
// Remove one tool
13081308
tool2.remove();
13091309

13101310
// Should now have two tools
1311-
result = await bridge.sendListTools({});
1311+
result = await bridge.listTools({});
13121312
expect(result.tools).toHaveLength(2);
13131313
expect(result.tools.map((t) => t.name)).toContain("tool1");
13141314
expect(result.tools.map((t) => t.name)).toContain("tool3");
@@ -1318,7 +1318,7 @@ describe("App <-> AppBridge integration", () => {
13181318
tool1.remove();
13191319

13201320
// Should now have one tool
1321-
result = await bridge.sendListTools({});
1321+
result = await bridge.listTools({});
13221322
expect(result.tools.map((t) => t.name)).toEqual(["tool3"]);
13231323
});
13241324

@@ -1346,7 +1346,7 @@ describe("App <-> AppBridge integration", () => {
13461346
// Disable one tool after connecting
13471347
tool2.disable();
13481348

1349-
const result = await bridge.sendListTools({});
1349+
const result = await bridge.listTools({});
13501350

13511351
// Only enabled tool should be in the list
13521352
expect(result.tools).toHaveLength(1);
@@ -1375,11 +1375,11 @@ describe("App <-> AppBridge integration", () => {
13751375
);
13761376

13771377
// List should include the tool
1378-
let listResult = await bridge.sendListTools({});
1378+
let listResult = await bridge.listTools({});
13791379
expect(listResult.tools.map((t) => t.name)).toContain("counter");
13801380

13811381
// Call the tool
1382-
let callResult = await bridge.sendCallTool({
1382+
let callResult = await bridge.callTool({
13831383
name: "counter",
13841384
arguments: {},
13851385
});
@@ -1391,7 +1391,7 @@ describe("App <-> AppBridge integration", () => {
13911391
tool.update({ description: "An updated counter tool" });
13921392

13931393
// Should still be callable
1394-
callResult = await bridge.sendCallTool({
1394+
callResult = await bridge.callTool({
13951395
name: "counter",
13961396
arguments: {},
13971397
});
@@ -1401,12 +1401,12 @@ describe("App <-> AppBridge integration", () => {
14011401
tool.remove();
14021402

14031403
// Should no longer be in list
1404-
listResult = await bridge.sendListTools({});
1404+
listResult = await bridge.listTools({});
14051405
expect(listResult.tools.map((t) => t.name)).not.toContain("counter");
14061406

14071407
// Should no longer be callable
14081408
await expect(
1409-
bridge.sendCallTool({ name: "counter", arguments: {} }),
1409+
bridge.callTool({ name: "counter", arguments: {} }),
14101410
).rejects.toThrow("Tool counter not found");
14111411
});
14121412

@@ -1457,19 +1457,19 @@ describe("App <-> AppBridge integration", () => {
14571457
await app2.connect(app2Transport);
14581458

14591459
// Each app should only see its own tools
1460-
const list1 = await bridge1.sendListTools({});
1460+
const list1 = await bridge1.listTools({});
14611461
expect(list1.tools.map((t) => t.name)).toEqual(["app1-tool"]);
14621462

1463-
const list2 = await bridge2.sendListTools({});
1463+
const list2 = await bridge2.listTools({});
14641464
expect(list2.tools.map((t) => t.name)).toEqual(["app2-tool"]);
14651465

14661466
// Each app should only be able to call its own tools
14671467
await expect(
1468-
bridge1.sendCallTool({ name: "app1-tool", arguments: {} }),
1468+
bridge1.callTool({ name: "app1-tool", arguments: {} }),
14691469
).resolves.toBeDefined();
14701470

14711471
await expect(
1472-
bridge1.sendCallTool({ name: "app2-tool", arguments: {} }),
1472+
bridge1.callTool({ name: "app2-tool", arguments: {} }),
14731473
).rejects.toThrow("Tool app2-tool not found");
14741474

14751475
// Clean up

src/app-bridge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,15 +1336,15 @@ export class AppBridge extends Protocol<
13361336
/** @deprecated Use {@link teardownResource} instead */
13371337
sendResourceTeardown: AppBridge["teardownResource"] = this.teardownResource;
13381338

1339-
sendCallTool(params: CallToolRequest["params"], options?: RequestOptions) {
1339+
callTool(params: CallToolRequest["params"], options?: RequestOptions) {
13401340
return this.request(
13411341
{ method: "tools/call", params },
13421342
CallToolResultSchema,
13431343
options,
13441344
);
13451345
}
13461346

1347-
sendListTools(params: ListToolsRequest["params"], options?: RequestOptions) {
1347+
listTools(params: ListToolsRequest["params"], options?: RequestOptions) {
13481348
return this.request(
13491349
{ method: "tools/list", params },
13501350
ListToolsResultSchema,

0 commit comments

Comments
 (0)