context-doctor 0.12.0 → 0.12.1
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/dist/doctor.js +5 -3
- package/dist/install.d.ts +14 -0
- package/dist/install.js +17 -1
- package/dist/mcp.js +1 -1
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -26,8 +26,10 @@ function checkMcpEntry(appName, configPath) {
|
|
|
26
26
|
const entry = config.mcpServers?.["context-doctor"];
|
|
27
27
|
if (!entry)
|
|
28
28
|
return { label: appName, status: "fail", detail: `no context-doctor entry in ${configPath} — run: context-doctor install` };
|
|
29
|
-
// Absolute-path entries must point at a file that still exists.
|
|
30
|
-
|
|
29
|
+
// Absolute-path entries must point at a file that still exists. Launcher
|
|
30
|
+
// forms (npx, and Windows' cmd /c npx) resolve at spawn time, not now.
|
|
31
|
+
const launcher = entry.command === "npx" || entry.command === "cmd";
|
|
32
|
+
const target = launcher ? null : entry.args?.[0];
|
|
31
33
|
if (target && !existsSync(target)) {
|
|
32
34
|
return { label: appName, status: "fail", detail: `MCP entry points at missing file ${target} — re-run: context-doctor install` };
|
|
33
35
|
}
|
|
@@ -41,7 +43,7 @@ function checkMcpEntry(appName, configPath) {
|
|
|
41
43
|
detail: `MCP command ${cmd} no longer exists (a Node upgrade moves version-pinned paths) — re-run: context-doctor install`,
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
|
-
return { label: appName, status: "ok", detail: `MCP wired (${
|
|
46
|
+
return { label: appName, status: "ok", detail: `MCP wired (${launcher ? "npx, tracks npm releases" : "local build"})` };
|
|
45
47
|
}
|
|
46
48
|
catch (e) {
|
|
47
49
|
return { label: appName, status: "fail", detail: `${configPath} is not valid JSON (${e.message})` };
|
package/dist/install.d.ts
CHANGED
|
@@ -6,5 +6,19 @@
|
|
|
6
6
|
* Every config edit is a careful JSON merge with a .backup file written first.
|
|
7
7
|
* `context-doctor uninstall` reverses it.
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* How to invoke the published package as an MCP server on a given platform.
|
|
11
|
+
*
|
|
12
|
+
* On Windows npx is `npx.cmd` — a batch script, not an executable. MCP clients
|
|
13
|
+
* spawn their server directly, without a shell, so a bare "npx" fails with
|
|
14
|
+
* ENOENT and the app simply shows no tools and no error. Hence the cmd /c
|
|
15
|
+
* wrapper that every working Windows MCP config uses.
|
|
16
|
+
*
|
|
17
|
+
* Exported so the platform branch is testable from any host OS.
|
|
18
|
+
*/
|
|
19
|
+
export declare function npxLauncher(platformName: string): {
|
|
20
|
+
command: string;
|
|
21
|
+
args: string[];
|
|
22
|
+
};
|
|
9
23
|
export declare function runInstall(): void;
|
|
10
24
|
export declare function runUninstall(): void;
|
package/dist/install.js
CHANGED
|
@@ -43,9 +43,25 @@ function serverEntry() {
|
|
|
43
43
|
const localMcp = join(selfDir, "mcp.js");
|
|
44
44
|
const fromPackage = selfDir.includes(`${sep}node_modules${sep}`) || selfDir.includes("_npx");
|
|
45
45
|
if (!fromPackage && existsSync(localMcp)) {
|
|
46
|
+
// `node` is node.exe on Windows — directly spawnable, no shell needed.
|
|
46
47
|
return { command: "node", args: [localMcp] };
|
|
47
48
|
}
|
|
48
|
-
return
|
|
49
|
+
return npxLauncher(platform());
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* How to invoke the published package as an MCP server on a given platform.
|
|
53
|
+
*
|
|
54
|
+
* On Windows npx is `npx.cmd` — a batch script, not an executable. MCP clients
|
|
55
|
+
* spawn their server directly, without a shell, so a bare "npx" fails with
|
|
56
|
+
* ENOENT and the app simply shows no tools and no error. Hence the cmd /c
|
|
57
|
+
* wrapper that every working Windows MCP config uses.
|
|
58
|
+
*
|
|
59
|
+
* Exported so the platform branch is testable from any host OS.
|
|
60
|
+
*/
|
|
61
|
+
export function npxLauncher(platformName) {
|
|
62
|
+
return platformName === "win32"
|
|
63
|
+
? { command: "cmd", args: ["/c", "npx", "-y", "context-doctor-mcp"] }
|
|
64
|
+
: { command: "npx", args: ["-y", "context-doctor-mcp"] };
|
|
49
65
|
}
|
|
50
66
|
function readJson(path) {
|
|
51
67
|
if (!existsSync(path))
|
package/dist/mcp.js
CHANGED
|
@@ -37,7 +37,7 @@ const STRATEGY_IDS = ["dedupe", "trim-tool-results", "trim-tool-calls", "strip-b
|
|
|
37
37
|
* recommended pattern.
|
|
38
38
|
*/
|
|
39
39
|
function createServer() {
|
|
40
|
-
const server = new McpServer({ name: "context-doctor", version: "0.12.
|
|
40
|
+
const server = new McpServer({ name: "context-doctor", version: "0.12.1" }, { instructions: SERVER_INSTRUCTIONS });
|
|
41
41
|
server.tool("profile_context", "Profile an LLM conversation or prompt: token breakdown by category, largest messages, and actionable findings about wasted context (duplicates, oversized tool results, base64 blobs, cache-unfriendly ordering). Accepts OpenAI/Anthropic conversation JSON or raw text. Call this immediately whenever the user asks about token usage, context size, LLM cost, or latency — and proactively offer it once a conversation grows long or accumulates large pasted content.", {
|
|
42
42
|
conversation: z.string().describe("Conversation JSON (OpenAI or Anthropic format, or bare message array) or raw prompt text"),
|
|
43
43
|
model: z.string().optional().describe("Target model name for context-window math, e.g. claude-sonnet-5 or gpt-4o"),
|
package/package.json
CHANGED