Skip to content

Commit fee6d58

Browse files
chore: consolidate imports, remove unused (code-quality bot)
1 parent ab3c9c3 commit fee6d58

3 files changed

Lines changed: 36 additions & 48 deletions

File tree

src/app-bridge.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
2-
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
3-
import type { Client } from "@modelcontextprotocol/client";
4-
import type { ServerCapabilities } from "@modelcontextprotocol/client";
2+
import {
3+
InMemoryTransport,
4+
type Client,
5+
type ServerCapabilities,
6+
} from "@modelcontextprotocol/client";
57
import {
68
EmptyResultSchema,
79
ListPromptsResultSchema,
@@ -680,11 +682,7 @@ describe("App <-> AppBridge integration", () => {
680682
await app.connect(appTransport);
681683

682684
// Bridge can send ping via the protocol's request method
683-
const result = await bridge.request(
684-
"ping",
685-
{},
686-
EmptyResultSchema,
687-
);
685+
const result = await bridge.request("ping", {}, EmptyResultSchema);
688686

689687
expect(result).toEqual({});
690688
});

src/app-bridge.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Client } from "@modelcontextprotocol/client";
2-
import { Transport } from "@modelcontextprotocol/client";
31
import {
42
CallToolRequest,
53
CallToolResult,
4+
Client,
65
EmptyResult,
76
Implementation,
87
ListPromptsRequest,
@@ -15,35 +14,26 @@ import {
1514
LoggingMessageNotification,
1615
PingRequest,
1716
PromptListChangedNotification,
17+
ProtocolOptions,
1818
ReadResourceRequest,
1919
ReadResourceResult,
20+
RequestOptions,
2021
ResourceListChangedNotification,
2122
Tool,
2223
ToolListChangedNotification,
24+
Transport,
2325
} from "@modelcontextprotocol/client";
2426
import {
2527
CallToolRequestSchema,
2628
CallToolResultSchema,
2729
ListPromptsRequestSchema,
28-
ListPromptsResultSchema,
2930
ListResourcesRequestSchema,
30-
ListResourcesResultSchema,
3131
ListResourceTemplatesRequestSchema,
32-
ListResourceTemplatesResultSchema,
33-
ListToolsRequestSchema,
3432
ListToolsResultSchema,
3533
LoggingMessageNotificationSchema,
3634
PingRequestSchema,
37-
PromptListChangedNotificationSchema,
3835
ReadResourceRequestSchema,
39-
ReadResourceResultSchema,
40-
ResourceListChangedNotificationSchema,
41-
ToolListChangedNotificationSchema,
4236
} from "./sdk-schemas";
43-
import {
44-
ProtocolOptions,
45-
RequestOptions,
46-
} from "@modelcontextprotocol/client";
4737
import { ProtocolWithEvents } from "./events";
4838

4939
import {
@@ -374,7 +364,7 @@ export class AppBridge extends ProtocolWithEvents<
374364
// Hosts can override this by setting bridge.onrequestdisplaymode = ...
375365
this.replaceRequestHandler(
376366
McpUiRequestDisplayModeRequestSchema,
377-
(request) => {
367+
(_request) => {
378368
const currentMode = this._hostContext.displayMode ?? "inline";
379369
return { mode: currentMode };
380370
},
@@ -1586,7 +1576,10 @@ export class AppBridge extends ProtocolWithEvents<
15861576
params: McpUiResourceTeardownRequest["params"],
15871577
options?: RequestOptions,
15881578
) {
1589-
return this.request("ui/resource-teardown", params, McpUiResourceTeardownResultSchema,
1579+
return this.request(
1580+
"ui/resource-teardown",
1581+
params,
1582+
McpUiResourceTeardownResultSchema,
15901583
options,
15911584
);
15921585
}
@@ -1604,9 +1597,7 @@ export class AppBridge extends ProtocolWithEvents<
16041597
* @returns Promise resolving to the tool call result
16051598
*/
16061599
callTool(params: CallToolRequest["params"], options?: RequestOptions) {
1607-
return this.request("tools/call", params, CallToolResultSchema,
1608-
options,
1609-
);
1600+
return this.request("tools/call", params, CallToolResultSchema, options);
16101601
}
16111602

16121603
/**
@@ -1619,9 +1610,7 @@ export class AppBridge extends ProtocolWithEvents<
16191610
* @returns Promise resolving to the list of tools
16201611
*/
16211612
listTools(params: ListToolsRequest["params"], options?: RequestOptions) {
1622-
return this.request("tools/list", params, ListToolsResultSchema,
1623-
options,
1624-
);
1613+
return this.request("tools/list", params, ListToolsResultSchema, options);
16251614
}
16261615

16271616
/**

src/app.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import {
2-
type RequestOptions,
3-
ProtocolOptions,
4-
} from "@modelcontextprotocol/client";
5-
61
import {
72
CallToolRequest,
83
CallToolResult,
@@ -12,8 +7,11 @@ import {
127
ListToolsRequest,
138
ListToolsResult,
149
LoggingMessageNotification,
10+
ProtocolOptions,
1511
ReadResourceRequest,
1612
ReadResourceResult,
13+
type RequestOptions,
14+
Transport,
1715
} from "@modelcontextprotocol/client";
1816
import {
1917
CallToolRequestSchema,
@@ -62,7 +60,6 @@ import {
6260
McpUiRequestDisplayModeRequest,
6361
McpUiRequestDisplayModeResultSchema,
6462
} from "./types";
65-
import { Transport } from "@modelcontextprotocol/client";
6663

6764
export { PostMessageTransport } from "./message-transport";
6865
export * from "./types";
@@ -825,16 +822,14 @@ export class App extends ProtocolWithEvents<
825822
`Did you mean: callServerTool({ name: "${params}", arguments: { ... } })?`,
826823
);
827824
}
828-
return await this.request("tools/call", params, CallToolResultSchema,
829-
{
830-
// Hosts may interpose long-running or user-interactive steps before the
831-
// tool result arrives. Opting in here lets a host heartbeat keep the
832-
// request alive past the default timeout; callers can still override.
833-
onprogress: () => {},
834-
resetTimeoutOnProgress: true,
835-
...options,
836-
},
837-
);
825+
return await this.request("tools/call", params, CallToolResultSchema, {
826+
// Hosts may interpose long-running or user-interactive steps before the
827+
// tool result arrives. Opting in here lets a host heartbeat keep the
828+
// request alive past the default timeout; callers can still override.
829+
onprogress: () => {},
830+
resetTimeoutOnProgress: true,
831+
...options,
832+
});
838833
}
839834

840835
/**
@@ -881,7 +876,10 @@ export class App extends ProtocolWithEvents<
881876
params: ReadResourceRequest["params"],
882877
options?: RequestOptions,
883878
): Promise<ReadResourceResult> {
884-
return await this.request("resources/read", params, ReadResourceResultSchema,
879+
return await this.request(
880+
"resources/read",
881+
params,
882+
ReadResourceResultSchema,
885883
options,
886884
);
887885
}
@@ -926,7 +924,10 @@ export class App extends ProtocolWithEvents<
926924
params?: ListResourcesRequest["params"],
927925
options?: RequestOptions,
928926
): Promise<ListResourcesResult> {
929-
return await this.request("resources/list", params, ListResourcesResultSchema,
927+
return await this.request(
928+
"resources/list",
929+
params,
930+
ListResourcesResultSchema,
930931
options,
931932
);
932933
}

0 commit comments

Comments
 (0)