{"record":{"id":"e380a08d5f6a99c7","repo":"upstash/context7","slug":"existing-mcp-args-do-not-invoke-stdio-package","errorCode":null,"errorMessage":"Existing MCP args do not invoke ${STDIO_PACKAGE}","messagePattern":"Existing MCP args do not invoke (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/setup/toml-editor.ts","lineNumber":194,"sourceCode":"  apiKey: string | undefined\n): Promise<boolean> {\n  let raw: string;\n  try {\n    raw = await readFile(filePath, \"utf-8\");\n  } catch {\n    return false;\n  }\n\n  if (raw.includes('\"\"\"') || raw.includes(\"'''\")) {\n    throw new Error(\"TOML files containing multiline strings are not safely editable\");\n  }\n\n  const range = findTomlServerArgs(raw, serverName);\n  if (!range) return false;\n\n  const args = range.tokens.map((token) => token.value);\n  if (!args.some(isContext7Package)) {\n    throw new Error(`Existing MCP args do not invoke ${STDIO_PACKAGE}`);\n  }\n\n  const apiKeyIndexes = args.flatMap((arg, index) => (arg === \"--api-key\" ? [index] : []));\n  let content: string;\n  if (apiKey && apiKeyIndexes.length === 1 && apiKeyIndexes[0] + 1 < range.tokens.length) {\n    const valueToken = range.tokens[apiKeyIndexes[0] + 1];\n    content = raw.slice(0, valueToken.start) + JSON.stringify(apiKey) + raw.slice(valueToken.end);\n  } else {\n    const patched = withoutApiKey(args);\n    if (apiKey) patched.push(\"--api-key\", apiKey);\n    content = raw.slice(0, range.start) + JSON.stringify(patched) + raw.slice(range.end);\n  }\n\n  if (content !== raw) {\n    await mkdir(dirname(filePath), { recursive: true });\n    await writeFile(filePath, content, \"utf-8\");\n  }\n  return true;","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/upstash/context7/blob/edc9eeb77bbfc553e08a122ca783293fdb477daf/packages/cli/src/setup/toml-editor.ts#L176-L212","documentation":"The server's args array parsed successfully, but no element matches the expected stdio package (STDIO_PACKAGE, e.g. the context7 MCP package). The tool only patches args that actually invoke that package, so it aborts instead of modifying an unrelated command.","triggerScenarios":"args = [\"-y\", \"some-other-mcp\"] where the user pointed the setup at a server table that runs a different package, or renamed/misspelled the package element.","commonSituations":"See trigger scenarios.","solutions":["Fix the args array so an element actually names the expected package (e.g. \"-y\", \"@upstash/context7-mcp\")","Point the setup command at the correct server entry","If intentional, skip the patch step for this server"],"exampleFix":"// before\n[context7]\nargs = [\"-y\", \"@other/mcp\"]\n\n// after\n[context7]\nargs = [\"-y\", \"@upstash/context7-mcp\"]","handlingStrategy":"validation","validationCode":"const args = range.tokens.map(t => t.value);\nif (!args.some(isContext7Package)) throw new Error('args do not invoke the expected package');","typeGuard":"function argsInvokePackage(args: string[], pkg: string): boolean {\n  return args.some(a => a === pkg || a.endsWith(`/${pkg}`) || a.includes(pkg));\n}","tryCatchPattern":"catch (e) { if (/do not invoke/.test(e.message)) { /* correct the package name in args, or target the right server */ } throw e; }","preventionTips":["Verify the package element in args matches the tool's expected package","Run setup against the correct server entry","Keep package names exact (no typos/versions)"],"tags":["mcp","package-mismatch","args-validation"],"backgroundTag":"command-not-found-in-config","analyzedSha":"edc9eeb77bbfc553e08a122ca783293fdb477daf","analyzedAt":"2026-08-28T10:18:41.476Z","contentChangedAt":"2026-08-28T10:18:41.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}