* For stdio transport, preserve an existing `@upstash/context7-mcp` invocation * (e.g., `@upstash/context7-mcp@latest` or a user-pinned version) and only * swap the `--api-key` value. Falls back to the agent's canonical shape when * no existing stdio entry is detected. HTTP transport always uses
( agent: ReturnType<typeof getAgent>, auth: AuthOptions, transport: Transport, existingEntry: Record<string, unknown> | undefined )
| 278 | * canonical shape. |
| 279 | */ |
| 280 | function resolveEntryToWrite( |
| 281 | agent: ReturnType<typeof getAgent>, |
| 282 | auth: AuthOptions, |
| 283 | transport: Transport, |
| 284 | existingEntry: Record<string, unknown> | undefined |
| 285 | ): Record<string, unknown> { |
| 286 | if (transport === "stdio" && existingEntry && isStdioContext7Entry(existingEntry)) { |
| 287 | const apiKey = auth.mode === "api-key" ? auth.apiKey : undefined; |
| 288 | return patchStdioApiKey(existingEntry, apiKey); |
| 289 | } |
| 290 | return agent.mcp.buildEntry(auth, transport); |
| 291 | } |
| 292 | |
| 293 | async function setupAgent( |
| 294 | agentName: SetupAgent, |
no test coverage detected