@deckflow/deckprobe-mcp 0.1.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/LICENSE +22 -0
- package/README.md +244 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +59 -0
- package/dist/config.js.map +1 -0
- package/dist/engine/index.d.ts +11 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +60 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/native.d.ts +21 -0
- package/dist/engine/native.d.ts.map +1 -0
- package/dist/engine/native.js +193 -0
- package/dist/engine/native.js.map +1 -0
- package/dist/engine/types.d.ts +52 -0
- package/dist/engine/types.d.ts.map +1 -0
- package/dist/engine/types.js +21 -0
- package/dist/engine/types.js.map +1 -0
- package/dist/engine/wasm.d.ts +23 -0
- package/dist/engine/wasm.d.ts.map +1 -0
- package/dist/engine/wasm.js +116 -0
- package/dist/engine/wasm.js.map +1 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +25 -0
- package/dist/errors.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +68 -0
- package/dist/main.js.map +1 -0
- package/dist/paths.d.ts +9 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +34 -0
- package/dist/paths.js.map +1 -0
- package/dist/result.d.ts +28 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +101 -0
- package/dist/result.js.map +1 -0
- package/dist/schemas.d.ts +59 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +53 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +47 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/context.d.ts +7 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +2 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/discovery.d.ts +4 -0
- package/dist/tools/discovery.d.ts.map +1 -0
- package/dist/tools/discovery.js +130 -0
- package/dist/tools/discovery.js.map +1 -0
- package/dist/tools/probe-batch.d.ts +4 -0
- package/dist/tools/probe-batch.d.ts.map +1 -0
- package/dist/tools/probe-batch.js +97 -0
- package/dist/tools/probe-batch.js.map +1 -0
- package/dist/tools/probe.d.ts +4 -0
- package/dist/tools/probe.d.ts.map +1 -0
- package/dist/tools/probe.js +45 -0
- package/dist/tools/probe.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/engine/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,sFAAsF;AACtF,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1C,2EAA2E;AAC3E,MAAM,aAAa,GAAG,KAAK,CAAC;AAQ5B,MAAM,SAAS;IACb,UAAU,CAAS;IACV,QAAQ,GAAsB,EAAE,CAAC;IAE1C,YAAY,OAAe;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAI,IAAsB;QACjC,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,C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,CAAC,CAAC;gBACH,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACpB,CAAC;QACH,CAAC,CAAC,CACL,CAAC;IACJ,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAa;IAC3C,OAAO,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type ProbeLevel = "header" | "metadata" | "deep";
|
|
2
|
+
export type Confidence = "low" | "medium" | "high" | "exact";
|
|
3
|
+
export type ProbeView = "report" | "values";
|
|
4
|
+
export interface Budget {
|
|
5
|
+
max_physical_bytes?: number | undefined;
|
|
6
|
+
max_expanded_bytes?: number | undefined;
|
|
7
|
+
max_archive_entries?: number | undefined;
|
|
8
|
+
timeout_ms?: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One probe request, in the same snake_case the tool inputs and the report use.
|
|
12
|
+
* Every field maps to exactly one CLI option; nothing else reaches the engine.
|
|
13
|
+
*/
|
|
14
|
+
export interface ProbeRequest {
|
|
15
|
+
targets?: string[] | undefined;
|
|
16
|
+
level?: ProbeLevel | undefined;
|
|
17
|
+
min_confidence?: Confidence | undefined;
|
|
18
|
+
target_confidence?: Record<string, Confidence> | undefined;
|
|
19
|
+
view?: ProbeView | undefined;
|
|
20
|
+
budget?: Budget | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* What the engine produced for one input: the JSON value verbatim, plus the
|
|
24
|
+
* status that decides whether it is a report or an error envelope.
|
|
25
|
+
*/
|
|
26
|
+
export interface EngineOutcome {
|
|
27
|
+
/** DeckProbe exit status: 0 on success, 1-6 on failure. */
|
|
28
|
+
exitCode: number;
|
|
29
|
+
/** A schema-v2 report, a values view, a discovery report, or an error envelope. */
|
|
30
|
+
json: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface Engine {
|
|
33
|
+
readonly kind: "native" | "wasm";
|
|
34
|
+
/** Human-readable engine location, for the startup line on stderr. */
|
|
35
|
+
readonly description: string;
|
|
36
|
+
version(): Promise<string>;
|
|
37
|
+
probe(path: string, request: ProbeRequest): Promise<EngineOutcome>;
|
|
38
|
+
probeBatch(paths: readonly string[], request: ProbeRequest): Promise<EngineOutcome[]>;
|
|
39
|
+
formats(): Promise<EngineOutcome>;
|
|
40
|
+
targets(format: string): Promise<EngineOutcome>;
|
|
41
|
+
schema(): Promise<EngineOutcome>;
|
|
42
|
+
}
|
|
43
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
44
|
+
/** The `error.code` of an engine envelope, or undefined when the value is not one. */
|
|
45
|
+
export declare function errorCodeOf(json: unknown): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The exit status an envelope stands for. Used by the JSONL path, where the
|
|
48
|
+
* process exits with the highest record status and per-record statuses have to
|
|
49
|
+
* come from the records themselves.
|
|
50
|
+
*/
|
|
51
|
+
export declare function exitCodeOf(json: unknown): number;
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/engine/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5C,MAAM,WAAW,MAAM;IACrB,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,kBAAkB,CAAC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QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG7D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAIhD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function isRecord(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
/** The `error.code` of an engine envelope, or undefined when the value is not one. */
|
|
5
|
+
export function errorCodeOf(json) {
|
|
6
|
+
if (!isRecord(json) || json.status !== "error" || !isRecord(json.error))
|
|
7
|
+
return undefined;
|
|
8
|
+
return typeof json.error.code === "string" ? json.error.code : undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The exit status an envelope stands for. Used by the JSONL path, where the
|
|
12
|
+
* process exits with the highest record status and per-record statuses have to
|
|
13
|
+
* come from the records themselves.
|
|
14
|
+
*/
|
|
15
|
+
export function exitCodeOf(json) {
|
|
16
|
+
if (!isRecord(json) || json.status !== "error")
|
|
17
|
+
return 0;
|
|
18
|
+
const code = isRecord(json.error) ? json.error.exit_code : undefined;
|
|
19
|
+
return typeof code === "number" ? code : 6;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/engine/types.ts"],"names":[],"mappings":"AA+CA,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,OAAO,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO;QAAE,OAAO,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Engine, EngineOutcome, ProbeRequest } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fallback engine for platforms with no prebuilt DeckProbe binary. It runs the
|
|
4
|
+
* same Rust engine compiled to WebAssembly, in this process, so `npx` works
|
|
5
|
+
* anywhere Node does.
|
|
6
|
+
*
|
|
7
|
+
* Two differences from the native path are unavoidable and are why this is the
|
|
8
|
+
* fallback rather than the default: the whole file is held in memory, and the
|
|
9
|
+
* server deadline cannot interrupt a probe already inside WebAssembly — only
|
|
10
|
+
* the engine's own `timeout_ms` budget bounds it.
|
|
11
|
+
*/
|
|
12
|
+
export declare class WasmEngine implements Engine {
|
|
13
|
+
#private;
|
|
14
|
+
readonly kind: "wasm";
|
|
15
|
+
readonly description = "bundled WebAssembly engine (no prebuilt binary for this platform)";
|
|
16
|
+
version(): Promise<string>;
|
|
17
|
+
probe(path: string, request: ProbeRequest): Promise<EngineOutcome>;
|
|
18
|
+
probeBatch(paths: readonly string[], request: ProbeRequest): Promise<EngineOutcome[]>;
|
|
19
|
+
formats(): Promise<EngineOutcome>;
|
|
20
|
+
targets(format: string): Promise<EngineOutcome>;
|
|
21
|
+
schema(): Promise<EngineOutcome>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/engine/wasm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKtE;;;;;;;;;GASG;AACH,qBAAa,UAAW,YAAW,MAAM;;IACvC,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAU;IAChC,QAAQ,CAAC,WAAW,uEAAuE;IAerF,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAK1B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAgBlE,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAMrF,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAKjC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAK/C,MAAM,IAAI,OAAO,CAAC,aAAa,CAAC;CAIvC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { ServerError } from "../errors.js";
|
|
2
|
+
import { exitCodeOf, isRecord } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fallback engine for platforms with no prebuilt DeckProbe binary. It runs the
|
|
5
|
+
* same Rust engine compiled to WebAssembly, in this process, so `npx` works
|
|
6
|
+
* anywhere Node does.
|
|
7
|
+
*
|
|
8
|
+
* Two differences from the native path are unavoidable and are why this is the
|
|
9
|
+
* fallback rather than the default: the whole file is held in memory, and the
|
|
10
|
+
* server deadline cannot interrupt a probe already inside WebAssembly — only
|
|
11
|
+
* the engine's own `timeout_ms` budget bounds it.
|
|
12
|
+
*/
|
|
13
|
+
export class WasmEngine {
|
|
14
|
+
kind = "wasm";
|
|
15
|
+
description = "bundled WebAssembly engine (no prebuilt binary for this platform)";
|
|
16
|
+
#sdk;
|
|
17
|
+
#load() {
|
|
18
|
+
this.#sdk ??= import("@deckflow/deckprobe").catch((error) => {
|
|
19
|
+
this.#sdk = undefined;
|
|
20
|
+
throw new ServerError("MCP_ENGINE_FAILURE", `the WebAssembly engine could not be loaded: ${error instanceof Error ? error.message : String(error)}`);
|
|
21
|
+
});
|
|
22
|
+
return this.#sdk;
|
|
23
|
+
}
|
|
24
|
+
async version() {
|
|
25
|
+
const sdk = await this.#load();
|
|
26
|
+
return `deckprobe ${await sdk.version()}`;
|
|
27
|
+
}
|
|
28
|
+
async probe(path, request) {
|
|
29
|
+
const sdk = await this.#load();
|
|
30
|
+
let report;
|
|
31
|
+
try {
|
|
32
|
+
report = await sdk.probeFile(path, sdkOptions(request));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new ServerError("MCP_ENGINE_FAILURE", `the WebAssembly engine failed on ${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
}
|
|
37
|
+
const exitCode = exitCodeOf(report);
|
|
38
|
+
const json = exitCode === 0 && request.view === "values" ? valuesView(report) : report;
|
|
39
|
+
return { exitCode, json };
|
|
40
|
+
}
|
|
41
|
+
async probeBatch(paths, request) {
|
|
42
|
+
const outcomes = [];
|
|
43
|
+
for (const path of paths)
|
|
44
|
+
outcomes.push(await this.probe(path, request));
|
|
45
|
+
return outcomes;
|
|
46
|
+
}
|
|
47
|
+
async formats() {
|
|
48
|
+
const sdk = await this.#load();
|
|
49
|
+
return wrap(await sdk.formats());
|
|
50
|
+
}
|
|
51
|
+
async targets(format) {
|
|
52
|
+
const sdk = await this.#load();
|
|
53
|
+
return wrap(await sdk.targets(format));
|
|
54
|
+
}
|
|
55
|
+
async schema() {
|
|
56
|
+
const sdk = await this.#load();
|
|
57
|
+
return wrap(await sdk.schema());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function wrap(json) {
|
|
61
|
+
return { exitCode: exitCodeOf(json), json };
|
|
62
|
+
}
|
|
63
|
+
function sdkOptions(request) {
|
|
64
|
+
const budget = request.budget;
|
|
65
|
+
return {
|
|
66
|
+
...(request.targets ? { targets: request.targets } : {}),
|
|
67
|
+
...(request.level ? { level: request.level } : {}),
|
|
68
|
+
...(request.min_confidence ? { minimumConfidence: request.min_confidence } : {}),
|
|
69
|
+
...(request.target_confidence ? { targetConfidence: request.target_confidence } : {}),
|
|
70
|
+
...(budget
|
|
71
|
+
? {
|
|
72
|
+
budget: {
|
|
73
|
+
...(budget.max_physical_bytes !== undefined
|
|
74
|
+
? { maxPhysicalBytes: budget.max_physical_bytes }
|
|
75
|
+
: {}),
|
|
76
|
+
...(budget.max_expanded_bytes !== undefined
|
|
77
|
+
? { maxExpandedBytes: budget.max_expanded_bytes }
|
|
78
|
+
: {}),
|
|
79
|
+
...(budget.max_archive_entries !== undefined
|
|
80
|
+
? { maxArchiveEntries: budget.max_archive_entries }
|
|
81
|
+
: {}),
|
|
82
|
+
...(budget.timeout_ms !== undefined ? { timeoutMs: budget.timeout_ms } : {}),
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
: {}),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The SDK always resolves the full evidence report — `--view values` is a CLI
|
|
90
|
+
* flag with no SDK equivalent — so the compact envelope is derived here, field
|
|
91
|
+
* for field with what the CLI writes.
|
|
92
|
+
*/
|
|
93
|
+
function valuesView(report) {
|
|
94
|
+
if (!isRecord(report))
|
|
95
|
+
return report;
|
|
96
|
+
const values = {};
|
|
97
|
+
const results = isRecord(report.results) ? report.results : {};
|
|
98
|
+
for (const [target, evidence] of Object.entries(results)) {
|
|
99
|
+
if (isRecord(evidence) && "value" in evidence)
|
|
100
|
+
values[target] = evidence.value;
|
|
101
|
+
}
|
|
102
|
+
const execution = isRecord(report.execution) ? report.execution : {};
|
|
103
|
+
return {
|
|
104
|
+
schema_version: report.schema_version,
|
|
105
|
+
tool_version: report.tool_version,
|
|
106
|
+
status: report.status,
|
|
107
|
+
input: report.input,
|
|
108
|
+
driver: report.driver,
|
|
109
|
+
values,
|
|
110
|
+
unresolved_targets: execution.unresolved_targets ?? [],
|
|
111
|
+
piggyback_targets: execution.piggyback_targets ?? [],
|
|
112
|
+
diagnostics: report.diagnostics ?? [],
|
|
113
|
+
view: "values",
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=wasm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../src/engine/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIlD;;;;;;;;;GASG;AACH,MAAM,OAAO,UAAU;IACZ,IAAI,GAAG,MAAe,CAAC;IACvB,WAAW,GAAG,mEAAmE,CAAC;IAE3F,IAAI,CAAoC;IAExC,KAAK;QACH,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,qBAAqB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACnE,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,MAAM,IAAI,WAAW,CACnB,oBAAoB,EACpB,+CAA+C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACxG,CAA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IACjF,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,OAAO;QACL,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM;QACN,kBAAkB,EAAE,SAAS,CAAC,kBAAkB,IAAI,EAAE;QACtD,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,IAAI,EAAE;QACpD,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;QACrC,IAAI,EAAE,QAAQ;KACf,CAAC;AACJ,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-originated failures reuse DeckProbe's error envelope so a consumer
|
|
3
|
+
* parses one error grammar everywhere. `origin` is what tells the two apart:
|
|
4
|
+
* an engine envelope carries `exit_code` and `tool_version`, a server envelope
|
|
5
|
+
* carries `origin: "mcp-server"`.
|
|
6
|
+
*/
|
|
7
|
+
export interface ServerErrorEnvelope {
|
|
8
|
+
schema_version: 2;
|
|
9
|
+
status: "error";
|
|
10
|
+
error: {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
origin: "mcp-server";
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare class ServerError extends Error {
|
|
17
|
+
readonly code: string;
|
|
18
|
+
readonly hint: string | undefined;
|
|
19
|
+
constructor(code: string, message: string, hint?: string);
|
|
20
|
+
envelope(): ServerErrorEnvelope;
|
|
21
|
+
}
|
|
22
|
+
/** A bad `DECKPROBE_MCP_*` value. Raised at startup so the operator sees it immediately. */
|
|
23
|
+
export declare class ConfigError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,CAAC,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,YAAY,CAAC;KACtB,CAAC;CACH;AAED,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEtB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAOxD,QAAQ,IAAI,mBAAmB;CAOhC;AAED,4FAA4F;AAC5F,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class ServerError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
hint;
|
|
4
|
+
constructor(code, message, hint) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "ServerError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.hint = hint;
|
|
9
|
+
}
|
|
10
|
+
envelope() {
|
|
11
|
+
return {
|
|
12
|
+
schema_version: 2,
|
|
13
|
+
status: "error",
|
|
14
|
+
error: { code: this.code, message: this.message, origin: "mcp-server" },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** A bad `DECKPROBE_MCP_*` value. Raised at startup so the operator sees it immediately. */
|
|
19
|
+
export class ConfigError extends Error {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.name = "ConfigError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAgBA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAS;IACb,IAAI,CAAqB;IAElC,YAAY,IAAY,EAAE,OAAe,EAAE,IAAa;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ;QACN,OAAO;YACL,cAAc,EAAE,CAAC;YACjB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE;SACxE,CAAC;IACJ,CAAC;CACF;AAED,4FAA4F;AAC5F,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
3
|
+
import { DEFAULT_MAX_BATCH, DEFAULT_MAX_CONCURRENCY, DEFAULT_TIMEOUT_MS, loadConfig, } from "./config.js";
|
|
4
|
+
import { createEngine } from "./engine/index.js";
|
|
5
|
+
import { ConfigError } from "./errors.js";
|
|
6
|
+
import { buildServer } from "./server.js";
|
|
7
|
+
import { PACKAGE_NAME, SERVER_VERSION } from "./version.js";
|
|
8
|
+
const HELP = `${PACKAGE_NAME} ${SERVER_VERSION}
|
|
9
|
+
|
|
10
|
+
An MCP server that inspects PDF, Microsoft Office, and Apple iWork documents
|
|
11
|
+
with DeckProbe. It speaks MCP over stdio and is meant to be launched by an MCP
|
|
12
|
+
client, not run by hand.
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
deckprobe-mcp Serve MCP over stdio
|
|
16
|
+
deckprobe-mcp --version Print the server version
|
|
17
|
+
deckprobe-mcp --help Print this message
|
|
18
|
+
|
|
19
|
+
Add it to a client, for example Claude Code:
|
|
20
|
+
claude mcp add deckprobe -- npx -y ${PACKAGE_NAME}
|
|
21
|
+
|
|
22
|
+
Environment:
|
|
23
|
+
DECKPROBE_MCP_BIN Engine binary to use instead of the bundled one
|
|
24
|
+
DECKPROBE_MCP_ROOTS Allowed directories, separated like PATH (default: unrestricted)
|
|
25
|
+
DECKPROBE_MCP_TIMEOUT_MS Hard per-call deadline (default: ${DEFAULT_TIMEOUT_MS})
|
|
26
|
+
DECKPROBE_MCP_MAX_CONCURRENCY Concurrent engine processes (default: ${DEFAULT_MAX_CONCURRENCY})
|
|
27
|
+
DECKPROBE_MCP_MAX_BATCH Paths per probe_batch call (default: ${DEFAULT_MAX_BATCH})
|
|
28
|
+
|
|
29
|
+
Tools: probe, probe_batch, list_formats, list_targets
|
|
30
|
+
Docs: https://github.com/deckflow/deckprobe-mcp-server`;
|
|
31
|
+
/** stdout carries the MCP transport, so everything the operator sees goes to stderr. */
|
|
32
|
+
function log(message) {
|
|
33
|
+
process.stderr.write(`deckprobe-mcp: ${message}\n`);
|
|
34
|
+
}
|
|
35
|
+
async function main(argv) {
|
|
36
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
37
|
+
process.stdout.write(`${HELP}\n`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (argv.includes("--version") || argv.includes("-V")) {
|
|
41
|
+
process.stdout.write(`${SERVER_VERSION}\n`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const config = loadConfig();
|
|
45
|
+
const engine = await createEngine(config);
|
|
46
|
+
let engineVersion = "unknown version";
|
|
47
|
+
try {
|
|
48
|
+
engineVersion = await engine.version();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
log(`warning: could not read the engine version: ${error.message}`);
|
|
52
|
+
}
|
|
53
|
+
log(`serving MCP over stdio using the ${engine.description} (${engineVersion})`);
|
|
54
|
+
if (config.roots.length > 0)
|
|
55
|
+
log(`reads restricted to: ${config.roots.join(", ")}`);
|
|
56
|
+
serveStdio(() => buildServer(engine, config), {
|
|
57
|
+
onerror: (error) => log(`transport error: ${error.message}`),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
main(process.argv.slice(2)).catch((error) => {
|
|
61
|
+
if (error instanceof ConfigError) {
|
|
62
|
+
log(`configuration error: ${error.message}`);
|
|
63
|
+
process.exit(2);
|
|
64
|
+
}
|
|
65
|
+
log(`fatal: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MA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M,GAAG,CAAC;QAAE,GAAG,CAAC,wBAAwB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEpF,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QAC5C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,oBAAoB,KAAK,CAAC,OAAO,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACnD,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;QACjC,GAAG,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,GAAG,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Config } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Turns a caller-supplied path into the absolute, symlink-resolved path handed
|
|
4
|
+
* to the engine, rejecting anything the server should not read. Doing the
|
|
5
|
+
* existence check here rather than letting the engine report `SOURCE_IO` keeps
|
|
6
|
+
* the allow-list enforceable and avoids spawning a process for a typo.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveInputPath(raw: string, config: Config): string;
|
|
9
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAA+B,MAAM,aAAa,CAAC;AAGvE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAmCpE"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { canonicalPath, isInsideRoot } from "./config.js";
|
|
3
|
+
import { ServerError } from "./errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* Turns a caller-supplied path into the absolute, symlink-resolved path handed
|
|
6
|
+
* to the engine, rejecting anything the server should not read. Doing the
|
|
7
|
+
* existence check here rather than letting the engine report `SOURCE_IO` keeps
|
|
8
|
+
* the allow-list enforceable and avoids spawning a process for a typo.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveInputPath(raw, config) {
|
|
11
|
+
if (raw.trim() === "") {
|
|
12
|
+
throw new ServerError("MCP_INVALID_PATH", "path must not be empty");
|
|
13
|
+
}
|
|
14
|
+
const path = canonicalPath(raw);
|
|
15
|
+
let stats;
|
|
16
|
+
try {
|
|
17
|
+
stats = statSync(path);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
21
|
+
throw new ServerError("MCP_INVALID_PATH", `cannot read ${raw}: ${reason}`);
|
|
22
|
+
}
|
|
23
|
+
if (stats.isDirectory()) {
|
|
24
|
+
throw new ServerError("MCP_INVALID_PATH", `${raw} is a directory; DeckProbe probes one document at a time`, "List the documents in the directory yourself and pass them to probe_batch.");
|
|
25
|
+
}
|
|
26
|
+
if (!stats.isFile()) {
|
|
27
|
+
throw new ServerError("MCP_INVALID_PATH", `${raw} is not a regular file`);
|
|
28
|
+
}
|
|
29
|
+
if (config.roots.length > 0 && !config.roots.some((root) => isInsideRoot(path, root))) {
|
|
30
|
+
throw new ServerError("MCP_PATH_NOT_ALLOWED", `${raw} is outside the directories this server is allowed to read`, `Allowed roots: ${config.roots.join(", ")}. They are set with DECKPROBE_MCP_ROOTS.`);
|
|
31
|
+
}
|
|
32
|
+
return path;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAe,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,MAAc;IAC1D,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,WAAW,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAEhC,IAAI,KAAkC,CAAC;IACvC,IAAI,CAAC;QACH,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,IAAI,WAAW,CAAC,kBAAkB,EAAE,eAAe,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,WAAW,CACnB,kBAAkB,EAClB,GAAG,GAAG,0DAA0D,EAChE,4EAA4E,CAC7E,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,WAAW,CAAC,kBAAkB,EAAE,GAAG,GAAG,wBAAwB,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;QACtF,MAAM,IAAI,WAAW,CACnB,sBAAsB,EACtB,GAAG,GAAG,4DAA4D,EAClE,kBAAkB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,0CAA0C,CACpF,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/server";
|
|
2
|
+
import { ServerError } from "./errors.js";
|
|
3
|
+
export declare function hintFor(json: unknown, exitCode: number): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Reports are indented because they are read as much as they are parsed. A long
|
|
6
|
+
* batch or a full target catalogue is emitted compactly instead: indenting one
|
|
7
|
+
* roughly doubles its size for no gain, and `structuredContent` carries the
|
|
8
|
+
* same value for anything consuming it programmatically.
|
|
9
|
+
*/
|
|
10
|
+
export declare function jsonText(json: unknown): string;
|
|
11
|
+
export declare function successResult(json: unknown): CallToolResult;
|
|
12
|
+
/**
|
|
13
|
+
* An engine failure. The envelope is the message; the hint goes first because
|
|
14
|
+
* it is the part that says what to do next.
|
|
15
|
+
*/
|
|
16
|
+
export declare function engineErrorResult(json: unknown, exitCode: number): CallToolResult;
|
|
17
|
+
export declare function serverErrorResult(error: ServerError): CallToolResult;
|
|
18
|
+
/**
|
|
19
|
+
* Every tool body runs through here, so a caller always gets one error grammar
|
|
20
|
+
* back instead of a bare protocol error for anything unforeseen.
|
|
21
|
+
*/
|
|
22
|
+
export declare function guard(run: () => Promise<CallToolResult>): Promise<CallToolResult>;
|
|
23
|
+
/** Maps one engine outcome to a tool result. `partial` is a success, not a failure. */
|
|
24
|
+
export declare function outcomeResult(outcome: {
|
|
25
|
+
exitCode: number;
|
|
26
|
+
json: unknown;
|
|
27
|
+
}): CallToolResult;
|
|
28
|
+
//# sourceMappingURL=result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmC1C,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI3E;AAKD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAI9C;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CAK3D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAUjF;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAUpE;AAED;;;GAGG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAavF;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,cAAc,CAI1F"}
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { errorCodeOf, isRecord } from "./engine/index.js";
|
|
2
|
+
import { ServerError } from "./errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* What to do about each engine failure. Keyed on `error.code` rather than the
|
|
5
|
+
* exit status because status 4 covers both a damaged file and an exhausted
|
|
6
|
+
* budget, which call for opposite responses.
|
|
7
|
+
*/
|
|
8
|
+
const HINTS = {
|
|
9
|
+
UNSUPPORTED_TARGET: "This format has no path for that target. Call list_targets with the file's format to see the valid names, aliases, and minimum levels.",
|
|
10
|
+
UNSUPPORTED_FORMAT: "DeckProbe has no driver for this extension. Call list_formats for the supported set. Legacy XML iWork packages are rejected by design; only modern .key/.numbers/.pages are supported.",
|
|
11
|
+
MALFORMED_INPUT: "The container does not match what the extension claims, or the file is damaged. DeckProbe routes by extension and then verifies the contents, so a renamed file fails here.",
|
|
12
|
+
BUDGET_EXCEEDED: "The probe hit a resource limit before it could finish. Raise budget.max_physical_bytes, max_expanded_bytes, max_archive_entries, or timeout_ms — or drop to a lower level.",
|
|
13
|
+
SOURCE_IO: "The file could not be read. Check the path and its permissions.",
|
|
14
|
+
INTERNAL: "This is an engine bug. Please report it at https://github.com/deckflow/deckprobe/issues.",
|
|
15
|
+
};
|
|
16
|
+
/** Fallback when the envelope carries a code this server has no specific advice for. */
|
|
17
|
+
function hintForExitCode(exitCode) {
|
|
18
|
+
switch (exitCode) {
|
|
19
|
+
case 1:
|
|
20
|
+
return "The request itself was rejected. Call list_targets for this format and check the target names.";
|
|
21
|
+
case 2:
|
|
22
|
+
return "The engine could not read the input. Check the path.";
|
|
23
|
+
case 6:
|
|
24
|
+
return "This is an engine bug. Please report it at https://github.com/deckflow/deckprobe/issues.";
|
|
25
|
+
default:
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function hintFor(json, exitCode) {
|
|
30
|
+
const code = errorCodeOf(json);
|
|
31
|
+
if (code && HINTS[code])
|
|
32
|
+
return HINTS[code];
|
|
33
|
+
return hintForExitCode(exitCode);
|
|
34
|
+
}
|
|
35
|
+
/** Above this, indentation costs more context than the readability is worth. */
|
|
36
|
+
const PRETTY_LIMIT_BYTES = 8 * 1024;
|
|
37
|
+
/**
|
|
38
|
+
* Reports are indented because they are read as much as they are parsed. A long
|
|
39
|
+
* batch or a full target catalogue is emitted compactly instead: indenting one
|
|
40
|
+
* roughly doubles its size for no gain, and `structuredContent` carries the
|
|
41
|
+
* same value for anything consuming it programmatically.
|
|
42
|
+
*/
|
|
43
|
+
export function jsonText(json) {
|
|
44
|
+
const compact = JSON.stringify(json);
|
|
45
|
+
if (compact === undefined)
|
|
46
|
+
return "null";
|
|
47
|
+
return compact.length > PRETTY_LIMIT_BYTES ? compact : JSON.stringify(json, null, 2);
|
|
48
|
+
}
|
|
49
|
+
export function successResult(json) {
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: jsonText(json) }],
|
|
52
|
+
structuredContent: isRecord(json) ? json : { result: json },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* An engine failure. The envelope is the message; the hint goes first because
|
|
57
|
+
* it is the part that says what to do next.
|
|
58
|
+
*/
|
|
59
|
+
export function engineErrorResult(json, exitCode) {
|
|
60
|
+
const hint = hintFor(json, exitCode);
|
|
61
|
+
return {
|
|
62
|
+
isError: true,
|
|
63
|
+
content: [
|
|
64
|
+
...(hint ? [{ type: "text", text: hint }] : []),
|
|
65
|
+
{ type: "text", text: jsonText(json) },
|
|
66
|
+
],
|
|
67
|
+
...(isRecord(json) ? { structuredContent: json } : {}),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function serverErrorResult(error) {
|
|
71
|
+
const envelope = error.envelope();
|
|
72
|
+
return {
|
|
73
|
+
isError: true,
|
|
74
|
+
content: [
|
|
75
|
+
...(error.hint ? [{ type: "text", text: error.hint }] : []),
|
|
76
|
+
{ type: "text", text: jsonText(envelope) },
|
|
77
|
+
],
|
|
78
|
+
structuredContent: envelope,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Every tool body runs through here, so a caller always gets one error grammar
|
|
83
|
+
* back instead of a bare protocol error for anything unforeseen.
|
|
84
|
+
*/
|
|
85
|
+
export async function guard(run) {
|
|
86
|
+
try {
|
|
87
|
+
return await run();
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof ServerError)
|
|
91
|
+
return serverErrorResult(error);
|
|
92
|
+
return serverErrorResult(new ServerError("MCP_INTERNAL", error instanceof Error ? error.message : String(error), "This is a bug in the DeckProbe MCP server. Please report it at https://github.com/deckflow/deckprobe-mcp-server/issues."));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Maps one engine outcome to a tool result. `partial` is a success, not a failure. */
|
|
96
|
+
export function outcomeResult(outcome) {
|
|
97
|
+
return outcome.exitCode === 0
|
|
98
|
+
? successResult(outcome.json)
|
|
99
|
+
: engineErrorResult(outcome.json, outcome.exitCode);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;GAIG;AACH,MAAM,KAAK,GAA2B;IACpC,kBAAkB,EAChB,wIAAwI;IAC1I,kBAAkB,EAChB,wLAAwL;IAC1L,eAAe,EACb,6KAA6K;IAC/K,eAAe,EACb,4KAA4K;IAC9K,SAAS,EAAE,iEAAiE;IAC5E,QAAQ,EACN,0FAA0F;CAC7F,CAAC;AAEF,wFAAwF;AACxF,SAAS,eAAe,CAAC,QAAgB;IACvC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,CAAC;YACJ,OAAO,gGAAgG,CAAC;QAC1G,KAAK,CAAC;YACJ,OAAO,sDAAsD,CAAC;QACh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