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

Function resolveEntryToWrite

packages/cli/src/commands/setup.ts:280–291  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

278 * canonical shape.
279 */
280function 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
293async function setupAgent(
294 agentName: SetupAgent,

Callers 1

setupAgentFunction · 0.85

Calls 2

isStdioContext7EntryFunction · 0.85
patchStdioApiKeyFunction · 0.85

Tested by

no test coverage detected