Skip to content

Commit c559917

Browse files
illumeashu8912
andcommitted
app: preload: Add mcp APIs to be exposed to the web
Co-Authored-By: Ashu Ghildiyal <aghildiyal@microsoft.com>
1 parent 09d8d19 commit c559917

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app/electron/preload.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ contextBridge.exposeInMainWorld('desktopApi', {
3131
'request-backend-token',
3232
'request-plugin-permission-secrets',
3333
'request-backend-port',
34+
'cluster-changed',
3435
];
3536
if (validChannels.includes(channel)) {
3637
ipcRenderer.send(channel, data);
@@ -60,4 +61,29 @@ contextBridge.exposeInMainWorld('desktopApi', {
6061
removeListener: (channel: string, func: (...args: unknown[]) => void) => {
6162
ipcRenderer.removeListener(channel, func);
6263
},
64+
65+
// @todo: move these to the send receive pattern above, restricted to ai-assistant only.
66+
// @todo: do not enable if environment variable disabling mcp is set.
67+
// MCP client APIs
68+
mcp: {
69+
executeTool: (toolName: string, args: Record<string, any>, toolCallId?: string) =>
70+
ipcRenderer.invoke('mcp-execute-tool', { toolName, args, toolCallId }),
71+
getStatus: () => ipcRenderer.invoke('mcp-get-status'),
72+
resetClient: () => ipcRenderer.invoke('mcp-reset-client'),
73+
getConfig: () => ipcRenderer.invoke('mcp-get-config'),
74+
updateConfig: (config: any) => ipcRenderer.invoke('mcp-update-config', config),
75+
getToolsConfig: () => ipcRenderer.invoke('mcp-get-tools-config'),
76+
updateToolsConfig: (config: any) => ipcRenderer.invoke('mcp-update-tools-config', config),
77+
setToolEnabled: (serverName: string, toolName: string, enabled: boolean) =>
78+
ipcRenderer.invoke('mcp-set-tool-enabled', { serverName, toolName, enabled }),
79+
getToolStats: (serverName: string, toolName: string) =>
80+
ipcRenderer.invoke('mcp-get-tool-stats', { serverName, toolName }),
81+
clusterChange: (cluster: string | null) =>
82+
ipcRenderer.invoke('mcp-cluster-change', { cluster }),
83+
},
84+
85+
// Notify cluster change (for MCP server restart)
86+
notifyClusterChange: (cluster: string | null) => {
87+
ipcRenderer.send('cluster-changed', cluster);
88+
},
6389
});

0 commit comments

Comments
 (0)