Skip to content

Commit e0eabd7

Browse files
cliffhallclaude
andcommitted
test(apps): address PR #1272 review feedback
- core/mcp/apps.ts: convert getAppResourceUri from a typed const re-export to a function declaration so its export style matches isAppTool. Behavior is unchanged. - core/mcp/apps.ts: document the filter-iteration implication on isAppTool — callers using tools.filter(isAppTool) will halt on a server-malformed URI. - apps.test.ts: add the symmetric isAppTool false-case for `_meta.ui` present without `resourceUri`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 63bd135 commit e0eabd7

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

clients/web/src/test/core/apps.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ describe("isAppTool", () => {
8282
expect(isAppTool(toolWith({ other: "value" }))).toBe(false);
8383
});
8484

85+
it("returns false when _meta.ui exists without resourceUri", () => {
86+
expect(isAppTool(toolWith({ ui: { visibility: ["model"] } }))).toBe(false);
87+
});
88+
8589
it("propagates the underlying throw for an invalid URI", () => {
8690
expect(() =>
8791
isAppTool(toolWith({ ui: { resourceUri: "not-a-ui-uri" } })),

core/mcp/apps.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,23 @@ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
1414
* silently dropping the tool, because a malformed URI is a server bug worth
1515
* making visible.
1616
*
17-
* Re-exported from `@modelcontextprotocol/ext-apps/app-bridge` so that web,
18-
* CLI, and TUI all consume the same implementation through `@inspector/core`.
17+
* Wraps `getToolUiResourceUri` from `@modelcontextprotocol/ext-apps/app-bridge`
18+
* so that web, CLI, and TUI all consume the same implementation through
19+
* `@inspector/core`.
1920
*/
20-
export const getAppResourceUri: (tool: Tool) => string | undefined =
21-
getToolUiResourceUri;
21+
export function getAppResourceUri(tool: Tool): string | undefined {
22+
return getToolUiResourceUri(tool);
23+
}
2224

2325
/**
2426
* Single source of truth for App-tool detection across all Inspector clients.
2527
* Wraps {@link getAppResourceUri}; throws on a malformed `_meta.ui.resourceUri`
2628
* for the same reason.
29+
*
30+
* Note: because this throws on malformed URIs, callers using
31+
* `tools.filter(isAppTool)` will halt iteration on the first bad tool. Wrap in
32+
* a try/catch (or a safe-predicate helper) at the call site if you need to
33+
* tolerate mixed-validity tool lists.
2734
*/
2835
export function isAppTool(tool: Tool): boolean {
2936
return getAppResourceUri(tool) !== undefined;

0 commit comments

Comments
 (0)