MCPcopy
hub / github.com/upstash/context7 / patchStdioApiKey

Function patchStdioApiKey

packages/cli/src/setup/mcp-writer.ts:216–228  ·  view source on GitHub ↗
(
  entry: Record<string, unknown>,
  apiKey: string | undefined
)

Source from the content-addressed store, hash-verified

214 * package specifier (e.g., `@upstash/context7-mcp@latest`) — are preserved.
215 */
216export 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
230export function buildTomlServerBlock(serverName: string, entry: Record<string, unknown>): string {
231 const lines: string[] = [`[mcp_servers.${serverName}]`];

Callers 2

resolveEntryToWriteFunction · 0.85
setup.test.tsFile · 0.85

Calls 1

stripApiKeyPairFunction · 0.85

Tested by

no test coverage detected