upstash/context7 · warning
Skipped : could not parse ( )
Error message
Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)}) What it means
hasMcpConfig tries to parse an existing MCP config JSON for a given agent; if readJsonConfig throws (file is invalid JSON or unreadable as JSON), it logs "Skipped <mcpPath>: could not parse (...)" and returns false, so that config file is ignored rather than crashing detection. As a side effect, detectAvailableModes and hasAnyContext7Artifacts treat that agent as having no MCP config.
Solutions
- Open the logged mcpPath and fix the JSON syntax error reported in the warning.
- Validate the file with a JSON linter (jq . file.json) before rerunning.
- Delete/recreate the config if it's corrupted beyond repair.
- Back up the file before hand-editing; use a JSONC-aware editor if the agent's format allows comments.
Example fix
// before (mcp.json)
{ "mcpServers": { "context7": { "command": "npx", } } } // trailing comma
// after
{
"mcpServers": {
"context7": { "command": "npx" }
}
} Defensive patterns
Strategy: validation
Validate before calling
const raw = await fs.readFile(mcpPath, 'utf8').catch(() => null);
if (raw !== null) {
try { JSON.parse(raw); } catch (e) { console.warn(`Fix JSON in ${mcpPath}: ${e.message}`); }
} Type guard
function isRecord(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null && !Array.isArray(v);
} Try / catch
try {
existing = await readJsonConfig(mcpPath);
} catch {
log.warn(`Skipping unreadable config ${mcpPath}; fix its JSON syntax`);
return false;
} Prevention
- Run jq or a JSON linter after every manual edit to MCP config files
- Avoid trailing commas and comments in strict-JSON config files
- Keep editor format-on-save configured to output valid JSON
- Back up config files before scripted rewrites
When it happens
Trigger: The agent's MCP config file at mcpPath contains malformed JSON (truncated edit, comments in a strict-JSON parser, BOM/encoding issues) or readJsonConfig fails for another reason.
Common situations: Users hand-editing mcp.json and leaving trailing commas, files corrupted by a crash, or JSONC-style comments in files parsed as plain JSON.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- authentication_error
- Authentication is required. Pass apiKey or authToken, or…
- await describeErrorResponse(response, fallback)
- Cancelled
- Context7 base URL must not contain a query string or…
AI-assisted analysis of upstash/context7@4416fb855b (2026-09-16).
Data as JSON: /api/errors/eae802c6bab885df.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/commands/remove.ts:199
const agent = getAgent(agentName);
// Agents with no project-level MCP (e.g. Antigravity) only have a global
// config — there's nothing to detect at project scope.
if (scope === "project" && agent.mcp.projectPaths.length === 0) return false;
const candidates =
scope === "global"
? agent.mcp.globalPaths
: agent.mcp.projectPaths.map((path) => join(process.cwd(), path));
const mcpPath = await resolveMcpPath(candidates);
if (mcpPath.endsWith(".toml")) {
return readTomlServerExists(mcpPath, "context7");
}
let existing: Record<string, unknown>;
try {
existing = await readJsonConfig(mcpPath);
} catch (err) {
log.warn(
`Skipped ${mcpPath}: could not parse (${err instanceof Error ? err.message : String(err)})`
);
return false;
}
const section = existing[agent.mcp.configKey];
return (
!!section && typeof section === "object" && !Array.isArray(section) && "context7" in section
);
}
async function hasRule(agentName: SetupAgent, scope: Scope): Promise<boolean> {
const agent = getAgent(agentName);
const rule = agent.rule;
if (rule.kind === "file") {
const ruleDir =
scope === "global" ? rule.dir("global") : join(process.cwd(), rule.dir("project"));
return pathExists(join(ruleDir, rule.filename));View on GitHub (pinned to 4416fb855b)