( entry: Record<string, unknown>, apiKey: string | undefined )
| 214 | * package specifier (e.g., `@upstash/context7-mcp@latest`) — are preserved. |
| 215 | */ |
| 216 | export function patchStdioApiKey( |
| 217 | entry: Record<string, unknown>, |
| 218 | apiKey: string | undefined |
| 219 | ): Record<string, unknown> { |
| 220 | if (Array.isArray(entry.command)) { |
| 221 | const cmd = stripApiKeyPair(entry.command as string[]); |
| 222 | if (apiKey) cmd.push("--api-key", apiKey); |
| 223 | return { ...entry, command: cmd }; |
| 224 | } |
| 225 | const args = Array.isArray(entry.args) ? stripApiKeyPair(entry.args as string[]) : []; |
| 226 | if (apiKey) args.push("--api-key", apiKey); |
| 227 | return { ...entry, args }; |
| 228 | } |
| 229 | |
| 230 | export function buildTomlServerBlock(serverName: string, entry: Record<string, unknown>): string { |
| 231 | const lines: string[] = [`[mcp_servers.${serverName}]`]; |
no test coverage detected