Skip to content

Commit 148ec47

Browse files
committed
fix: clean up mcp app types
1 parent 8013c4e commit 148ec47

File tree

10 files changed

+27
-227
lines changed

10 files changed

+27
-227
lines changed

core/context/mcp/MCPAppsResource.ts

Lines changed: 0 additions & 84 deletions
This file was deleted.

core/context/mcp/MCPConnection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ class MCPConnection {
118118
};
119119
}
120120

121+
async getResource(uri: string) {
122+
return await this.client.readResource({ uri });
123+
}
124+
121125
async connectClient(forceRefresh: boolean, externalSignal: AbortSignal) {
122126
if (this.status === "disabled") {
123127
return;

core/context/providers/MCPContextProvider.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ class MCPContextProvider extends BaseContextProvider {
7474
throw new Error(`No MCP connection found for ${mcpId}`);
7575
}
7676

77-
const { contents } = await connection.client.readResource({
78-
uri: this.insertInputToUriTemplate(uri, extras.fullInput),
79-
});
77+
const resourceuri = this.insertInputToUriTemplate(uri, extras.fullInput);
78+
const { contents } = await connection.getResource(resourceuri);
8079

8180
return await Promise.all(
8281
contents.map(async (resource) => {

core/core.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,14 @@ export class Core {
563563
);
564564
});
565565

566+
// // MCP Apps
567+
// on("mcp/fetchResourceUri", async (msg) => {
568+
// removeMCPAuth(msg.data.serverUrl, this.ide);
569+
// await MCPManagerSingleton.getInstance().refreshConnection(
570+
// msg.data.serverId,
571+
// );
572+
// });
573+
566574
// Context providers
567575
on("context/addDocs", async (msg) => {
568576
void this.docsService.indexAndAdd(msg.data);

core/index.d.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ export type ToolStatus =
497497
| "done" // Tool execution completed successfully
498498
| "canceled"; // Tool call was canceled by user or system
499499

500+
interface;
500501
// Will exist only on "assistant" messages with tool calls
501502
interface ToolCallState {
502503
toolCallId: string;
@@ -1134,7 +1135,7 @@ export interface Tool {
11341135
};
11351136
defaultToolPolicy?: ToolPolicy;
11361137
toolCallIcon?: string;
1137-
mcpAppUI?: MCPToolUIMetadata; // MCP Apps UI metadata
1138+
mcpAppUI?: MCPToolUIMetadata;
11381139
preprocessArgs?: (
11391140
args: Record<string, unknown>,
11401141
extras: {
@@ -1338,9 +1339,6 @@ export interface MCPPrompt {
13381339
arguments?: MCPPromptArgs;
13391340
}
13401341

1341-
// Leaving here to ideate on
1342-
// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1343-
13441342
// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
13451343
export interface MCPResource {
13461344
name: string;
@@ -1349,10 +1347,17 @@ export interface MCPResource {
13491347
mimeType?: string;
13501348
}
13511349

1350+
// https://modelcontextprotocol.io/docs/extensions/apps
1351+
export type MCPToolUIMetadata = {
1352+
resourceUri: string; // URI of the UI resource (typically ui://)
1353+
permissions?: string[]; // Additional iframe permissions (e.g., "microphone", "camera")
1354+
csp?: string[]; // Content Security Policy origins for loading external resources
1355+
};
1356+
13521357
// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
13531358
export interface MCPResourceTemplate {
1354-
uriTemplate: string;
13551359
name: string;
1360+
uriTemplate: string;
13561361
description?: string;
13571362
mimeType?: string;
13581363
}
@@ -1369,23 +1374,13 @@ export interface MCPTool {
13691374
};
13701375
}
13711376

1372-
// MCP Apps UI metadata (https://modelcontextprotocol.io/docs/extensions/apps)
1373-
export interface MCPToolUIMetadata {
1374-
resourceUri: string; // URI of the UI resource (typically ui://)
1375-
permissions?: string[]; // Additional iframe permissions (e.g., "microphone", "camera")
1376-
csp?: string[]; // Content Security Policy origins for loading external resources
1377-
}
1378-
13791377
export interface MCPAppResourceContent {
13801378
uri: string;
13811379
mimeType: string;
13821380
text?: string;
13831381
blob?: string;
13841382
_meta?: {
1385-
ui?: {
1386-
permissions?: string[];
1387-
csp?: string[];
1388-
};
1383+
ui?: Pick<MCPToolUIMetadata, "permissions", "csp">;
13891384
};
13901385
}
13911386

core/protocol/core.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -173,33 +173,6 @@ export type ToCoreFromIdeOrWebviewProtocol = {
173173
},
174174
void,
175175
];
176-
"mcpApp/fetchUI": [
177-
{
178-
toolCallId: string;
179-
mcpServerId: string;
180-
resourceUri: string;
181-
},
182-
{
183-
htmlContent?: string;
184-
permissions?: string[];
185-
csp?: string[];
186-
error?: string;
187-
},
188-
];
189-
"mcpApp/callTool": [
190-
{
191-
mcpServerId: string;
192-
name: string;
193-
arguments: Record<string, any>;
194-
},
195-
{
196-
content: Array<{
197-
type: string;
198-
text?: string;
199-
[key: string]: any;
200-
}>;
201-
},
202-
];
203176
"context/getSymbolsForFiles": [{ uris: string[] }, FileSymbolMap];
204177
"context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]];
205178
"autocomplete/complete": [AutocompleteInput, string[]];

core/protocol/coreWebview.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { ToCoreFromIdeOrWebviewProtocol } from "./core.js";
2-
import { MCPAppProtocol } from "./mcpApps.js";
32
import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";
43

54
export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & {
65
didChangeSelectedProfile: [{ id: string }, void];
76
didChangeSelectedOrg: [{ id: string; profileId?: string }, void];
87
};
9-
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol &
10-
MCPAppProtocol;
8+
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol;

core/protocol/mcpApps.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.

gui/src/components/MCPApp/MCPAppIframe.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ interface MCPAppIframeProps {
66
toolCallId: string;
77
permissions?: string[];
88
csp?: string[];
9-
onMessage?: (message: any) => void;
109
toolResult?: any;
1110
resourceUri?: string;
1211
}
@@ -19,7 +18,6 @@ interface MCPAppIframeProps {
1918
export function MCPAppIframe({
2019
htmlContent,
2120
toolCallId,
22-
onMessage,
2321
toolResult,
2422
resourceUri = `ui://${toolCallId}`,
2523
}: MCPAppIframeProps) {

gui/src/pages/gui/ToolCallDiv/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export function ToolCallDiv({
4343
functionName && tool?.toolCallIcon
4444
? getIconByName(tool.toolCallIcon)
4545
: undefined;
46-
4746
// Render MCP App UI if available
4847
if (toolCallState.mcpAppUI?.htmlContent) {
4948
return (
@@ -57,6 +56,7 @@ export function ToolCallDiv({
5756
permissions={toolCallState.mcpAppUI.permissions}
5857
csp={toolCallState.mcpAppUI.csp}
5958
toolResult={toolCallState.output}
59+
resourceUri={toolCallState.mcpAppUI?.resourceUri}
6060
/>
6161
</div>
6262
);

0 commit comments

Comments
 (0)