affaan-m/ECC · error
Failed to parse at
Error message
Failed to parse ${label} at ${filePath}: ${error.message} What it means
readJsonObject in the Kimi project install target reads a JSON config file (Kimi's project MCP config) and re-throws any read or parse failure with the labeled file path and underlying error message. It exists so merge operations fail with a clear, path-qualified error instead of a raw fs/JSON stack.
Solutions
- Open the file at the path in the message and fix the JSON syntax error from error.message
- Remove non-JSON syntax (comments, trailing commas) — Kimi project config must be plain JSON
- Fix file permissions if the error indicates EACCES
- If unrecoverable, back up and delete the file so the installer recreates it
Example fix
// before: .kimi/mcp.json with comment
{ // my servers
"mcpServers": {}
}
// after
{
"mcpServers": {}
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight: verify the Kimi MCP config parses before install
try {
JSON.parse(fs.readFileSync(kimiMcpPath, 'utf8'));
} catch (e) {
console.error(`Fix ${kimiMcpPath} before installing: ${e.message}`);
} Type guard
function isPlainObject(v) {
return v !== null && typeof v === 'object' && !Array.isArray(v);
} Try / catch
try {
runInstallOperation(op);
} catch (e) {
if (/Failed to parse .* at .*:/.test(e.message)) {
// fix the JSON at the path named in the message, then retry
} else throw e;
} Prevention
- Keep Kimi project config files as strict plain JSON
- Lint JSON config files in CI or via editor plugins before running installs
- Never interrupt a running install — partial writes corrupt JSON
When it happens
Trigger: createMcpMergeOperation for a Kimi project target finds a destination file that exists but is not valid JSON (comments, trailing commas, truncation) or cannot be read (ENOENT/EACCES) when it attempts to merge MCP server entries.
Common situations: Hand-editing the Kimi MCP config as JSONC with comments; a partial write from a crashed process; file permission changes after switching machines or users.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse at
- Invalid at : expected a JSON object
- Failed to read
- Invalid at : expected a JSON object
- application request must be a JSON object
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/bda414a353367c2e.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/install-targets/kimi-project.js:15
const fs = require('fs');
const path = require('path');
const {
createInstallTargetAdapter,
createManagedOperation,
isForeignPlatformPath,
} = require('./helpers');
function readJsonObject(filePath, label) {
let parsed;
try {
parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (error) {
throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);
}
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);
}
return parsed;
}
function createMcpMergeOperation(moduleId, repoRoot, targetRoot) {
if (!repoRoot) {
throw new Error('repoRoot is required to plan Kimi MCP configuration');
}
const sourceRelativePath = '.mcp.json';
const sourcePath = path.join(repoRoot, sourceRelativePath);
if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isFile()) {
return null;View on GitHub (pinned to 8321021c54)