( existing: Record<string, unknown>, configKey: string, serverName: string )
| 63 | } |
| 64 | |
| 65 | export function removeServerEntry( |
| 66 | existing: Record<string, unknown>, |
| 67 | configKey: string, |
| 68 | serverName: string |
| 69 | ): { config: Record<string, unknown>; removed: boolean } { |
| 70 | const section = existing[configKey]; |
| 71 | if (!section || typeof section !== "object" || Array.isArray(section)) { |
| 72 | return { config: existing, removed: false }; |
| 73 | } |
| 74 | |
| 75 | const current = section as Record<string, unknown>; |
| 76 | if (!(serverName in current)) { |
| 77 | return { config: existing, removed: false }; |
| 78 | } |
| 79 | |
| 80 | const rest = Object.fromEntries(Object.entries(current).filter(([key]) => key !== serverName)); |
| 81 | const next = { ...existing }; |
| 82 | |
| 83 | if (Object.keys(rest).length === 0) { |
| 84 | delete next[configKey]; |
| 85 | } else { |
| 86 | next[configKey] = rest; |
| 87 | } |
| 88 | |
| 89 | return { config: next, removed: true }; |
| 90 | } |
| 91 | |
| 92 | export async function resolveMcpPath(candidates: string[]): Promise<string> { |
| 93 | for (const candidate of candidates) { |
no outgoing calls
no test coverage detected