@tellagen/mcp-server 0.5.1 → 0.7.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/README.md +53 -3
- package/SKILL.md +143 -19
- package/contracts/mcp-protocol.json +64 -3
- package/contracts/runbooks/manifest.json +24 -14
- package/contracts/runbooks/v2/client-protocol.json +65 -2
- package/contracts/runbooks/v2/client-writes.guidance.json +16 -1
- package/contracts/runbooks/v2/fixtures/filesystem-pressure.json +22 -31
- package/contracts/runbooks/v2/fixtures/timeline-event-blocks-rejected.json +15 -1
- package/contracts/runbooks/v2/investigation-window.guidance.json +45 -0
- package/contracts/runbooks/v2/question-checks.guidance.json +49 -0
- package/contracts/runbooks/v2/result-summary.guidance.json +53 -5
- package/contracts/runbooks/v2/timeline-event-blocks.schema.json +66 -3
- package/contracts/tellagen-runbook-contracts.json +3 -3
- package/dist/active-run.d.ts +6 -0
- package/dist/active-run.js +14 -0
- package/dist/active-run.js.map +1 -1
- package/dist/cli/doctor.d.ts +19 -0
- package/dist/cli/doctor.js +179 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/kubernetes.d.ts +47 -0
- package/dist/cli/kubernetes.js +369 -0
- package/dist/cli/kubernetes.js.map +1 -0
- package/dist/cli/main.js +10 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/diagnosis-structure.d.ts +380 -102
- package/dist/diagnosis-structure.js +334 -14
- package/dist/diagnosis-structure.js.map +1 -1
- package/dist/doctor/checks.d.ts +42 -0
- package/dist/doctor/checks.js +181 -0
- package/dist/doctor/checks.js.map +1 -0
- package/dist/doctor/config-files.d.ts +49 -0
- package/dist/doctor/config-files.js +121 -0
- package/dist/doctor/config-files.js.map +1 -0
- package/dist/doctor/k8s-read-only.d.ts +16 -0
- package/dist/doctor/k8s-read-only.js +89 -0
- package/dist/doctor/k8s-read-only.js.map +1 -0
- package/dist/doctor/real-fs.d.ts +3 -0
- package/dist/doctor/real-fs.js +36 -0
- package/dist/doctor/real-fs.js.map +1 -0
- package/dist/doctor/toml.d.ts +13 -0
- package/dist/doctor/toml.js +205 -0
- package/dist/doctor/toml.js.map +1 -0
- package/dist/figures.d.ts +520 -101
- package/dist/figures.js +341 -7
- package/dist/figures.js.map +1 -1
- package/dist/heartbeat.d.ts +3 -0
- package/dist/heartbeat.js +32 -1
- package/dist/heartbeat.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/k8s-safety.d.ts +42 -0
- package/dist/k8s-safety.js +33 -0
- package/dist/k8s-safety.js.map +1 -0
- package/dist/listen-config.d.ts +5 -5
- package/dist/listen-probe.d.ts +14 -1
- package/dist/listen-probe.js +83 -5
- package/dist/listen-probe.js.map +1 -1
- package/dist/listen-settings.d.ts +8 -0
- package/dist/listen-settings.js +29 -0
- package/dist/listen-settings.js.map +1 -1
- package/dist/listener.d.ts +11 -0
- package/dist/listener.js +60 -16
- package/dist/listener.js.map +1 -1
- package/dist/log-lines.d.ts +118 -0
- package/dist/log-lines.js +534 -0
- package/dist/log-lines.js.map +1 -0
- package/dist/redact.d.ts +21 -0
- package/dist/redact.js +212 -5
- package/dist/redact.js.map +1 -1
- package/dist/run-events.js +13 -1
- package/dist/run-events.js.map +1 -1
- package/dist/run-requests.d.ts +16 -0
- package/dist/run-requests.js +56 -0
- package/dist/run-requests.js.map +1 -0
- package/dist/run-window.d.ts +59 -0
- package/dist/run-window.js +141 -0
- package/dist/run-window.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +11 -9
- package/dist/server.js.map +1 -1
- package/dist/session.d.ts +37 -0
- package/dist/session.js +59 -0
- package/dist/session.js.map +1 -1
- package/dist/tool-report.d.ts +2 -0
- package/dist/tool-report.js +3 -0
- package/dist/tool-report.js.map +1 -0
- package/dist/tools/amendments.d.ts +13 -0
- package/dist/tools/amendments.js +206 -0
- package/dist/tools/amendments.js.map +1 -0
- package/dist/tools/catalog.js +4 -0
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/diagnostics.js +131 -3
- package/dist/tools/diagnostics.js.map +1 -1
- package/dist/tools/figures.d.ts +2 -2
- package/dist/tools/figures.js +37 -9
- package/dist/tools/figures.js.map +1 -1
- package/dist/tools/findings.d.ts +136 -0
- package/dist/tools/findings.js +68 -7
- package/dist/tools/findings.js.map +1 -1
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/investigations.d.ts +3223 -5
- package/dist/tools/investigations.js +202 -50
- package/dist/tools/investigations.js.map +1 -1
- package/dist/tools/next.d.ts +16 -0
- package/dist/tools/next.js +49 -1
- package/dist/tools/next.js.map +1 -1
- package/dist/tools/postmortem-runbooks.d.ts +20 -20
- package/dist/tools/requests.d.ts +3 -0
- package/dist/tools/requests.js +62 -0
- package/dist/tools/requests.js.map +1 -0
- package/dist/tools/resume.js +14 -1
- package/dist/tools/resume.js.map +1 -1
- package/dist/tools/source-links.d.ts +7 -0
- package/dist/tools/source-links.js +32 -5
- package/dist/tools/source-links.js.map +1 -1
- package/dist/tools/timeline.js +24 -2
- package/dist/tools/timeline.js.map +1 -1
- package/dist/version.d.ts +4 -2
- package/dist/version.js +6 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/server.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type DoctorClient, type DoctorFs, type ServerEntry } from "./config-files.js";
|
|
2
|
+
export declare const DOCTOR_TOOLS: readonly ["grafana", "kubernetes", "github", "docs"];
|
|
3
|
+
export type DoctorTool = (typeof DOCTOR_TOOLS)[number];
|
|
4
|
+
/** The shorter PATH that a desktop app starts its servers with. A terminal PATH is not used. */
|
|
5
|
+
export declare const DESKTOP_BASE_PATH = "/usr/bin:/bin:/usr/sbin:/sbin";
|
|
6
|
+
/** The catalog tool an entry is, by its name first and then by its command line. */
|
|
7
|
+
export declare function toolOfEntry(entry: ServerEntry): DoctorTool | undefined;
|
|
8
|
+
export type CheckStatus = "ok" | "failed" | "warning" | "not_checked";
|
|
9
|
+
export type AccessProblem = "missing_tool" | "auth_missing" | "unreachable";
|
|
10
|
+
export interface DoctorCheck {
|
|
11
|
+
id: "command_resolves" | "env_present" | "health";
|
|
12
|
+
label: string;
|
|
13
|
+
status: CheckStatus;
|
|
14
|
+
/** One plain sentence of what to do. It may name a path of this computer, so it never leaves it. */
|
|
15
|
+
summary: string;
|
|
16
|
+
/** The same fact in fixed words with no name, path or value. It is what --report sends. */
|
|
17
|
+
reportSummary: string;
|
|
18
|
+
/** For command_resolves: the full path to use in the command, when the command exists elsewhere. */
|
|
19
|
+
fixCommand?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ToolResult {
|
|
22
|
+
client: DoctorClient;
|
|
23
|
+
source: string;
|
|
24
|
+
serverName: string;
|
|
25
|
+
tool: DoctorTool;
|
|
26
|
+
checks: DoctorCheck[];
|
|
27
|
+
problem?: AccessProblem;
|
|
28
|
+
entry: ServerEntry;
|
|
29
|
+
}
|
|
30
|
+
export interface CheckDeps {
|
|
31
|
+
fs: DoctorFs;
|
|
32
|
+
/** The PATH of the shell that runs the doctor. */
|
|
33
|
+
shellPath: string;
|
|
34
|
+
fetch: (url: string, init: {
|
|
35
|
+
signal: AbortSignal;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
status: number;
|
|
38
|
+
}>;
|
|
39
|
+
healthTimeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Runs the checks of one server entry that matches a catalog tool. */
|
|
42
|
+
export declare function checkEntry(entry: ServerEntry, tool: DoctorTool, deps: CheckDeps): Promise<ToolResult>;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { delimiter, isAbsolute, join, basename } from "node:path";
|
|
2
|
+
import { CLIENT_LABELS } from "./config-files.js";
|
|
3
|
+
export const DOCTOR_TOOLS = ["grafana", "kubernetes", "github", "docs"];
|
|
4
|
+
/** The shorter PATH that a desktop app starts its servers with. A terminal PATH is not used. */
|
|
5
|
+
export const DESKTOP_BASE_PATH = "/usr/bin:/bin:/usr/sbin:/sbin";
|
|
6
|
+
/** Clients that a person starts from a dock or a menu, not from a terminal. */
|
|
7
|
+
const DESKTOP_CLIENTS = new Set(["claude-desktop", "cursor"]);
|
|
8
|
+
const PROFILES = {
|
|
9
|
+
grafana: {
|
|
10
|
+
name: /grafana/i,
|
|
11
|
+
command: /mcp-grafana|grafana-mcp/i,
|
|
12
|
+
env: [["GRAFANA_URL"], ["GRAFANA_SERVICE_ACCOUNT_TOKEN", "GRAFANA_API_KEY"]],
|
|
13
|
+
},
|
|
14
|
+
kubernetes: { name: /kubernetes|k8s|kubectl/i, command: /kubernetes-mcp-server|mcp-server-kubernetes/i, env: [] },
|
|
15
|
+
github: { name: /github/i, command: /github-mcp-server|server-github/i, env: [["GITHUB_PERSONAL_ACCESS_TOKEN", "GITHUB_TOKEN"]] },
|
|
16
|
+
docs: {
|
|
17
|
+
// A documentation server, or the Atlassian, Confluence or Notion servers that hold the runbooks.
|
|
18
|
+
// A Bitbucket server is a code server, not documentation.
|
|
19
|
+
name: /^(?!.*bitbucket).*((^|[^a-z])(docs?|documentation|atlassian|jira|confluence|notion)([^a-z]|$))/i,
|
|
20
|
+
command: /docs-mcp|mcp-docs|mcp-atlassian|atlassian[-/]?mcp|mcp\.atlassian\.com|confluence|notion-mcp|mcp\.notion\.com|@notionhq/i,
|
|
21
|
+
env: [],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/** The catalog tool an entry is, by its name first and then by its command line. */
|
|
25
|
+
export function toolOfEntry(entry) {
|
|
26
|
+
for (const tool of DOCTOR_TOOLS)
|
|
27
|
+
if (PROFILES[tool].name.test(entry.name))
|
|
28
|
+
return tool;
|
|
29
|
+
const line = [entry.command ?? "", ...entry.args, entry.url ?? ""].join(" ");
|
|
30
|
+
for (const tool of DOCTOR_TOOLS)
|
|
31
|
+
if (PROFILES[tool].command.test(line))
|
|
32
|
+
return tool;
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const COMMON_DIRS = ["/opt/homebrew/bin", "/usr/local/bin", ".local/bin", ".cargo/bin", ".bun/bin"];
|
|
36
|
+
function executableNames(command, fs) {
|
|
37
|
+
if (fs.platform !== "win32" || /\.[A-Za-z0-9]{1,4}$/.test(command))
|
|
38
|
+
return [command];
|
|
39
|
+
return [command, ...[".exe", ".cmd", ".bat"].map((ext) => command + ext)];
|
|
40
|
+
}
|
|
41
|
+
function search(command, dirs, fs) {
|
|
42
|
+
for (const dir of dirs) {
|
|
43
|
+
if (!dir)
|
|
44
|
+
continue;
|
|
45
|
+
for (const name of executableNames(command, fs)) {
|
|
46
|
+
const path = join(dir, name);
|
|
47
|
+
if (fs.isExecutable(path))
|
|
48
|
+
return path;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
function pathList(value, fs) {
|
|
54
|
+
return (value ?? "").split(fs.platform === "win32" ? ";" : delimiter).filter(Boolean);
|
|
55
|
+
}
|
|
56
|
+
function commandCheck(entry, deps) {
|
|
57
|
+
const { fs } = deps;
|
|
58
|
+
const label = CLIENT_LABELS[entry.client];
|
|
59
|
+
const first = (entry.command ?? "").split(/\s+/)[0] ?? "";
|
|
60
|
+
const name = basename(first);
|
|
61
|
+
const entryPath = pathList(entry.env.PATH ?? entry.env.Path, fs);
|
|
62
|
+
const desktop = DESKTOP_CLIENTS.has(entry.client) && fs.platform !== "win32";
|
|
63
|
+
const clientDirs = desktop ? [...pathList(DESKTOP_BASE_PATH, fs), ...entryPath] : [...pathList(deps.shellPath, fs), ...entryPath];
|
|
64
|
+
const check = (status, summary, reportSummary, fixCommand) => ({
|
|
65
|
+
id: "command_resolves",
|
|
66
|
+
label: "The command can be started",
|
|
67
|
+
status,
|
|
68
|
+
summary,
|
|
69
|
+
reportSummary,
|
|
70
|
+
...(fixCommand ? { fixCommand } : {}),
|
|
71
|
+
});
|
|
72
|
+
if (isAbsolute(first) || /[\\/]/.test(first)) {
|
|
73
|
+
const full = isAbsolute(first) ? first : join(fs.cwd, first);
|
|
74
|
+
if (fs.isExecutable(full))
|
|
75
|
+
return check("ok", `${name} is there and can run.`, "The command is there and can run.");
|
|
76
|
+
return check("failed", `${label} cannot run the command ${name}: the file is missing or is not allowed to run. Install it again or fix the path in the command.`, "The command file is missing or cannot run.");
|
|
77
|
+
}
|
|
78
|
+
const found = search(first, clientDirs, fs);
|
|
79
|
+
if (found) {
|
|
80
|
+
return check("ok", `${label} finds ${name}.`, "The command is found where the client starts it.");
|
|
81
|
+
}
|
|
82
|
+
const elsewhere = search(first, [...pathList(deps.shellPath, fs), ...COMMON_DIRS.map((dir) => (isAbsolute(dir) ? dir : join(fs.home, dir)))], fs);
|
|
83
|
+
if (elsewhere) {
|
|
84
|
+
const where = desktop ? `${label} starts ${name} from a shorter PATH than your terminal.` : `${label} does not find ${name} on its PATH.`;
|
|
85
|
+
return check("failed", `${where} Use ${elsewhere} in the command.`, desktop ? "The client starts the command from a shorter PATH than a terminal, so it cannot find it." : "The command is not on the PATH the client uses.", elsewhere);
|
|
86
|
+
}
|
|
87
|
+
return check("failed", `${name} is not on any PATH that ${label} uses, and was not found in the usual places. Install it, then use its full path in the command.`, "The command was not found on any PATH.");
|
|
88
|
+
}
|
|
89
|
+
function envCheck(entry, tool) {
|
|
90
|
+
const groups = PROFILES[tool].env;
|
|
91
|
+
if (groups.length === 0 || entry.url)
|
|
92
|
+
return undefined;
|
|
93
|
+
const missing = groups.filter((group) => !group.some((name) => (entry.env[name] ?? "").trim() !== "")).map((group) => group.join(" or "));
|
|
94
|
+
if (missing.length === 0) {
|
|
95
|
+
return { id: "env_present", label: "The settings the tool needs are set", status: "ok", summary: "Every setting the tool needs is in the entry.", reportSummary: "The required settings are in the client config." };
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
id: "env_present",
|
|
99
|
+
label: "The settings the tool needs are set",
|
|
100
|
+
status: "failed",
|
|
101
|
+
summary: `Add ${missing.join(" and ")} to the env of the ${entry.name} entry. Only the names are checked, never the values.`,
|
|
102
|
+
reportSummary: "A setting the tool needs is missing from the client config.",
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function healthAddress(entry) {
|
|
106
|
+
const raw = (entry.env.GRAFANA_URL ?? "").trim();
|
|
107
|
+
if (!raw)
|
|
108
|
+
return undefined;
|
|
109
|
+
try {
|
|
110
|
+
const url = new URL(raw);
|
|
111
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
112
|
+
return undefined;
|
|
113
|
+
url.username = "";
|
|
114
|
+
url.password = "";
|
|
115
|
+
url.search = "";
|
|
116
|
+
url.hash = "";
|
|
117
|
+
return url;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async function healthCheck(entry, deps) {
|
|
124
|
+
const base = healthAddress(entry);
|
|
125
|
+
if (!base)
|
|
126
|
+
return undefined;
|
|
127
|
+
const target = `${base.origin}${base.pathname.replace(/\/+$/, "")}/api/health`;
|
|
128
|
+
const label = "Grafana answers";
|
|
129
|
+
const controller = new AbortController();
|
|
130
|
+
const timer = setTimeout(() => controller.abort(), deps.healthTimeoutMs ?? 5000);
|
|
131
|
+
try {
|
|
132
|
+
// No token is sent: /api/health needs none.
|
|
133
|
+
const res = await deps.fetch(target, { signal: controller.signal });
|
|
134
|
+
if (res.status >= 200 && res.status < 300) {
|
|
135
|
+
return { id: "health", label, status: "ok", summary: `${base.origin} answers /api/health.`, reportSummary: "Grafana answers its health check." };
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
id: "health",
|
|
139
|
+
label,
|
|
140
|
+
status: "failed",
|
|
141
|
+
summary: `${base.origin} answered /api/health with status ${res.status}. Check GRAFANA_URL and the network.`,
|
|
142
|
+
reportSummary: "Grafana did not answer its health check.",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return {
|
|
147
|
+
id: "health",
|
|
148
|
+
label,
|
|
149
|
+
status: "failed",
|
|
150
|
+
summary: `${base.origin} did not answer /api/health. Check GRAFANA_URL, the VPN and the network.`,
|
|
151
|
+
reportSummary: "Grafana did not answer its health check.",
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Runs the checks of one server entry that matches a catalog tool. */
|
|
159
|
+
export async function checkEntry(entry, tool, deps) {
|
|
160
|
+
const checks = [];
|
|
161
|
+
if (entry.command)
|
|
162
|
+
checks.push(commandCheck(entry, deps));
|
|
163
|
+
const env = envCheck(entry, tool);
|
|
164
|
+
if (env)
|
|
165
|
+
checks.push(env);
|
|
166
|
+
if (tool === "grafana") {
|
|
167
|
+
const health = await healthCheck(entry, deps);
|
|
168
|
+
if (health)
|
|
169
|
+
checks.push(health);
|
|
170
|
+
}
|
|
171
|
+
const failed = (id) => checks.some((check) => check.id === id && check.status === "failed");
|
|
172
|
+
const problem = failed("command_resolves")
|
|
173
|
+
? "missing_tool"
|
|
174
|
+
: failed("env_present")
|
|
175
|
+
? "auth_missing"
|
|
176
|
+
: failed("health")
|
|
177
|
+
? "unreachable"
|
|
178
|
+
: undefined;
|
|
179
|
+
return { client: entry.client, source: entry.source, serverName: entry.name, tool, checks, ...(problem ? { problem } : {}), entry };
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/doctor/checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,aAAa,EAAsD,MAAM,mBAAmB,CAAC;AAEtG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAC;AAGjF,gGAAgG;AAChG,M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AAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;IAC/G,MAAM,OAAO,GAA8B,MAAM,CAAC,kBAAkB,CAAC;QACnE,CAAC,CAAC,cAAc;QAChB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;YACrB,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAChB,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;AACtI,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const DOCTOR_CLIENTS: readonly ["claude-code", "claude-desktop", "codex", "cursor"];
|
|
2
|
+
export type DoctorClient = (typeof DOCTOR_CLIENTS)[number];
|
|
3
|
+
export declare const CLIENT_LABELS: Record<DoctorClient, string>;
|
|
4
|
+
/** What the doctor needs from the computer, so a test can run it on fixture folders. */
|
|
5
|
+
export interface DoctorFs {
|
|
6
|
+
platform: NodeJS.Platform;
|
|
7
|
+
home: string;
|
|
8
|
+
cwd: string;
|
|
9
|
+
/** The folder of Windows application data; empty elsewhere. */
|
|
10
|
+
appData: string;
|
|
11
|
+
/** The folder of Linux user config; empty elsewhere. */
|
|
12
|
+
xdgConfig: string;
|
|
13
|
+
/** The text of a file, or undefined when it is not there or cannot be read. */
|
|
14
|
+
readText(path: string): string | undefined;
|
|
15
|
+
/** Whether a path is a file that the person may run. */
|
|
16
|
+
isExecutable(path: string): boolean;
|
|
17
|
+
}
|
|
18
|
+
/** One MCP server entry of a client config. The values of env are kept only inside the doctor. */
|
|
19
|
+
export interface ServerEntry {
|
|
20
|
+
client: DoctorClient;
|
|
21
|
+
/** Which file it came from, as a short name for the output. */
|
|
22
|
+
source: string;
|
|
23
|
+
/** The name the entry has in the config. */
|
|
24
|
+
name: string;
|
|
25
|
+
command?: string;
|
|
26
|
+
args: string[];
|
|
27
|
+
env: Record<string, string>;
|
|
28
|
+
/** A remote server is reached by address, so it has no command to start. */
|
|
29
|
+
url?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ConfigFile {
|
|
32
|
+
client: DoctorClient;
|
|
33
|
+
/** A short name such as "Claude Desktop config", never a path. */
|
|
34
|
+
source: string;
|
|
35
|
+
path: string;
|
|
36
|
+
}
|
|
37
|
+
/** The config files each client may have, in reading order. */
|
|
38
|
+
export declare function configFilesFor(client: DoctorClient, fs: DoctorFs): ConfigFile[];
|
|
39
|
+
/** The server entries of one config file's text. A file that does not parse gives none. */
|
|
40
|
+
export declare function parseServerEntries(file: ConfigFile, text: string, fs: DoctorFs): ServerEntry[];
|
|
41
|
+
export interface ClientScan {
|
|
42
|
+
client: DoctorClient;
|
|
43
|
+
/** Files that exist, by short name. */
|
|
44
|
+
filesRead: string[];
|
|
45
|
+
/** Files that exist but could not be read as a config. */
|
|
46
|
+
unreadable: string[];
|
|
47
|
+
entries: ServerEntry[];
|
|
48
|
+
}
|
|
49
|
+
export declare function scanClient(client: DoctorClient, fs: DoctorFs): ClientScan;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { parseToml } from "./toml.js";
|
|
3
|
+
export const DOCTOR_CLIENTS = ["claude-code", "claude-desktop", "codex", "cursor"];
|
|
4
|
+
export const CLIENT_LABELS = {
|
|
5
|
+
"claude-code": "Claude Code",
|
|
6
|
+
"claude-desktop": "Claude Desktop",
|
|
7
|
+
codex: "Codex",
|
|
8
|
+
cursor: "Cursor",
|
|
9
|
+
};
|
|
10
|
+
/** The config files each client may have, in reading order. */
|
|
11
|
+
export function configFilesFor(client, fs) {
|
|
12
|
+
switch (client) {
|
|
13
|
+
case "claude-code":
|
|
14
|
+
return [
|
|
15
|
+
{ client, source: "~/.claude.json", path: join(fs.home, ".claude.json") },
|
|
16
|
+
{ client, source: ".mcp.json of the current folder", path: join(fs.cwd, ".mcp.json") },
|
|
17
|
+
];
|
|
18
|
+
case "claude-desktop": {
|
|
19
|
+
const file = "claude_desktop_config.json";
|
|
20
|
+
const path = fs.platform === "darwin"
|
|
21
|
+
? join(fs.home, "Library", "Application Support", "Claude", file)
|
|
22
|
+
: fs.platform === "win32"
|
|
23
|
+
? join(fs.appData || join(fs.home, "AppData", "Roaming"), "Claude", file)
|
|
24
|
+
: join(fs.xdgConfig || join(fs.home, ".config"), "Claude", file);
|
|
25
|
+
return [{ client, source: "Claude Desktop config", path }];
|
|
26
|
+
}
|
|
27
|
+
case "codex":
|
|
28
|
+
return [{ client, source: "~/.codex/config.toml", path: join(fs.home, ".codex", "config.toml") }];
|
|
29
|
+
case "cursor":
|
|
30
|
+
return [{ client, source: "~/.cursor/mcp.json", path: join(fs.home, ".cursor", "mcp.json") }];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function isRecord(value) {
|
|
34
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35
|
+
}
|
|
36
|
+
function entryFrom(client, source, name, raw) {
|
|
37
|
+
if (!isRecord(raw))
|
|
38
|
+
return undefined;
|
|
39
|
+
const env = {};
|
|
40
|
+
if (isRecord(raw.env)) {
|
|
41
|
+
for (const [key, value] of Object.entries(raw.env)) {
|
|
42
|
+
if (typeof value === "string" || typeof value === "number")
|
|
43
|
+
env[key] = String(value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const command = typeof raw.command === "string" && raw.command.trim() ? raw.command.trim() : undefined;
|
|
47
|
+
const url = typeof raw.url === "string" ? raw.url : typeof raw.serverUrl === "string" ? raw.serverUrl : undefined;
|
|
48
|
+
if (!command && !url)
|
|
49
|
+
return undefined;
|
|
50
|
+
return {
|
|
51
|
+
client,
|
|
52
|
+
source,
|
|
53
|
+
name,
|
|
54
|
+
...(command ? { command } : {}),
|
|
55
|
+
args: Array.isArray(raw.args) ? raw.args.filter((a) => typeof a === "string") : [],
|
|
56
|
+
env,
|
|
57
|
+
...(url ? { url } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function fromServerMap(client, source, map) {
|
|
61
|
+
if (!isRecord(map))
|
|
62
|
+
return [];
|
|
63
|
+
const out = [];
|
|
64
|
+
for (const [name, raw] of Object.entries(map)) {
|
|
65
|
+
const entry = entryFrom(client, source, name, raw);
|
|
66
|
+
if (entry)
|
|
67
|
+
out.push(entry);
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/** The server entries of one config file's text. A file that does not parse gives none. */
|
|
72
|
+
export function parseServerEntries(file, text, fs) {
|
|
73
|
+
try {
|
|
74
|
+
if (file.client === "codex") {
|
|
75
|
+
const root = parseToml(text);
|
|
76
|
+
return fromServerMap("codex", file.source, root.mcp_servers);
|
|
77
|
+
}
|
|
78
|
+
const json = JSON.parse(text);
|
|
79
|
+
if (!isRecord(json))
|
|
80
|
+
return [];
|
|
81
|
+
const entries = fromServerMap(file.client, file.source, json.mcpServers);
|
|
82
|
+
if (file.client === "claude-code" && isRecord(json.projects)) {
|
|
83
|
+
// The local scope of Claude Code keeps servers under the project folder.
|
|
84
|
+
const project = json.projects[fs.cwd];
|
|
85
|
+
if (isRecord(project)) {
|
|
86
|
+
entries.push(...fromServerMap("claude-code", "~/.claude.json (this project)", project.mcpServers));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return entries;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function scanClient(client, fs) {
|
|
96
|
+
const scan = { client, filesRead: [], unreadable: [], entries: [] };
|
|
97
|
+
for (const file of configFilesFor(client, fs)) {
|
|
98
|
+
const text = fs.readText(file.path);
|
|
99
|
+
if (text === undefined)
|
|
100
|
+
continue;
|
|
101
|
+
const entries = parseServerEntries(file, text, fs);
|
|
102
|
+
const parsed = (() => {
|
|
103
|
+
try {
|
|
104
|
+
if (client === "codex")
|
|
105
|
+
return true;
|
|
106
|
+
JSON.parse(text);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
})();
|
|
113
|
+
if (parsed)
|
|
114
|
+
scan.filesRead.push(file.source);
|
|
115
|
+
else
|
|
116
|
+
scan.unreadable.push(file.source);
|
|
117
|
+
scan.entries.push(...entries);
|
|
118
|
+
}
|
|
119
|
+
return scan;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=config-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-files.js","sourceRoot":"","sources":["../../src/doctor/config-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAC;AAEtD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAG5F,MAAM,CAAC,MAAM,aAAa,GAAiC;IACzD,aAAa,EAAE,aAAa;IAC5B,gBAAgB,EAAE,gBAAgB;IAClC,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACjB,CAAC;AAsCF,+DAA+D;AAC/D,MAAM,UAAU,cAAc,CAAC,MAAoB,EAAE,EAAY;IAC/D,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,aAAa;YAChB,OAAO;gBACL,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE;gBACzE,EAAE,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AAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,IAAI,MAAM;YAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;YACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type DoctorFs, type ServerEntry } from "./config-files.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether one Kubernetes server entry runs read-only: the `read_only` setting
|
|
4
|
+
* of its `--config` TOML file, or a `--read-only` flag. `true` when it does,
|
|
5
|
+
* `false` when the entry clearly does not, `undefined` when it cannot be
|
|
6
|
+
* known (a config file that cannot be read, or an entry that is a remote
|
|
7
|
+
* address). Only this one fact is read; no path, value or file text leaves.
|
|
8
|
+
*/
|
|
9
|
+
export declare function kubernetesEntryReadOnly(entry: ServerEntry, fs: DoctorFs): boolean | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The read-only flag of the Kubernetes server of a client, read from its
|
|
12
|
+
* config files. With several Kubernetes servers it is true only when every
|
|
13
|
+
* one is read-only. `undefined` when the client has no Kubernetes server in a
|
|
14
|
+
* file the doctor reads, or the answer cannot be known.
|
|
15
|
+
*/
|
|
16
|
+
export declare function kubernetesReadOnlyOfClient(client: string | undefined, fs: DoctorFs): boolean | undefined;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { isAbsolute, join } from "node:path";
|
|
2
|
+
import { toolOfEntry } from "./checks.js";
|
|
3
|
+
import { DOCTOR_CLIENTS, scanClient } from "./config-files.js";
|
|
4
|
+
import { parseToml } from "./toml.js";
|
|
5
|
+
/** Replaces a leading `~` and the `$HOME` forms that a config line may use. */
|
|
6
|
+
function expandHome(path, fs) {
|
|
7
|
+
return path
|
|
8
|
+
.replace(/^~(?=$|[\\/])/, fs.home)
|
|
9
|
+
.replace(/^\$\{?HOME\}?(?=$|[\\/])/, fs.home)
|
|
10
|
+
.replace(/^%USERPROFILE%(?=$|[\\/])/i, fs.home);
|
|
11
|
+
}
|
|
12
|
+
function flagValue(args, name) {
|
|
13
|
+
for (let i = 0; i < args.length; i++) {
|
|
14
|
+
const arg = args[i];
|
|
15
|
+
if (arg === name) {
|
|
16
|
+
const next = args[i + 1];
|
|
17
|
+
return next !== undefined && !next.startsWith("-") ? next : true;
|
|
18
|
+
}
|
|
19
|
+
if (arg.startsWith(`${name}=`))
|
|
20
|
+
return arg.slice(name.length + 1);
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function truthy(value) {
|
|
25
|
+
if (value === true)
|
|
26
|
+
return true;
|
|
27
|
+
const v = value.trim().toLowerCase();
|
|
28
|
+
if (v === "true" || v === "1" || v === "yes")
|
|
29
|
+
return true;
|
|
30
|
+
if (v === "false" || v === "0" || v === "no")
|
|
31
|
+
return false;
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether one Kubernetes server entry runs read-only: the `read_only` setting
|
|
36
|
+
* of its `--config` TOML file, or a `--read-only` flag. `true` when it does,
|
|
37
|
+
* `false` when the entry clearly does not, `undefined` when it cannot be
|
|
38
|
+
* known (a config file that cannot be read, or an entry that is a remote
|
|
39
|
+
* address). Only this one fact is read; no path, value or file text leaves.
|
|
40
|
+
*/
|
|
41
|
+
export function kubernetesEntryReadOnly(entry, fs) {
|
|
42
|
+
if (entry.url && !entry.command)
|
|
43
|
+
return undefined;
|
|
44
|
+
const flag = flagValue(entry.args, "--read-only");
|
|
45
|
+
if (flag !== undefined)
|
|
46
|
+
return truthy(flag);
|
|
47
|
+
const config = flagValue(entry.args, "--config");
|
|
48
|
+
if (typeof config === "string") {
|
|
49
|
+
const expanded = expandHome(config, fs);
|
|
50
|
+
const path = isAbsolute(expanded) ? expanded : join(fs.cwd, expanded);
|
|
51
|
+
const text = fs.readText(path);
|
|
52
|
+
if (text === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
try {
|
|
55
|
+
const root = parseToml(text);
|
|
56
|
+
const value = root.read_only;
|
|
57
|
+
return value === true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The read-only flag of the Kubernetes server of a client, read from its
|
|
67
|
+
* config files. With several Kubernetes servers it is true only when every
|
|
68
|
+
* one is read-only. `undefined` when the client has no Kubernetes server in a
|
|
69
|
+
* file the doctor reads, or the answer cannot be known.
|
|
70
|
+
*/
|
|
71
|
+
export function kubernetesReadOnlyOfClient(client, fs) {
|
|
72
|
+
const clients = DOCTOR_CLIENTS.includes(client ?? "")
|
|
73
|
+
? [client]
|
|
74
|
+
: DOCTOR_CLIENTS;
|
|
75
|
+
const answers = [];
|
|
76
|
+
for (const name of clients) {
|
|
77
|
+
for (const entry of scanClient(name, fs).entries) {
|
|
78
|
+
if (toolOfEntry(entry) !== "kubernetes")
|
|
79
|
+
continue;
|
|
80
|
+
const answer = kubernetesEntryReadOnly(entry, fs);
|
|
81
|
+
if (answer !== undefined)
|
|
82
|
+
answers.push(answer);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (answers.length === 0)
|
|
86
|
+
return undefined;
|
|
87
|
+
return answers.every(Boolean);
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=k8s-read-only.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"k8s-read-only.js","sourceRoot":"","sources":["../../src/doctor/k8s-read-only.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO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AAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAA0B,EAAE,EAAY;IACjF,MAAM,OAAO,GAA6B,cAAoC,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;QACnG,CAAC,CAAC,CAAC,MAAsB,CAAC;QAC1B,CAAC,CAAC,cAAc,CAAC;IACnB,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;YACjD,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,YAAY;gBAAE,SAAS;YAClD,MAAM,MAAM,GAAG,uBAAuB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAClD,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { accessSync, constants, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
const MAX_CONFIG_BYTES = 4 << 20;
|
|
4
|
+
/** The computer this process runs on. */
|
|
5
|
+
export function realDoctorFs() {
|
|
6
|
+
return {
|
|
7
|
+
platform: process.platform,
|
|
8
|
+
home: homedir(),
|
|
9
|
+
cwd: process.cwd(),
|
|
10
|
+
appData: process.env.APPDATA ?? "",
|
|
11
|
+
xdgConfig: process.env.XDG_CONFIG_HOME ?? "",
|
|
12
|
+
readText(path) {
|
|
13
|
+
try {
|
|
14
|
+
if (statSync(path).size > MAX_CONFIG_BYTES)
|
|
15
|
+
return undefined;
|
|
16
|
+
return readFileSync(path, "utf8");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
isExecutable(path) {
|
|
23
|
+
try {
|
|
24
|
+
if (!statSync(path).isFile())
|
|
25
|
+
return false;
|
|
26
|
+
if (process.platform !== "win32")
|
|
27
|
+
accessSync(path, constants.X_OK);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=real-fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-fs.js","sourceRoot":"","sources":["../../src/doctor/real-fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,CAAC;AAEjC,yCAAyC;AACzC,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,IAAI,EAAE,OAAO,EAAE;QACf,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE;QAClC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE;QAC5C,QAAQ,CAAC,IAAI;YACX,IAAI,CAAC;gBACH,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,gBAAgB;oBAAE,OAAO,SAAS,CAAC;gBAC7D,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,YAAY,CAAC,IAAI;YACf,IAAI,CAAC;gBACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;oBAAE,OAAO,KAAK,CAAC;gBAC3C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;oBAAE,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBACnE,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reader for the small part of TOML that a Codex config uses: tables
|
|
3
|
+
* (`[a.b]`, `[a."b.c"]`), strings, numbers, booleans, arrays (also over
|
|
4
|
+
* several lines) and inline tables. It is not a full TOML parser. A line it
|
|
5
|
+
* cannot read is skipped, so one odd entry never hides the rest.
|
|
6
|
+
*/
|
|
7
|
+
export type TomlValue = string | number | boolean | TomlValue[] | {
|
|
8
|
+
[key: string]: TomlValue;
|
|
9
|
+
};
|
|
10
|
+
export type TomlTable = {
|
|
11
|
+
[key: string]: TomlValue;
|
|
12
|
+
};
|
|
13
|
+
export declare function parseToml(text: string): TomlTable;
|