{"record":{"id":"45202f66a5ee47ce","repo":"davila7/claude-code-templates","slug":"could-not-analyze-mcps","errorCode":null,"errorMessage":"Could not analyze MCPs:","messagePattern":"Could not analyze MCPs:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cli-tool/src/analytics/core/YearInReview2025.js","lineNumber":810,"sourceCode":"            // Use modification time with slight offset for each MCP\n            if (modifiedAt.getFullYear() === 2025) {\n              const timestamp = new Date(modifiedAt.getTime() + (index * 1000)); // 1 second apart\n              mcpEvents.push({\n                name: name,\n                timestamp: timestamp\n              });\n            }\n          }\n        });\n      }\n\n      return {\n        mcps: mcps,\n        total: mcps.length,\n        events: mcpEvents.sort((a, b) => a.timestamp - b.timestamp)\n      };\n    } catch (error) {\n      console.warn('Could not analyze MCPs:', error.message);\n      return { mcps: [], total: 0, events: [] };\n    }\n  }\n\n  /**\n   * Analyze subagent usage\n   * @param {string} claudeDir - Claude directory path\n   * @returns {Promise<Object>} Subagents data\n   */\n  async analyzeSubagents(claudeDir) {\n    const fs = require('fs-extra');\n    const path = require('path');\n\n    try {\n      const projectsDir = path.join(claudeDir, 'projects');\n      if (!await fs.pathExists(projectsDir)) {\n        return { subagents: [], total: 0, events: [] };\n      }","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/analytics/core/YearInReview2025.js#L792-L828","documentation":"YearInReview2025 MCP analysis caught an error and returns empty MCP data ({mcps: [], total: 0, events: []}); the report's MCP section is blanked.","triggerScenarios":"Reading ~/.claude.json (or settings) to enumerate configured MCP servers fails — invalid JSON, oversized file, unexpected mcpServers shape.","commonSituations":"~/.claude.json corrupted by a crashed write; mcpServers entries with unusual structures from manual editing or other tools; file locked on Windows.","solutions":["Validate the config: jq . ~/.claude.json — fix or restore if invalid","Back up and let Claude Code regenerate the config if corruption is broad","Ignore if MCP stats aren't important for you","Update the CLI for tolerant MCP config parsing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const raw = await fs.readFile(cfgPath, 'utf8').catch(() => null);\nconst cfg = raw ? (() => { try { return JSON.parse(raw); } catch { return null; } })() : null;\nconst servers = cfg?.mcpServers && typeof cfg.mcpServers === 'object' ? Object.keys(cfg.mcpServers) : [];","typeGuard":"function hasMcpServers(cfg) {\n  return !!cfg && typeof cfg === 'object' &&\n    typeof cfg.mcpServers === 'object' && cfg.mcpServers !== null;\n}","tryCatchPattern":"try { return analyzeMcps(cfg); }\ncatch (error) { console.warn('Could not analyze MCPs:', error.message); return { mcps: [], total: 0, events: [] }; }","preventionTips":["Validate ~/.claude.json with jq after manual MCP edits","Keep a backup of ~/.claude.json before editing mcpServers","Let Claude Code manage the config file instead of hand-editing"],"tags":["year-in-review","mcp","config-parsing"],"backgroundTag":"mcp-config-parse-error","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}