@omnidim-ai/mcp-server 0.2.9 → 0.4.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 +21 -3
- package/build/banner.d.ts +2 -0
- package/build/banner.js +45 -0
- package/build/banner.js.map +1 -0
- package/build/clients.d.ts +18 -0
- package/build/clients.js +203 -0
- package/build/clients.js.map +1 -0
- package/build/doctor.d.ts +1 -0
- package/build/doctor.js +71 -0
- package/build/doctor.js.map +1 -0
- package/build/helpers.d.ts +1 -0
- package/build/helpers.js +36 -0
- package/build/helpers.js.map +1 -1
- package/build/index.js +36 -2
- package/build/index.js.map +1 -1
- package/build/logger.d.ts +8 -0
- package/build/logger.js +50 -0
- package/build/logger.js.map +1 -0
- package/build/setup.d.ts +4 -0
- package/build/setup.js +47 -74
- package/build/setup.js.map +1 -1
- package/build/telemetry.d.ts +28 -7
- package/build/telemetry.js +100 -9
- package/build/telemetry.js.map +1 -1
- package/package.json +1 -1
- package/src/banner.ts +48 -0
- package/src/clients.ts +246 -0
- package/src/doctor.ts +75 -0
- package/src/helpers.ts +39 -0
- package/src/index.ts +32 -9
- package/src/logger.ts +57 -0
- package/src/setup.ts +62 -92
- package/src/telemetry.ts +144 -11
package/build/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkC,MAAM,wBAAwB,CAAC;AAEzF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,wBAAw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C,KAAK,CAAC,UAAU,SAAS,CAAC,eAAe,EAAE,CAAC,MAAM,CAAC,CAAC;QACnE,OAAO,CAAC,CAAC;IACb,CAAC;YAAS,CAAC;QACP,EAAE,EAAE,KAAK,EAAE,CAAC;IAChB,CAAC;AACL,CAAC"}
|
package/build/telemetry.d.ts
CHANGED
|
@@ -4,17 +4,38 @@ export declare function telemetryStatus(): {
|
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
reason: string;
|
|
6
6
|
};
|
|
7
|
+
export interface SanitizedError {
|
|
8
|
+
error_class: string;
|
|
9
|
+
error_code: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function sanitizeError(error: unknown): SanitizedError;
|
|
7
12
|
export declare function emitInstall(): Promise<void>;
|
|
8
13
|
export declare function emitSessionStart(): Promise<void>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
export type SetupKeyOutcome = "reused" | "entered" | "rejected_401" | "network_error" | "server_error" | "aborted";
|
|
15
|
+
export declare function emitSetupStarted(): Promise<void>;
|
|
16
|
+
export declare function emitSetupKeyResult(outcome: SetupKeyOutcome): Promise<void>;
|
|
17
|
+
export declare function emitSetupClientResult(client: string, outcome: "installed" | "failed", error?: SanitizedError & {
|
|
18
|
+
exit_code?: number;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
export declare function emitSetupFinished(clientsInstalled: number, clientsFailed: number): Promise<void>;
|
|
21
|
+
interface ToolUsage {
|
|
22
|
+
tool: string;
|
|
23
|
+
count: number;
|
|
24
|
+
ok: number;
|
|
25
|
+
errors: Array<{
|
|
26
|
+
code: string;
|
|
13
27
|
count: number;
|
|
14
28
|
}>;
|
|
15
29
|
}
|
|
16
|
-
export
|
|
17
|
-
|
|
30
|
+
export interface SessionSummary {
|
|
31
|
+
duration_s: number;
|
|
32
|
+
tools_called: ToolUsage[];
|
|
33
|
+
tool_errors_total: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function recordToolResult(name: string, outcome: string): void;
|
|
36
|
+
export declare function recordToolError(name: string, error: unknown): void;
|
|
18
37
|
export declare function beginSession(): void;
|
|
19
|
-
export declare function endSession():
|
|
38
|
+
export declare function endSession(): SessionSummary;
|
|
39
|
+
export declare function emitSessionEnd(payload: SessionSummary): Promise<void>;
|
|
40
|
+
export declare function emitSessionCrash(error: unknown): Promise<void>;
|
|
20
41
|
export {};
|
package/build/telemetry.js
CHANGED
|
@@ -2,6 +2,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { classifyToolError } from "./helpers.js";
|
|
6
|
+
import { appendLog } from "./logger.js";
|
|
5
7
|
const ENDPOINT = "https://mcp.omnidim.io/api/telemetry/event";
|
|
6
8
|
const CONFIG_DIR = join(homedir(), ".config", "omnidim");
|
|
7
9
|
const INSTALL_ID_PATH = join(CONFIG_DIR, "install-id");
|
|
@@ -95,29 +97,118 @@ async function send(event, extra = {}) {
|
|
|
95
97
|
clearTimeout(timer);
|
|
96
98
|
}
|
|
97
99
|
}
|
|
100
|
+
// Reduce any thrown value to two low-cardinality, non-identifying fields.
|
|
101
|
+
// Never returns a message, stack, path, or payload, since those can carry
|
|
102
|
+
// usernames and file paths. Node's documented errno strings (ENOENT,
|
|
103
|
+
// EACCES, ...) and the error constructor name are safe to keep.
|
|
104
|
+
export function sanitizeError(error) {
|
|
105
|
+
if (error && typeof error === "object") {
|
|
106
|
+
const e = error;
|
|
107
|
+
const rawName = typeof e.name === "string" && e.name ? e.name : e.constructor?.name ?? "Error";
|
|
108
|
+
const error_class = /^[A-Za-z][A-Za-z0-9]{0,39}$/.test(rawName) ? rawName : "Error";
|
|
109
|
+
const error_code = typeof e.code === "string" && /^[A-Z][A-Z0-9_]{1,31}$/.test(e.code) ? e.code : "unknown";
|
|
110
|
+
return { error_class, error_code };
|
|
111
|
+
}
|
|
112
|
+
return { error_class: "Error", error_code: "unknown" };
|
|
113
|
+
}
|
|
98
114
|
export async function emitInstall() {
|
|
99
115
|
await send("install");
|
|
100
116
|
}
|
|
101
117
|
export async function emitSessionStart() {
|
|
102
118
|
await send("session_start");
|
|
103
119
|
}
|
|
104
|
-
export async function
|
|
105
|
-
await send("
|
|
120
|
+
export async function emitSetupStarted() {
|
|
121
|
+
await send("setup_started");
|
|
122
|
+
}
|
|
123
|
+
export async function emitSetupKeyResult(outcome) {
|
|
124
|
+
await send("setup_key_result", { outcome });
|
|
125
|
+
}
|
|
126
|
+
export async function emitSetupClientResult(client, outcome, error) {
|
|
127
|
+
await send("setup_client_result", { client, outcome, ...(error ?? {}) });
|
|
106
128
|
}
|
|
107
|
-
|
|
129
|
+
export async function emitSetupFinished(clientsInstalled, clientsFailed) {
|
|
130
|
+
await send("setup_finished", {
|
|
131
|
+
clients_installed: clientsInstalled,
|
|
132
|
+
clients_failed: clientsFailed,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const toolStats = new Map();
|
|
108
136
|
let sessionStartMs = null;
|
|
109
|
-
|
|
110
|
-
|
|
137
|
+
// Guards against one session reporting twice (a crash racing graceful
|
|
138
|
+
// shutdown), which would otherwise log an empty ghost event.
|
|
139
|
+
let terminated = false;
|
|
140
|
+
// outcome is "ok" for a successful call, otherwise a category code
|
|
141
|
+
// ("http_401", "network", "timeout", "validation", "upstream_html",
|
|
142
|
+
// "no_api_key", "unknown"). Never a tool's input or output.
|
|
143
|
+
export function recordToolResult(name, outcome) {
|
|
144
|
+
let stat = toolStats.get(name);
|
|
145
|
+
if (!stat) {
|
|
146
|
+
stat = { count: 0, ok: 0, errors: new Map() };
|
|
147
|
+
toolStats.set(name, stat);
|
|
148
|
+
}
|
|
149
|
+
stat.count += 1;
|
|
150
|
+
if (outcome === "ok") {
|
|
151
|
+
stat.ok += 1;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
stat.errors.set(outcome, (stat.errors.get(outcome) ?? 0) + 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Catch-path helper: classify the error, count it in the session summary,
|
|
158
|
+
// and append the real (local-only) message to the diagnostics log.
|
|
159
|
+
export function recordToolError(name, error) {
|
|
160
|
+
const code = classifyToolError(error);
|
|
161
|
+
recordToolResult(name, code);
|
|
162
|
+
appendLog({
|
|
163
|
+
kind: "tool_error",
|
|
164
|
+
tool: name,
|
|
165
|
+
code,
|
|
166
|
+
message: error instanceof Error ? error.message : String(error),
|
|
167
|
+
});
|
|
111
168
|
}
|
|
112
169
|
export function beginSession() {
|
|
113
170
|
sessionStartMs = Date.now();
|
|
171
|
+
terminated = false;
|
|
114
172
|
void emitSessionStart();
|
|
115
173
|
}
|
|
116
|
-
|
|
174
|
+
function drainSession() {
|
|
117
175
|
const duration_s = sessionStartMs ? Math.round((Date.now() - sessionStartMs) / 1000) : 0;
|
|
118
|
-
|
|
176
|
+
let tool_errors_total = 0;
|
|
177
|
+
const tools_called = Array.from(toolStats.entries()).map(([tool, stat]) => {
|
|
178
|
+
const errors = Array.from(stat.errors.entries()).map(([code, count]) => {
|
|
179
|
+
tool_errors_total += count;
|
|
180
|
+
return { code, count };
|
|
181
|
+
});
|
|
182
|
+
return { tool, count: stat.count, ok: stat.ok, errors };
|
|
183
|
+
});
|
|
119
184
|
sessionStartMs = null;
|
|
120
|
-
|
|
121
|
-
return { duration_s, tools_called };
|
|
185
|
+
toolStats.clear();
|
|
186
|
+
return { duration_s, tools_called, tool_errors_total };
|
|
187
|
+
}
|
|
188
|
+
export function endSession() {
|
|
189
|
+
return drainSession();
|
|
190
|
+
}
|
|
191
|
+
export async function emitSessionEnd(payload) {
|
|
192
|
+
if (terminated)
|
|
193
|
+
return;
|
|
194
|
+
terminated = true;
|
|
195
|
+
await send("session_end", { ...payload });
|
|
196
|
+
}
|
|
197
|
+
// Fires on a crash so the session still terminates with a record carrying
|
|
198
|
+
// its tool-call summary; a clean session_end never runs on a crash path.
|
|
199
|
+
export async function emitSessionCrash(error) {
|
|
200
|
+
if (terminated)
|
|
201
|
+
return;
|
|
202
|
+
terminated = true;
|
|
203
|
+
const active = sessionStartMs !== null;
|
|
204
|
+
const summary = drainSession();
|
|
205
|
+
const phase = active ? "runtime" : "startup";
|
|
206
|
+
appendLog({
|
|
207
|
+
kind: "crash",
|
|
208
|
+
phase,
|
|
209
|
+
...sanitizeError(error),
|
|
210
|
+
message: error instanceof Error ? error.message : String(error),
|
|
211
|
+
});
|
|
212
|
+
await send("session_crash", { phase, ...sanitizeError(error), ...summary });
|
|
122
213
|
}
|
|
123
214
|
//# sourceMappingURL=telemetry.js.map
|
package/build/telemetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,QAAQ,GAAG,4CAA4C,CAAC;AAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACzD,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,CAAC;AAC3E,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAC9C,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,UAAU,mBAAmB;IAC/B,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CA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AG,OAAO,EAAE,CAAC,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnidim-ai/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Official MCP server for OmniDimension. Drive voice agents, dispatch calls, and manage knowledge bases from Claude, Cursor, Windsurf, and any MCP client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
package/src/banner.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Branded "OMNIDIMENSION" wordmark shown at the top of `setup`. The ANSI
|
|
2
|
+
// Shadow art is baked in (generated once with figlet) so the package ships
|
|
3
|
+
// no figlet dependency. OMNI uses the brand cyan, DIMENSION the light slate.
|
|
4
|
+
const OMNI_ROWS = [
|
|
5
|
+
" ██████╗ ███╗ ███╗███╗ ██╗██╗",
|
|
6
|
+
"██╔═══██╗████╗ ████║████╗ ██║██║",
|
|
7
|
+
"██║ ██║██╔████╔██║██╔██╗ ██║██║",
|
|
8
|
+
"██║ ██║██║╚██╔╝██║██║╚██╗██║██║",
|
|
9
|
+
"╚██████╔╝██║ ╚═╝ ██║██║ ╚████║██║",
|
|
10
|
+
" ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝",
|
|
11
|
+
];
|
|
12
|
+
const DIM_ROWS = [
|
|
13
|
+
"██████╗ ██╗███╗ ███╗███████╗███╗ ██╗███████╗██╗ ██████╗ ███╗ ██╗",
|
|
14
|
+
"██╔══██╗██║████╗ ████║██╔════╝████╗ ██║██╔════╝██║██╔═══██╗████╗ ██║",
|
|
15
|
+
"██║ ██║██║██╔████╔██║█████╗ ██╔██╗ ██║███████╗██║██║ ██║██╔██╗ ██║",
|
|
16
|
+
"██║ ██║██║██║╚██╔╝██║██╔══╝ ██║╚██╗██║╚════██║██║██║ ██║██║╚██╗██║",
|
|
17
|
+
"██████╔╝██║██║ ╚═╝ ██║███████╗██║ ╚████║███████║██║╚██████╔╝██║ ╚████║",
|
|
18
|
+
"╚═════╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export const WORDMARK_WIDTH = OMNI_ROWS[0].length + DIM_ROWS[0].length;
|
|
22
|
+
|
|
23
|
+
const OMNI_RGB: [number, number, number] = [19, 180, 174]; // #13B4AE
|
|
24
|
+
const DIM_RGB: [number, number, number] = [192, 210, 216]; // #C0D2D8
|
|
25
|
+
const OMNI_256 = 37;
|
|
26
|
+
const DIM_256 = 152;
|
|
27
|
+
|
|
28
|
+
function supportsTrueColor(): boolean {
|
|
29
|
+
const ct = (process.env.COLORTERM || "").toLowerCase();
|
|
30
|
+
return ct.includes("truecolor") || ct.includes("24bit");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// One colorizer for a block of rows, picking 24-bit or 256-color up front.
|
|
34
|
+
function painter(rgb: [number, number, number], code256: number): (s: string) => string {
|
|
35
|
+
const open = supportsTrueColor()
|
|
36
|
+
? `\x1b[38;2;${rgb[0]};${rgb[1]};${rgb[2]}m`
|
|
37
|
+
: `\x1b[38;5;${code256}m`;
|
|
38
|
+
return (s) => `${open}${s}\x1b[0m`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The colored multi-line wordmark, or null when the terminal is too narrow
|
|
42
|
+
// to render it without wrapping (the caller falls back to the compact line).
|
|
43
|
+
export function renderWordmark(columns: number | undefined): string | null {
|
|
44
|
+
if (!columns || columns < WORDMARK_WIDTH + 2) return null;
|
|
45
|
+
const omni = painter(OMNI_RGB, OMNI_256);
|
|
46
|
+
const dimn = painter(DIM_RGB, DIM_256);
|
|
47
|
+
return OMNI_ROWS.map((row, i) => ` ${omni(row)}${dimn(DIM_ROWS[i])}`).join("\n");
|
|
48
|
+
}
|
package/src/clients.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
|
|
6
|
+
import { sanitizeError, type SanitizedError } from "./telemetry.js";
|
|
7
|
+
|
|
8
|
+
const PKG = "@omnidim-ai/mcp-server";
|
|
9
|
+
const NPX_ARGS = ["-y", PKG];
|
|
10
|
+
|
|
11
|
+
// The host paths targets are resolved against. Injected (rather than read
|
|
12
|
+
// from the process at import time) so tests can simulate any OS and a clean
|
|
13
|
+
// machine without touching the real one.
|
|
14
|
+
export interface HostEnv {
|
|
15
|
+
platform: NodeJS.Platform;
|
|
16
|
+
home: string;
|
|
17
|
+
appData: string; // Windows %APPDATA%
|
|
18
|
+
xdgConfig: string; // Linux ~/.config
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function currentHostEnv(): HostEnv {
|
|
22
|
+
const home = homedir();
|
|
23
|
+
return {
|
|
24
|
+
platform: process.platform,
|
|
25
|
+
home,
|
|
26
|
+
appData: process.env.APPDATA || join(home, "AppData", "Roaming"),
|
|
27
|
+
xdgConfig: process.env.XDG_CONFIG_HOME || join(home, ".config"),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ClientTarget {
|
|
32
|
+
name: string;
|
|
33
|
+
id: string;
|
|
34
|
+
// App is considered installed when this returns true. Keyed off the
|
|
35
|
+
// app's own directory/binary, not its MCP config file: a fresh install
|
|
36
|
+
// has the app but no config file yet, and we create the file ourselves.
|
|
37
|
+
detect: () => boolean;
|
|
38
|
+
install: (apiKey: string) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Carries a sanitized failure category so the setup funnel can report why a
|
|
42
|
+
// client install failed without shipping the raw message (which holds paths).
|
|
43
|
+
class ClientInstallError extends Error {
|
|
44
|
+
readonly errorCode: string;
|
|
45
|
+
readonly errorClass: string;
|
|
46
|
+
readonly exitCode?: number;
|
|
47
|
+
constructor(message: string, errorCode: string, errorClass: string, exitCode?: number) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = "ClientInstallError";
|
|
50
|
+
this.errorCode = errorCode;
|
|
51
|
+
this.errorClass = errorClass;
|
|
52
|
+
this.exitCode = exitCode;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Reduce a caught install error to the sanitized fields the funnel reports.
|
|
57
|
+
export function describeInstallError(e: unknown): SanitizedError & { exit_code?: number } {
|
|
58
|
+
if (e instanceof ClientInstallError) {
|
|
59
|
+
return { error_class: e.errorClass, error_code: e.errorCode, exit_code: e.exitCode };
|
|
60
|
+
}
|
|
61
|
+
return sanitizeError(e);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Most clients read `mcpServers`; VS Code reads `servers` and wants an
|
|
65
|
+
// explicit transport `type`. Both take the same npx command shape.
|
|
66
|
+
function mcpServersEntry(apiKey: string): Record<string, unknown> {
|
|
67
|
+
return { command: "npx", args: NPX_ARGS, env: { OMNIDIM_API_KEY: apiKey } };
|
|
68
|
+
}
|
|
69
|
+
function vscodeEntry(apiKey: string): Record<string, unknown> {
|
|
70
|
+
return { type: "stdio", command: "npx", args: NPX_ARGS, env: { OMNIDIM_API_KEY: apiKey } };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Filesystem errno -> a specific, PII-free error category. Lets telemetry say
|
|
74
|
+
// "permission denied" vs "disk full" vs "read-only" instead of one vague code.
|
|
75
|
+
const FS_ERROR_CODES: Record<string, string> = {
|
|
76
|
+
EACCES: "config_permission_denied",
|
|
77
|
+
EPERM: "config_permission_denied",
|
|
78
|
+
EROFS: "config_readonly_fs",
|
|
79
|
+
ENOSPC: "config_no_space",
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function fsError(e: unknown, fallback: string): ClientInstallError {
|
|
83
|
+
const code = (e as { code?: string }).code;
|
|
84
|
+
const errorCode = (typeof code === "string" && FS_ERROR_CODES[code]) || fallback;
|
|
85
|
+
return new ClientInstallError(
|
|
86
|
+
e instanceof Error ? e.message : String(e),
|
|
87
|
+
errorCode,
|
|
88
|
+
e instanceof Error ? e.name : "Error",
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Read a client's existing config. A missing OR empty/whitespace-only file is
|
|
93
|
+
// treated as a fresh `{}` rather than an error: a created-but-unwritten config
|
|
94
|
+
// file is a common state (the cause of "Unexpected end of JSON input"). A file
|
|
95
|
+
// holding valid JSON that isn't an object is also reset, since we can't merge
|
|
96
|
+
// a server map into it. Only genuinely malformed JSON is a hard failure.
|
|
97
|
+
function readConfig(configPath: string): Record<string, unknown> {
|
|
98
|
+
if (!existsSync(configPath)) return {};
|
|
99
|
+
let raw: string;
|
|
100
|
+
try {
|
|
101
|
+
raw = readFileSync(configPath, "utf8");
|
|
102
|
+
} catch (e) {
|
|
103
|
+
throw fsError(e, "config_read_error");
|
|
104
|
+
}
|
|
105
|
+
if (!raw.trim()) return {};
|
|
106
|
+
try {
|
|
107
|
+
const parsed = JSON.parse(raw) as unknown;
|
|
108
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
|
109
|
+
? (parsed as Record<string, unknown>)
|
|
110
|
+
: {};
|
|
111
|
+
} catch (e) {
|
|
112
|
+
throw new ClientInstallError(
|
|
113
|
+
e instanceof Error ? e.message : String(e),
|
|
114
|
+
"config_invalid_json",
|
|
115
|
+
e instanceof Error ? e.name : "Error",
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Merge our server entry into a JSON config under `topKey`, creating the file
|
|
121
|
+
// and parent directory if absent and preserving any other servers already
|
|
122
|
+
// there. Failures surface as a sanitized category for the setup funnel.
|
|
123
|
+
function upsertConfig(configPath: string, topKey: string, entry: Record<string, unknown>): void {
|
|
124
|
+
const config = readConfig(configPath);
|
|
125
|
+
const servers = ((config[topKey] as Record<string, unknown>) ?? {}) as Record<string, unknown>;
|
|
126
|
+
servers.omnidim = entry;
|
|
127
|
+
config[topKey] = servers;
|
|
128
|
+
try {
|
|
129
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
130
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
131
|
+
} catch (e) {
|
|
132
|
+
throw fsError(e, "config_write_error");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function installClaudeCode(apiKey: string): void {
|
|
137
|
+
try {
|
|
138
|
+
execFileSync("claude", ["mcp", "remove", "omnidim", "--scope", "user"], { stdio: "ignore" });
|
|
139
|
+
} catch {
|
|
140
|
+
// not registered, fine
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
// Name before the variadic -e so commander doesn't gobble it as an env value.
|
|
144
|
+
execFileSync(
|
|
145
|
+
"claude",
|
|
146
|
+
[
|
|
147
|
+
"mcp", "add", "omnidim",
|
|
148
|
+
"--scope", "user",
|
|
149
|
+
"-e", `OMNIDIM_API_KEY=${apiKey}`,
|
|
150
|
+
"--", "npx", "-y", PKG,
|
|
151
|
+
],
|
|
152
|
+
{ stdio: ["ignore", "pipe", "pipe"] },
|
|
153
|
+
);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
const err = e as { stderr?: Buffer; stdout?: Buffer; message: string; code?: string; status?: number };
|
|
156
|
+
const detail = (err.stderr ?? err.stdout ?? Buffer.from("")).toString().trim();
|
|
157
|
+
if (err.code === "ENOENT") {
|
|
158
|
+
throw new ClientInstallError("Claude Code CLI not found on PATH", "claude_cli_not_found", "Error");
|
|
159
|
+
}
|
|
160
|
+
const exitCode = typeof err.status === "number" ? err.status : undefined;
|
|
161
|
+
throw new ClientInstallError(detail || err.message, "claude_cli_error", "Error", exitCode);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Claude Code is present if it has written its config or the CLI resolves.
|
|
166
|
+
function hasClaudeCli(env: HostEnv): boolean {
|
|
167
|
+
if (existsSync(join(env.home, ".claude.json"))) return true;
|
|
168
|
+
try {
|
|
169
|
+
execFileSync("claude", ["--version"], { stdio: "ignore" });
|
|
170
|
+
return true;
|
|
171
|
+
} catch {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// macOS / Windows app-support dir for Claude Desktop (no official Linux build).
|
|
177
|
+
function claudeDesktopDir(env: HostEnv): string | null {
|
|
178
|
+
if (env.platform === "darwin") {
|
|
179
|
+
return join(env.home, "Library", "Application Support", "Claude");
|
|
180
|
+
}
|
|
181
|
+
if (env.platform === "win32") {
|
|
182
|
+
return join(env.appData, "Claude");
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function vscodeUserDir(env: HostEnv): string {
|
|
188
|
+
if (env.platform === "darwin") {
|
|
189
|
+
return join(env.home, "Library", "Application Support", "Code", "User");
|
|
190
|
+
}
|
|
191
|
+
if (env.platform === "win32") {
|
|
192
|
+
return join(env.appData, "Code", "User");
|
|
193
|
+
}
|
|
194
|
+
return join(env.xdgConfig, "Code", "User");
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Resolve the install targets for the given host. Paths differ per platform,
|
|
198
|
+
// so this is computed at call time rather than as a static table.
|
|
199
|
+
export function buildTargets(env: HostEnv = currentHostEnv()): ClientTarget[] {
|
|
200
|
+
const targets: ClientTarget[] = [
|
|
201
|
+
{
|
|
202
|
+
name: "Claude Code",
|
|
203
|
+
id: "claude_code",
|
|
204
|
+
detect: () => hasClaudeCli(env),
|
|
205
|
+
install: installClaudeCode,
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
const claudeDir = claudeDesktopDir(env);
|
|
210
|
+
if (claudeDir) {
|
|
211
|
+
const configPath = join(claudeDir, "claude_desktop_config.json");
|
|
212
|
+
targets.push({
|
|
213
|
+
name: "Claude Desktop",
|
|
214
|
+
id: "claude_desktop",
|
|
215
|
+
detect: () => existsSync(claudeDir),
|
|
216
|
+
install: (key) => upsertConfig(configPath, "mcpServers", mcpServersEntry(key)),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const cursorDir = join(env.home, ".cursor");
|
|
221
|
+
targets.push({
|
|
222
|
+
name: "Cursor",
|
|
223
|
+
id: "cursor",
|
|
224
|
+
detect: () => existsSync(cursorDir),
|
|
225
|
+
install: (key) => upsertConfig(join(cursorDir, "mcp.json"), "mcpServers", mcpServersEntry(key)),
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
const windsurfDir = join(env.home, ".codeium", "windsurf");
|
|
229
|
+
targets.push({
|
|
230
|
+
name: "Windsurf",
|
|
231
|
+
id: "windsurf",
|
|
232
|
+
detect: () => existsSync(windsurfDir),
|
|
233
|
+
install: (key) =>
|
|
234
|
+
upsertConfig(join(windsurfDir, "mcp_config.json"), "mcpServers", mcpServersEntry(key)),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const codeUserDir = vscodeUserDir(env);
|
|
238
|
+
targets.push({
|
|
239
|
+
name: "VS Code",
|
|
240
|
+
id: "vscode",
|
|
241
|
+
detect: () => existsSync(dirname(codeUserDir)),
|
|
242
|
+
install: (key) => upsertConfig(join(codeUserDir, "mcp.json"), "servers", vscodeEntry(key)),
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return targets;
|
|
246
|
+
}
|
package/src/doctor.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
import { buildTargets } from "./clients.js";
|
|
6
|
+
import { readApiKey } from "./credentials.js";
|
|
7
|
+
import { LOG_PATH, readLogTail } from "./logger.js";
|
|
8
|
+
import { telemetryStatus } from "./telemetry.js";
|
|
9
|
+
|
|
10
|
+
const PROD_API = "https://backend.omnidim.io/api/v1";
|
|
11
|
+
const ISSUES_URL = "https://github.com/Omnidim/omnidim-mcp-server/issues/new";
|
|
12
|
+
|
|
13
|
+
function packageVersion(): string {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = JSON.parse(
|
|
16
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
|
|
17
|
+
) as { version?: string };
|
|
18
|
+
return pkg.version ?? "unknown";
|
|
19
|
+
} catch {
|
|
20
|
+
return "unknown";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function probeBackend(apiKey: string | null): Promise<string> {
|
|
25
|
+
try {
|
|
26
|
+
const res = await axios.get(`${PROD_API}/agents`, {
|
|
27
|
+
params: { pagesize: 1 },
|
|
28
|
+
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
|
|
29
|
+
timeout: 8000,
|
|
30
|
+
validateStatus: () => true,
|
|
31
|
+
});
|
|
32
|
+
if (res.status === 200) return "reachable, key accepted (200)";
|
|
33
|
+
if (res.status === 401) return apiKey ? "reachable, key rejected (401)" : "reachable (401, no key)";
|
|
34
|
+
return `reachable, unexpected status ${res.status}`;
|
|
35
|
+
} catch (e) {
|
|
36
|
+
const code = (e as { code?: string }).code;
|
|
37
|
+
return `unreachable (${code ?? (e instanceof Error ? e.message : "error")})`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function runDoctor(): Promise<number> {
|
|
42
|
+
const envKey = process.env.OMNIDIM_API_KEY;
|
|
43
|
+
const savedKey = readApiKey();
|
|
44
|
+
const apiKey = envKey || savedKey;
|
|
45
|
+
const keyState = envKey ? "set (env)" : savedKey ? "set (saved file)" : "not set";
|
|
46
|
+
|
|
47
|
+
const backend = await probeBackend(apiKey);
|
|
48
|
+
const tel = telemetryStatus();
|
|
49
|
+
const clients = buildTargets().map((t) => `${t.name}: ${t.detect() ? "detected" : "not installed"}`);
|
|
50
|
+
const log = readLogTail(20);
|
|
51
|
+
|
|
52
|
+
const lines = [
|
|
53
|
+
"OmniDimension MCP server — doctor",
|
|
54
|
+
"",
|
|
55
|
+
` package @omnidim-ai/mcp-server ${packageVersion()}`,
|
|
56
|
+
` node ${process.version}`,
|
|
57
|
+
` os ${process.platform} ${process.arch}`,
|
|
58
|
+
` api key ${keyState}`,
|
|
59
|
+
` backend ${PROD_API} — ${backend}`,
|
|
60
|
+
` clients ${clients.join(" · ")}`,
|
|
61
|
+
` telemetry ${tel.disabled ? `disabled (${tel.reason})` : "enabled"}`,
|
|
62
|
+
` log ${LOG_PATH}`,
|
|
63
|
+
"",
|
|
64
|
+
];
|
|
65
|
+
if (log.length) {
|
|
66
|
+
lines.push(" recent errors (oldest first):");
|
|
67
|
+
for (const line of log) lines.push(` ${line}`);
|
|
68
|
+
} else {
|
|
69
|
+
lines.push(" recent errors: none logged");
|
|
70
|
+
}
|
|
71
|
+
lines.push("", ` Report an issue: ${ISSUES_URL}`, " Copy everything above into the issue.", "");
|
|
72
|
+
|
|
73
|
+
process.stdout.write(lines.join("\n") + "\n");
|
|
74
|
+
return 0;
|
|
75
|
+
}
|