@virling/ccdoctor 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project are documented here. The format follows [Kee
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.2.0] - 2026-11-27
8
+
9
+ ### Added
10
+
11
+ - MCP servers shipped by enabled plugins are checked and probed.
12
+ - Run from any folder inside a project: ccdoctor walks up to the project folder Claude Code keys its config by.
13
+
7
14
  ## [0.1.0] - 2026-11-27
8
15
 
9
16
  ### Added
@@ -13,5 +20,6 @@ All notable changes to this project are documented here. The format follows [Kee
13
20
  - Warns when an MCP server is registered but the hooks it ships are missing.
14
21
  - `--json` output; exit code 1 when any check fails.
15
22
 
16
- [Unreleased]: https://github.com/virling/ccdoctor/compare/v0.1.0...HEAD
23
+ [Unreleased]: https://github.com/virling/ccdoctor/compare/v0.2.0...HEAD
24
+ [0.2.0]: https://github.com/virling/ccdoctor/compare/v0.1.0...v0.2.0
17
25
  [0.1.0]: https://github.com/virling/ccdoctor/releases/tag/v0.1.0
package/README.md CHANGED
@@ -10,7 +10,7 @@ Typical catch: an MCP server is registered but the hooks that make it useful are
10
10
 
11
11
  ## Install
12
12
 
13
- Run it from the project folder you open Claude Code in:
13
+ Run it from your project, or any folder inside it. ccdoctor walks up to the project folder Claude Code uses:
14
14
 
15
15
  ```bash
16
16
  npx @virling/ccdoctor
@@ -46,7 +46,7 @@ Exit code is 1 when any check fails.
46
46
 
47
47
  - **Settings.** `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`), and `.claude/settings.json` and `.claude/settings.local.json` in the current folder. Invalid JSON fails.
48
48
  - **Hooks.** Every `command` hook in those files. The executable must exist on `PATH` or as a file (`~` and `$CLAUDE_PROJECT_DIR` are expanded). For `node`, `bash`, `python3` and similar, the script path must exist too. A script run directly without the executable bit warns. Only the first command of a shell line is checked.
49
- - **MCP servers.** User scope (`mcpServers` in `~/.claude.json`), local scope (`projects[<this folder>].mcpServers` in `~/.claude.json`) and project scope (`.mcp.json`). For stdio servers the command must resolve. A name defined in more than one scope warns. `env` values, headers and URLs are never printed.
49
+ - **MCP servers.** User scope (`mcpServers` in `~/.claude.json`), local scope (`projects[<this folder>].mcpServers` in `~/.claude.json`) project scope (`.mcp.json`), and servers shipped by enabled plugins (their `.mcp.json` or `mcpServers` in `.claude-plugin/plugin.json`, with `${CLAUDE_PLUGIN_ROOT}` expanded). For stdio servers the command must resolve. A name defined in more than one scope warns. `env` values, headers and URLs are never printed.
50
50
  - **Plugins.** Each plugin set to `true` in `enabledPlugins` must have a folder under `~/.claude/plugins/cache/<marketplace>/<plugin>/`. Missing ones warn.
51
51
  - **Wiring.** A stdio MCP server named `agentmem`, or whose package ships `hooks/hooks.json`, warns when no hook command (in settings or enabled plugins) mentions its name or package folder.
52
52
  - **Probe** (`--probe`). Starts each stdio server, sends `initialize`, `notifications/initialized` and `tools/list`, reports the tool count or the error, then kills it. http and sse servers are not probed.
@@ -63,6 +63,13 @@ ccdoctor --help
63
63
 
64
64
  ccdoctor never writes to your configuration.
65
65
 
66
+ ## More tools from Virling
67
+
68
+ - [agentmem](https://github.com/virling/agentmem): project memory for AI coding agents, shared across Claude Code, Cursor, Codex and other MCP clients.
69
+ - [ciwhy](https://github.com/virling/ciwhy): finds the real error in a failed GitHub Actions run and tells you if it is flaky.
70
+ - [npmship](https://github.com/virling/npmship): releases an npm package and verifies it landed on npm, in CI and on GitHub.
71
+ - [subagents](https://github.com/virling/subagents): reviews what Claude Code subagents did in a session and flags repeated or wasted work.
72
+
66
73
  ## License
67
74
 
68
75
  [PolyForm Noncommercial 1.0.0](LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virling/ccdoctor",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Check a Claude Code setup for broken hooks, MCP servers and plugins",
5
5
  "type": "module",
6
6
  "bin": {
package/src/checks.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { checkCommand, expand, isFile, tokenize } from "./command.js";
4
- import { pluginDir, readJson, settingsFiles } from "./config.js";
4
+ import { pluginDir, pluginServers, projectRoot, readJson, settingsFiles } from "./config.js";
5
5
  import { probe } from "./probe.js";
6
6
 
7
7
  function packageRoot(file) {
@@ -26,6 +26,10 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
26
26
  const results = [];
27
27
  const short = (s) => s.split(p.home).join("~");
28
28
  const add = (section, level, name, detail = "") => results.push({ section, level, name: short(name), detail: short(detail) });
29
+ const claudeJson = readJson(p.claudeJson);
30
+ const root = projectRoot(p, Object.keys(claudeJson.data?.projects || {}));
31
+ if (root !== p.cwd) add("Settings", "info", `project root ${root}`);
32
+ p = { ...p, cwd: root };
29
33
  const ctx = { cwd: p.cwd, home: p.home, PATH: p.PATH, vars: { ...p.env, CLAUDE_PROJECT_DIR: p.cwd } };
30
34
 
31
35
  const settings = settingsFiles(p).map((f) => ({ ...f, ...readJson(f.file) })).filter((f) => !f.missing);
@@ -43,15 +47,18 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
43
47
  }
44
48
  if (!commands.length) add("Hooks", "info", "no hooks configured");
45
49
 
50
+ const enabled = Object.assign({}, ...valid.map((s) => s.data.enabledPlugins || {}));
51
+ const plugins = Object.keys(enabled).filter((k) => enabled[k] === true).map((key) => ({ key, dir: pluginDir(p.configDir, key) }));
52
+
46
53
  const servers = [];
47
- const collect = (map, scope) => Object.entries(map || {}).forEach(([name, config]) => servers.push({ name, scope, config }));
48
- const claudeJson = readJson(p.claudeJson);
54
+ const collect = (map, scope, vars = {}) => Object.entries(map || {}).forEach(([name, config]) => servers.push({ name, scope, config, vars }));
49
55
  const mcpJson = readJson(path.join(p.cwd, ".mcp.json"));
50
56
  if (claudeJson.error) add("MCP servers", "fail", p.claudeJson, `invalid JSON: ${claudeJson.error}`);
51
57
  if (mcpJson.error) add("MCP servers", "fail", path.join(p.cwd, ".mcp.json"), `invalid JSON: ${mcpJson.error}`);
52
58
  collect(claudeJson.data?.mcpServers, "user");
53
59
  collect(claudeJson.data?.projects?.[p.cwd]?.mcpServers, "local");
54
60
  collect(mcpJson.data?.mcpServers, "project");
61
+ for (const pl of plugins.filter((pl) => pl.dir)) collect(pluginServers(pl.dir), `plugin ${pl.key}`, { CLAUDE_PLUGIN_ROOT: pl.dir });
55
62
  if (!servers.length) add("MCP servers", "info", "no MCP servers registered");
56
63
 
57
64
  const stdio = [];
@@ -61,12 +68,12 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
61
68
  add("MCP servers", "info", `${s.name} (${s.scope}, ${type})`, "remote, not checked");
62
69
  continue;
63
70
  }
64
- const r = checkCommand([s.config.command ?? "", ...(s.config.args || [])], ctx);
71
+ const r = checkCommand([s.config.command ?? "", ...(s.config.args || [])], { ...ctx, vars: { ...ctx.vars, ...s.vars } });
65
72
  add("MCP servers", r.level, `${s.name} (${s.scope})`, r.detail);
66
73
  stdio.push(Object.assign(s, { check: r }));
67
74
  }
68
75
  for (const name of new Set(servers.map((s) => s.name))) {
69
- const list = servers.filter((s) => s.name === name);
76
+ const list = servers.filter((s) => s.name === name && !s.scope.startsWith("plugin"));
70
77
  if (list.length > 1) add("MCP servers", "warn", name, `defined more than once: ${list.map((s) => s.scope).join(", ")}`);
71
78
  }
72
79
 
@@ -75,10 +82,11 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
75
82
  const runnable = stdio.filter((s) => s.check.level !== "fail");
76
83
  const probed = await Promise.all(
77
84
  runnable.map((s) => {
78
- const env = { ...p.env };
79
- for (const [k, v] of Object.entries(s.config.env || {})) env[k] = expand(String(v), p.env, p.home);
80
- const args = (s.config.args || []).map((a) => expand(a, p.env, p.home));
81
- return probe(expand(s.config.command, p.env, p.home), args, { cwd: p.cwd, env, timeout });
85
+ const vars = { ...p.env, ...s.vars };
86
+ const env = { ...vars };
87
+ for (const [k, v] of Object.entries(s.config.env || {})) env[k] = expand(String(v), vars, p.home);
88
+ const args = (s.config.args || []).map((a) => expand(a, vars, p.home));
89
+ return probe(expand(s.config.command, vars, p.home), args, { cwd: p.cwd, env, timeout });
82
90
  })
83
91
  );
84
92
  runnable.forEach((s, i) => {
@@ -88,16 +96,13 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
88
96
  for (const s of stdio.filter((s) => !runnable.includes(s))) add("Probe", "info", s.name, "not probed (command not found)");
89
97
  }
90
98
 
91
- const enabled = Object.assign({}, ...valid.map((s) => s.data.enabledPlugins || {}));
92
- const keys = Object.keys(enabled).filter((k) => enabled[k] === true);
93
- if (!keys.length) add("Plugins", "info", "no plugins enabled");
94
- for (const key of keys) {
95
- const dir = pluginDir(p.configDir, key);
99
+ if (!plugins.length) add("Plugins", "info", "no plugins enabled");
100
+ for (const { key, dir } of plugins) {
96
101
  add("Plugins", dir ? "ok" : "warn", key, dir ? "" : "enabled but not found in plugins/cache");
97
102
  if (dir) commands.push(...hookCommands(readJson(path.join(dir, "hooks", "hooks.json")).data?.hooks).map((h) => h.command));
98
103
  }
99
104
 
100
- for (const s of stdio) {
105
+ for (const s of stdio.filter((s) => !s.scope.startsWith("plugin"))) {
101
106
  const root = packageRoot(s.check.files.at(-1));
102
107
  const shipsHooks = root && isFile(path.join(root, "hooks", "hooks.json"));
103
108
  if (s.name !== "agentmem" && !shipsHooks) continue;
package/src/config.js CHANGED
@@ -26,6 +26,20 @@ export function settingsFiles(p) {
26
26
  return files.filter((f, i) => files.findIndex((g) => g.file === f.file) === i);
27
27
  }
28
28
 
29
+ // Claude Code keys project config by the folder it was started in, so walk up from a subfolder to find it.
30
+ export function projectRoot(p, known = []) {
31
+ for (let dir = p.cwd; dir !== path.dirname(dir) && dir !== p.home; dir = path.dirname(dir)) {
32
+ if (known.includes(dir) || fs.existsSync(path.join(dir, ".mcp.json")) || fs.existsSync(path.join(dir, ".claude"))) return dir;
33
+ }
34
+ return p.cwd;
35
+ }
36
+
37
+ export function pluginServers(dir) {
38
+ const manifest = readJson(path.join(dir, ".claude-plugin", "plugin.json")).data?.mcpServers;
39
+ const fromManifest = typeof manifest === "string" ? readJson(path.join(dir, manifest)).data?.mcpServers : manifest;
40
+ return { ...readJson(path.join(dir, ".mcp.json")).data?.mcpServers, ...fromManifest };
41
+ }
42
+
29
43
  export function pluginDir(configDir, key) {
30
44
  const installed = readJson(path.join(configDir, "plugins", "installed_plugins.json")).data?.plugins?.[key]?.[0]?.installPath;
31
45
  if (installed && fs.existsSync(installed)) return installed;