Skip to content

Commit 1b93e58

Browse files
committed
ai-plugin: Run formatter
Signed-off-by: ashu8912 <aghildiyal@microsoft.com>
1 parent 5bda725 commit 1b93e58

23 files changed

+1217
-1056
lines changed

ai-assistant/src/ai/mcp/client.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
1+
import { MultiServerMCPClient } from '@langchain/mcp-adapters';
22

33
const client = new MultiServerMCPClient({
44
// Global tool configuration options
@@ -7,25 +7,25 @@ const client = new MultiServerMCPClient({
77
// Whether to prefix tool names with the server name (optional, default: false)
88
prefixToolNameWithServerName: false,
99
// Optional additional prefix for tool names (optional, default: "")
10-
additionalToolNamePrefix: "",
10+
additionalToolNamePrefix: '',
1111

1212
// Use standardized content block format in tool outputs
1313
useStandardContentBlocks: true,
1414

1515
// Server configuration
1616
mcpServers: {
1717
// adds the Inspektor Gadget MCP server
18-
"inspektor-gadget": {
19-
transport: "stdio",
20-
command: "docker",
18+
'inspektor-gadget': {
19+
transport: 'stdio',
20+
command: 'docker',
2121
args: [
22-
"run",
23-
"-i",
24-
"--rm",
25-
"--mount",
26-
"type=bind,src=${env:HOME}/.kube/config,dst=/kubeconfig",
27-
"ghcr.io/inspektor-gadget/ig-mcp-server:latest",
28-
"-gadget-discoverer=artifacthub"
22+
'run',
23+
'-i',
24+
'--rm',
25+
'--mount',
26+
'type=bind,src=${env:HOME}/.kube/config,dst=/kubeconfig',
27+
'ghcr.io/inspektor-gadget/ig-mcp-server:latest',
28+
'-gadget-discoverer=artifacthub',
2929
],
3030
// Restart configuration for stdio transport
3131
restart: {
@@ -34,11 +34,11 @@ const client = new MultiServerMCPClient({
3434
delayMs: 2000, // Slightly longer delay for Docker container startup
3535
},
3636
},
37-
}
37+
},
3838
});
3939

40-
const tools = async function() {
41-
return await client.getTools();
40+
const tools = async function () {
41+
return await client.getTools();
4242
};
4343

44-
export default tools;
44+
export default tools;

ai-assistant/src/ai/mcp/electron-client.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ interface MCPResponse {
1717

1818
interface ElectronMCPApi {
1919
getTools: () => Promise<MCPResponse>;
20-
executeTool: (toolName: string, args: Record<string, any>, toolCallId?: string) => Promise<MCPResponse>;
20+
executeTool: (
21+
toolName: string,
22+
args: Record<string, any>,
23+
toolCallId?: string
24+
) => Promise<MCPResponse>;
2125
getStatus: () => Promise<{ isInitialized: boolean; hasClient: boolean }>;
2226
resetClient: () => Promise<MCPResponse>;
2327
getConfig: () => Promise<{ success: boolean; config?: any; error?: string }>;
@@ -36,9 +40,10 @@ class ElectronMCPClient {
3640
private isElectron: boolean;
3741

3842
constructor() {
39-
this.isElectron = typeof window !== 'undefined' &&
40-
typeof window.desktopApi !== 'undefined' &&
41-
typeof window.desktopApi.mcp !== 'undefined';
43+
this.isElectron =
44+
typeof window !== 'undefined' &&
45+
typeof window.desktopApi !== 'undefined' &&
46+
typeof window.desktopApi.mcp !== 'undefined';
4247
}
4348

4449
/**
@@ -59,11 +64,8 @@ class ElectronMCPClient {
5964

6065
try {
6166
const response = await window.desktopApi!.mcp.getTools();
62-
console.log(
63-
"mcp response from getting tools is",
64-
response
65-
);
66-
console.log("mcp window desktop api", window.desktopApi!.mcp.getTools)
67+
console.log('mcp response from getting tools is', response);
68+
console.log('mcp window desktop api', window.desktopApi!.mcp.getTools);
6769
if (response.success && response.tools) {
6870
console.log('Retrieved MCP tools from Electron:', response.tools.length, 'tools');
6971
return response.tools;
@@ -81,18 +83,18 @@ class ElectronMCPClient {
8183
* Execute an MCP tool via Electron main process
8284
*/
8385
async executeTool(
84-
toolName: string,
85-
args: Record<string, any>,
86+
toolName: string,
87+
args: Record<string, any>,
8688
toolCallId?: string
8789
): Promise<any> {
8890
if (!this.isElectron) {
8991
throw new Error('MCP client not available - not running in Electron environment');
9092
}
9193

9294
try {
93-
console.log("args for tool executed is ", args)
95+
console.log('args for tool executed is ', args);
9496
const response = await window.desktopApi!.mcp.executeTool(toolName, args, toolCallId);
95-
97+
9698
if (response.success) {
9799
return response.result;
98100
} else {
@@ -139,9 +141,9 @@ class ElectronMCPClient {
139141
}
140142

141143
// Export a function that returns tools (compatible with existing interface)
142-
const tools = async function(): Promise<MCPTool[]> {
144+
const tools = async function (): Promise<MCPTool[]> {
143145
const client = new ElectronMCPClient();
144-
console.log("mcp electron client is ", client);
146+
console.log('mcp electron client is ', client);
145147
return await client.getTools();
146148
};
147149

ai-assistant/src/components/assistant/ToolsDialog.tsx

Lines changed: 40 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
Switch,
1717
Typography,
1818
} from '@mui/material';
19-
import React, { useEffect,useState } from 'react';
19+
import React, { useEffect, useState } from 'react';
2020
import tools from '../../ai/mcp/electron-client';
2121
import { AVAILABLE_TOOLS } from '../../langchain/tools/registry';
2222

@@ -69,10 +69,8 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
6969
};
7070

7171
const handleToggleTool = (toolName: string) => {
72-
setLocalEnabledTools(prev =>
73-
prev.includes(toolName)
74-
? prev.filter(name => name !== toolName)
75-
: [...prev, toolName]
72+
setLocalEnabledTools(prev =>
73+
prev.includes(toolName) ? prev.filter(name => name !== toolName) : [...prev, toolName]
7674
);
7775
};
7876

@@ -106,7 +104,7 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
106104
External Model Context Protocol tools (always enabled)
107105
</Typography>
108106
</Box>
109-
107+
110108
{loadingMcpTools ? (
111109
<Box sx={{ display: 'flex', justifyContent: 'center', my: 3 }}>
112110
<CircularProgress size={24} />
@@ -119,29 +117,24 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
119117
{mcpTools.length > 0 ? (
120118
mcpTools.map((tool, index) => (
121119
<ListItem key={`mcp-${index}`}>
122-
<Box sx={{
123-
display: 'flex',
124-
alignItems: 'center',
125-
minWidth: 40,
126-
justifyContent: 'center'
127-
}}>
128-
<Icon
129-
icon={getToolIcon(tool.name, 'mcp')}
130-
style={{ fontSize: 20, marginRight: 8 }}
120+
<Box
121+
sx={{
122+
display: 'flex',
123+
alignItems: 'center',
124+
minWidth: 40,
125+
justifyContent: 'center',
126+
}}
127+
>
128+
<Icon
129+
icon={getToolIcon(tool.name, 'mcp')}
130+
style={{ fontSize: 20, marginRight: 8 }}
131131
/>
132132
</Box>
133133
<ListItemText
134134
primary={
135135
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
136-
<Typography variant="body1">
137-
{tool.name}
138-
</Typography>
139-
<Chip
140-
label="MCP"
141-
size="small"
142-
color="info"
143-
variant="outlined"
144-
/>
136+
<Typography variant="body1">{tool.name}</Typography>
137+
<Chip label="MCP" size="small" color="info" variant="outlined" />
145138
</Box>
146139
}
147140
secondary={tool.description || 'External MCP tool'}
@@ -195,7 +188,7 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
195188
</Typography>
196189
)}
197190
</Box>
198-
191+
199192
<List>
200193
{tools.map(ToolClass => {
201194
const tempTool = new ToolClass();
@@ -205,10 +198,7 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
205198
return (
206199
<ListItem key={toolName} divider>
207200
<Box sx={{ display: 'flex', alignItems: 'center', mr: 2 }}>
208-
<Icon
209-
icon={getToolIcon(toolName)}
210-
style={{ fontSize: 20, marginRight: 8 }}
211-
/>
201+
<Icon icon={getToolIcon(toolName)} style={{ fontSize: 20, marginRight: 8 }} />
212202
</Box>
213203
<ListItemText
214204
primary={
@@ -217,11 +207,7 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
217207
{tempTool.config.displayName || toolName}
218208
</Typography>
219209
{tempTool.config.category && (
220-
<Chip
221-
label={tempTool.config.category}
222-
size="small"
223-
variant="outlined"
224-
/>
210+
<Chip label={tempTool.config.category} size="small" variant="outlined" />
225211
)}
226212
</Box>
227213
}
@@ -243,67 +229,57 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
243229
);
244230

245231
return (
246-
<Dialog
247-
open={open}
232+
<Dialog
233+
open={open}
248234
onClose={handleCancel}
249235
maxWidth="md"
250236
fullWidth
251237
PaperProps={{
252-
sx: { height: '80vh' }
238+
sx: { height: '80vh' },
253239
}}
254240
>
255241
<DialogTitle>
256242
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
257243
<Icon icon="mdi:tools" style={{ fontSize: 24 }} />
258-
<Typography variant="h6">
259-
Manage Tools
260-
</Typography>
261-
<Chip
262-
label={`${localEnabledTools.length} enabled`}
263-
size="small"
264-
color="primary"
265-
/>
244+
<Typography variant="h6">Manage Tools</Typography>
245+
<Chip label={`${localEnabledTools.length} enabled`} size="small" color="primary" />
266246
</Box>
267247
</DialogTitle>
268-
248+
269249
<DialogContent>
270250
<Typography variant="body2" color="text.secondary" sx={{ mb: 3 }}>
271-
Enable or disable tools that the AI can use. Changes will take effect immediately and will be saved to your settings.
251+
Enable or disable tools that the AI can use. Changes will take effect immediately and will
252+
be saved to your settings.
272253
</Typography>
273254

274255
{/* Kubernetes Tools */}
275256
{kubernetesTools.length > 0 && (
276257
<>
277258
{renderToolList(
278-
kubernetesTools,
279-
"Kubernetes Tools",
280-
"Tools for interacting with Kubernetes clusters"
259+
kubernetesTools,
260+
'Kubernetes Tools',
261+
'Tools for interacting with Kubernetes clusters'
281262
)}
282263
<Divider sx={{ my: 3 }} />
283264
</>
284265
)}
285266

286267
{/* Other Tools */}
287-
{otherTools.length > 0 && (
268+
{otherTools.length > 0 &&
288269
renderToolList(
289-
otherTools,
290-
"System Tools",
291-
"General purpose tools for various operations"
292-
)
293-
)}
270+
otherTools,
271+
'System Tools',
272+
'General purpose tools for various operations'
273+
)}
294274

295275
{/* MCP Tools */}
296276
{renderMcpToolList()}
297-
298-
{(kubernetesTools.length > 0 || otherTools.length > 0) && (
299-
<Divider sx={{ my: 3 }} />
300-
)}
277+
278+
{(kubernetesTools.length > 0 || otherTools.length > 0) && <Divider sx={{ my: 3 }} />}
301279
</DialogContent>
302280

303281
<DialogActions>
304-
<Button onClick={handleCancel}>
305-
Cancel
306-
</Button>
282+
<Button onClick={handleCancel}>Cancel</Button>
307283
<Button onClick={handleSave} variant="contained">
308284
Save Changes
309285
</Button>
@@ -312,4 +288,4 @@ export const ToolsDialog: React.FC<ToolsDialogProps> = ({
312288
);
313289
};
314290

315-
export default ToolsDialog;
291+
export default ToolsDialog;

0 commit comments

Comments
 (0)