Skip to content

Commit 81200c0

Browse files
committed
fix(electron): guard against undefined command in MCP server config
Prevent agent:init crash when MCP server entries lack a command field (e.g. remote URL-based entries persisted without command key).
1 parent 8559d73 commit 81200c0

File tree

1 file changed

+3
-0
lines changed
  • crates/agent-electron-client/src/main/services/packages

1 file changed

+3
-0
lines changed

crates/agent-electron-client/src/main/services/packages/mcp.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function resolveUvCommand(
5454
args: string[],
5555
uvBinDir?: string,
5656
): { command: string; args: string[] } {
57+
if (typeof command !== 'string') return { command, args };
5758
const dir = uvBinDir ?? getUvBinDir();
5859
if (!dir) return { command, args };
5960

@@ -243,6 +244,7 @@ export function resolveServersConfig(
243244
continue;
244245
}
245246
if (entry.command === 'mcp-proxy') continue;
247+
if (typeof entry.command !== 'string') continue;
246248
const resolved = resolveUvCommand(entry.command, entry.args || [], dir);
247249
result[name] = {
248250
command: resolved.command,
@@ -648,6 +650,7 @@ export async function syncMcpConfigToProxyAndReload(
648650
realOnly[name] = entry;
649651
} else {
650652
if (entry.command === 'mcp-proxy') continue;
653+
if (typeof entry.command !== 'string') continue;
651654
realOnly[name] = {
652655
command: entry.command,
653656
args: Array.isArray(entry.args) ? entry.args : [],

0 commit comments

Comments
 (0)