{"record":{"id":"eae802c6bab885df","repo":"upstash/context7","slug":"skipped-mcppath-could-not-parse-err-instanc","errorCode":null,"errorMessage":"Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)})","messagePattern":"Skipped (.+?): could not parse \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/remove.ts","lineNumber":211,"sourceCode":"  const agent = getAgent(agentName);\n  // Agents with no project-level MCP (e.g. Antigravity) only have a global\n  // config — there's nothing to detect at project scope.\n  if (scope === \"project\" && agent.mcp.projectPaths.length === 0) return false;\n  const candidates =\n    scope === \"global\"\n      ? agent.mcp.globalPaths\n      : agent.mcp.projectPaths.map((path) => join(process.cwd(), path));\n  const mcpPath = await resolveMcpPath(candidates);\n\n  if (mcpPath.endsWith(\".toml\")) {\n    return readTomlServerExists(mcpPath, \"context7\");\n  }\n\n  let existing: Record<string, unknown>;\n  try {\n    existing = await readJsonConfig(mcpPath);\n  } catch (err) {\n    log.warn(\n      `Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)})`\n    );\n    return false;\n  }\n  const section = existing[agent.mcp.configKey];\n  return (\n    !!section && typeof section === \"object\" && !Array.isArray(section) && \"context7\" in section\n  );\n}\n\nasync function hasRule(agentName: SetupAgent, scope: Scope): Promise<boolean> {\n  const agent = getAgent(agentName);\n  const rule = agent.rule;\n\n  if (rule.kind === \"file\") {\n    const ruleDir =\n      scope === \"global\" ? rule.dir(\"global\") : join(process.cwd(), rule.dir(\"project\"));\n    return pathExists(join(ruleDir, rule.filename));","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/upstash/context7/blob/5284672feb575908efead6fcf1b5e542f8d607bb/packages/cli/src/commands/remove.ts#L193-L229","documentation":"Thrown while context7 checks whether the context7 MCP server is registered for an agent (during remove/setup). The resolved agent config path that does not end in .toml is read with readJsonConfig(), which does JSON.parse(stripJsonComments(raw)). If the parse throws, the file is skipped with this warning and hasMcp() returns false, so the agent is treated as 'not configured' instead of the command crashing.","triggerScenarios":"Running `context7 remove <agent>` (or any flow calling hasMcp) when the agent's JSON MCP config exists but is unparsable: truncated file, trailing commas or single quotes that survive stripJsonComments, merge-conflict markers, or YAML pasted into a .json file. A missing file does NOT trigger this (readJsonConfig returns {} silently); only an existing, syntactically broken file does.","commonSituations":"Hand-edited ~/.claude.json or .cursor/mcp.json with comments or trailing commas; configs corrupted by an interrupted write or an unresolved git merge; configs emitted by other tools that write non-strict JSON (BOM, unquoted keys).","solutions":["Validate the file and fix the reported syntax error: jq . '<configPath>' (or npx jsonlint <configPath>)","Remove git merge-conflict markers (<<<<<<< / ======= / >>>>>>>) or editor backup blocks from the config","Restore the config from source control, or regenerate it with the agent's own CLI, then re-run the context7 command","Keep hand-written configs strict JSON: no comments, no trailing commas"],"exampleFix":"// before (.cursor/mcp.json — unparsable)\n{\n  \"mcpServers\": {\n    \"context7\": { \"command\": \"npx\", \"args\": [\"-y\", \"@upstash/context7-mcp\"] }, // trailing comma + comment\n}\n\n// after\n{\n  \"mcpServers\": {\n    \"context7\": { \"command\": \"npx\", \"args\": [\"-y\", \"@upstash/context7-mcp\"] }\n  }\n}","handlingStrategy":"validation","validationCode":"// before running context7 remove, confirm the agent's config parses\nimport { readFile } from \"node:fs/promises\";\nconst raw = await readFile(configPath, \"utf-8\");\ntry {\n  JSON.parse(raw.replace(/^\\uFEFF/, \"\"));\n} catch (e) {\n  console.error(`Fix ${configPath} first: ${(e as Error).message}`);\n}","typeGuard":"function isJsonRecord(v: unknown): v is Record<string, unknown> {\n  return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}","tryCatchPattern":null,"preventionTips":["Keep agent MCP configs strict JSON — no comments, no trailing commas","After hand edits, validate with `jq empty <file>` before running context7 commands","Resolve git merge conflicts in config files before invoking the CLI"],"tags":["json","config","parse-error","mcp","cli"],"backgroundTag":"invalid-json-config","analyzedSha":"5284672feb575908efead6fcf1b5e542f8d607bb","analyzedAt":"2026-08-18T18:00:18.510Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}