dap-mcp-server 0.1.12 → 0.1.16
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 +25 -7
- package/SKILL.md +37 -186
- package/build/adapters/detect.d.ts +12 -0
- package/build/adapters/detect.js +91 -0
- package/build/adapters/detect.js.map +1 -1
- package/build/adapters/registry.js +35 -12
- package/build/adapters/registry.js.map +1 -1
- package/build/diagnostics/doctor.d.ts +64 -0
- package/build/diagnostics/doctor.js +209 -0
- package/build/diagnostics/doctor.js.map +1 -0
- package/build/server.js +305 -83
- package/build/server.js.map +1 -1
- package/build/session/inspect.d.ts +6 -2
- package/build/session/inspect.js +24 -8
- package/build/session/inspect.js.map +1 -1
- package/build/session/run.js +2 -9
- package/build/session/run.js.map +1 -1
- package/build/session/session.d.ts +16 -0
- package/build/session/session.js +63 -8
- package/build/session/session.js.map +1 -1
- package/integrations/claude/dap-debugging/.claude-plugin/plugin.json +9 -0
- package/integrations/claude/dap-debugging/.mcp.json +8 -0
- package/integrations/claude/dap-debugging/skills/dap-debugging/SKILL.md +49 -0
- package/package.json +8 -3
- package/.forgejo/workflows/publish.yml +0 -63
- package/CLAUDE.md +0 -71
- package/TODO.md +0 -32
- package/docs/plans/2026-03-05-dap-wrapper-mcp-design.md +0 -326
- package/docs/plans/2026-03-05-dap-wrapper-mcp-implementation.md +0 -2815
- package/src/adapters/builtin.ts +0 -75
- package/src/adapters/detect.test.ts +0 -36
- package/src/adapters/detect.ts +0 -36
- package/src/adapters/registry.test.ts +0 -74
- package/src/adapters/registry.ts +0 -86
- package/src/dap/dap-client.test.ts +0 -118
- package/src/dap/dap-client.ts +0 -588
- package/src/dap/protocol.test.ts +0 -82
- package/src/dap/protocol.ts +0 -78
- package/src/dap/ring-buffer.test.ts +0 -82
- package/src/dap/ring-buffer.ts +0 -64
- package/src/dap/types.ts +0 -115
- package/src/index.ts +0 -30
- package/src/integration/debug-lifecycle.test.ts +0 -131
- package/src/server.ts +0 -1096
- package/src/session/inspect.test.ts +0 -126
- package/src/session/inspect.ts +0 -160
- package/src/session/run.test.ts +0 -74
- package/src/session/run.ts +0 -144
- package/src/session/session-manager.test.ts +0 -74
- package/src/session/session-manager.ts +0 -67
- package/src/session/session.test.ts +0 -126
- package/src/session/session.ts +0 -482
- package/src/test-fixtures/crash-adapter.js +0 -23
- package/src/test-fixtures/mock-adapter.js +0 -164
- package/src/test-fixtures/no-stop-adapter.js +0 -77
- package/src/test-fixtures/silent-adapter.js +0 -24
- package/src/test-fixtures/tcp-mock-adapter.js +0 -87
- package/tsconfig.json +0 -16
package/src/dap/protocol.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Ivan Iraci <ivan.iraci@professioneit.com>
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in
|
|
12
|
-
* all copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { DebugProtocol } from "@vscode/debugprotocol";
|
|
24
|
-
|
|
25
|
-
const TWO_CRLF = "\r\n\r\n";
|
|
26
|
-
const CONTENT_LENGTH = "Content-Length: ";
|
|
27
|
-
|
|
28
|
-
export function encodeMessage(msg: DebugProtocol.ProtocolMessage): Buffer {
|
|
29
|
-
const json = JSON.stringify(msg);
|
|
30
|
-
const header = `${CONTENT_LENGTH}${Buffer.byteLength(json)}${TWO_CRLF}`;
|
|
31
|
-
return Buffer.from(header + json, "utf-8");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class MessageParser {
|
|
35
|
-
private buffer = Buffer.alloc(0);
|
|
36
|
-
private contentLength = -1;
|
|
37
|
-
private onMessage: (msg: DebugProtocol.ProtocolMessage) => void;
|
|
38
|
-
|
|
39
|
-
constructor(onMessage: (msg: DebugProtocol.ProtocolMessage) => void) {
|
|
40
|
-
this.onMessage = onMessage;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
feed(data: Buffer): void {
|
|
44
|
-
this.buffer = Buffer.concat([this.buffer, data]);
|
|
45
|
-
this.parse();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private parse(): void {
|
|
49
|
-
while (true) {
|
|
50
|
-
if (this.contentLength === -1) {
|
|
51
|
-
const headerEnd = this.buffer.indexOf(TWO_CRLF);
|
|
52
|
-
if (headerEnd === -1) return;
|
|
53
|
-
|
|
54
|
-
const header = this.buffer.subarray(0, headerEnd).toString("utf-8");
|
|
55
|
-
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
56
|
-
if (!match) {
|
|
57
|
-
this.buffer = this.buffer.subarray(headerEnd + TWO_CRLF.length);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
this.contentLength = parseInt(match[1], 10);
|
|
61
|
-
this.buffer = this.buffer.subarray(headerEnd + TWO_CRLF.length);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (this.buffer.length < this.contentLength) return;
|
|
65
|
-
|
|
66
|
-
const body = this.buffer.subarray(0, this.contentLength).toString("utf-8");
|
|
67
|
-
this.buffer = this.buffer.subarray(this.contentLength);
|
|
68
|
-
this.contentLength = -1;
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const msg = JSON.parse(body) as DebugProtocol.ProtocolMessage;
|
|
72
|
-
this.onMessage(msg);
|
|
73
|
-
} catch {
|
|
74
|
-
// Skip malformed JSON
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Ivan Iraci <ivan.iraci@professioneit.com>
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in
|
|
12
|
-
* all copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { describe, it, expect } from "vitest";
|
|
24
|
-
import { RingBuffer } from "./ring-buffer.js";
|
|
25
|
-
|
|
26
|
-
describe("RingBuffer", () => {
|
|
27
|
-
it("stores and retrieves entries", () => {
|
|
28
|
-
const buf = new RingBuffer<string>(100);
|
|
29
|
-
buf.push("a");
|
|
30
|
-
buf.push("b");
|
|
31
|
-
expect(buf.getAll()).toEqual(["a", "b"]);
|
|
32
|
-
expect(buf.truncated).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("drops oldest entries when full", () => {
|
|
36
|
-
const buf = new RingBuffer<string>(3);
|
|
37
|
-
buf.push("a");
|
|
38
|
-
buf.push("b");
|
|
39
|
-
buf.push("c");
|
|
40
|
-
buf.push("d");
|
|
41
|
-
expect(buf.getAll()).toEqual(["b", "c", "d"]);
|
|
42
|
-
expect(buf.truncated).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("clears entries", () => {
|
|
46
|
-
const buf = new RingBuffer<string>(10);
|
|
47
|
-
buf.push("a");
|
|
48
|
-
buf.push("b");
|
|
49
|
-
buf.clear();
|
|
50
|
-
expect(buf.getAll()).toEqual([]);
|
|
51
|
-
expect(buf.truncated).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("filters entries", () => {
|
|
55
|
-
const buf = new RingBuffer<{ cat: string; text: string }>(10);
|
|
56
|
-
buf.push({ cat: "stdout", text: "hello" });
|
|
57
|
-
buf.push({ cat: "stderr", text: "error" });
|
|
58
|
-
buf.push({ cat: "stdout", text: "world" });
|
|
59
|
-
const filtered = buf.getFiltered((e) => e.cat === "stdout");
|
|
60
|
-
expect(filtered).toEqual([
|
|
61
|
-
{ cat: "stdout", text: "hello" },
|
|
62
|
-
{ cat: "stdout", text: "world" },
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("reports size correctly", () => {
|
|
67
|
-
const buf = new RingBuffer<string>(5);
|
|
68
|
-
expect(buf.size).toBe(0);
|
|
69
|
-
buf.push("a");
|
|
70
|
-
buf.push("b");
|
|
71
|
-
expect(buf.size).toBe(2);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("removes only matching entries", () => {
|
|
75
|
-
const buf = new RingBuffer<{ cat: string; text: string }>(10);
|
|
76
|
-
buf.push({ cat: "stdout", text: "hello" });
|
|
77
|
-
buf.push({ cat: "stderr", text: "error" });
|
|
78
|
-
buf.push({ cat: "stdout", text: "world" });
|
|
79
|
-
buf.removeMatching((e) => e.cat === "stdout");
|
|
80
|
-
expect(buf.getAll()).toEqual([{ cat: "stderr", text: "error" }]);
|
|
81
|
-
});
|
|
82
|
-
});
|
package/src/dap/ring-buffer.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Ivan Iraci <ivan.iraci@professioneit.com>
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in
|
|
12
|
-
* all copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export class RingBuffer<T> {
|
|
24
|
-
private buffer: T[] = [];
|
|
25
|
-
private maxSize: number;
|
|
26
|
-
private _truncated = false;
|
|
27
|
-
|
|
28
|
-
constructor(maxSize: number) {
|
|
29
|
-
this.maxSize = maxSize;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
push(item: T): void {
|
|
33
|
-
if (this.buffer.length >= this.maxSize) {
|
|
34
|
-
this.buffer.shift();
|
|
35
|
-
this._truncated = true;
|
|
36
|
-
}
|
|
37
|
-
this.buffer.push(item);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getAll(): T[] {
|
|
41
|
-
return [...this.buffer];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getFiltered(predicate: (item: T) => boolean): T[] {
|
|
45
|
-
return this.buffer.filter(predicate);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
clear(): void {
|
|
49
|
-
this.buffer = [];
|
|
50
|
-
this._truncated = false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
removeMatching(predicate: (item: T) => boolean): void {
|
|
54
|
-
this.buffer = this.buffer.filter((item) => !predicate(item));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get size(): number {
|
|
58
|
-
return this.buffer.length;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get truncated(): boolean {
|
|
62
|
-
return this._truncated;
|
|
63
|
-
}
|
|
64
|
-
}
|
package/src/dap/types.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Ivan Iraci <ivan.iraci@professioneit.com>
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in
|
|
12
|
-
* all copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
// src/dap/types.ts
|
|
24
|
-
|
|
25
|
-
export type SessionState = "idle" | "configuring" | "running" | "stopped" | "terminated";
|
|
26
|
-
|
|
27
|
-
export interface Variable {
|
|
28
|
-
name: string;
|
|
29
|
-
value: string;
|
|
30
|
-
type?: string;
|
|
31
|
-
hasChildren: boolean;
|
|
32
|
-
variablesReference: number;
|
|
33
|
-
/** Populated when getVariables is called with depth > 1 and this variable has children. */
|
|
34
|
-
children?: Variable[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface StoppedState {
|
|
38
|
-
status: "stopped";
|
|
39
|
-
reason: string;
|
|
40
|
-
location: {
|
|
41
|
-
file: string;
|
|
42
|
-
line: number;
|
|
43
|
-
column?: number;
|
|
44
|
-
functionName?: string;
|
|
45
|
-
};
|
|
46
|
-
threads: Array<{ id: number; name: string; stopped: boolean }>;
|
|
47
|
-
stackTrace: Array<{
|
|
48
|
-
id: number;
|
|
49
|
-
name: string;
|
|
50
|
-
file: string;
|
|
51
|
-
line: number;
|
|
52
|
-
column?: number;
|
|
53
|
-
}>;
|
|
54
|
-
scopes: Array<{
|
|
55
|
-
name: string;
|
|
56
|
-
variables: Variable[];
|
|
57
|
-
}>;
|
|
58
|
-
output?: string[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface RunningState {
|
|
62
|
-
status: "running";
|
|
63
|
-
output?: string[];
|
|
64
|
-
elapsedMs?: number;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type DebugState = StoppedState | RunningState;
|
|
68
|
-
|
|
69
|
-
export interface AdapterConfig {
|
|
70
|
-
type: string;
|
|
71
|
-
runtime?: string;
|
|
72
|
-
program: string;
|
|
73
|
-
args?: string[];
|
|
74
|
-
launchDefaults?: Record<string, unknown>;
|
|
75
|
-
installHint?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Transport mode for the adapter:
|
|
78
|
-
* - "stdio" (default): DAP messages flow over the adapter's stdin/stdout.
|
|
79
|
-
* - "tcp": the adapter is a TCP DAP server. After spawning, the client reads
|
|
80
|
-
* the listening address from the adapter's stdout (matched with
|
|
81
|
-
* `portMatcher`) and connects to it via a TCP socket. DAP messages then
|
|
82
|
-
* flow over that socket. Use this for adapters like `dlv dap` or
|
|
83
|
-
* vscode-js-debug's `dapDebugServer.js` that don't speak DAP on stdio.
|
|
84
|
-
*/
|
|
85
|
-
transport?: "stdio" | "tcp";
|
|
86
|
-
/**
|
|
87
|
-
* Regular expression with a single capture group that yields the TCP port the
|
|
88
|
-
* adapter is listening on. Matched against the adapter's stdout output.
|
|
89
|
-
* Required (and only used) when `transport` is "tcp".
|
|
90
|
-
* Example for delve: "DAP server listening at:\\s*\\S+:(\\d+)"
|
|
91
|
-
*/
|
|
92
|
-
portMatcher?: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface OutputEntry {
|
|
96
|
-
/** Monotonic per-session sequence number assigned at push time. Survives ring-buffer eviction. */
|
|
97
|
-
seq: number;
|
|
98
|
-
category: string;
|
|
99
|
-
text: string;
|
|
100
|
-
timestamp: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface BreakpointConfig {
|
|
104
|
-
line: number;
|
|
105
|
-
condition?: string;
|
|
106
|
-
hitCondition?: string;
|
|
107
|
-
logMessage?: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface BreakpointResult {
|
|
111
|
-
id?: number;
|
|
112
|
-
verified: boolean;
|
|
113
|
-
line: number;
|
|
114
|
-
message?: string;
|
|
115
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2026 Ivan Iraci <ivan.iraci@professioneit.com>
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
* in the Software without restriction, including without limitation the rights
|
|
8
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
* furnished to do so, subject to the following conditions:
|
|
11
|
-
*
|
|
12
|
-
* The above copyright notice and this permission notice shall be included in
|
|
13
|
-
* all copies or substantial portions of the Software.
|
|
14
|
-
*
|
|
15
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
* SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
25
|
-
import { createServer } from "./server.js";
|
|
26
|
-
|
|
27
|
-
const server = createServer();
|
|
28
|
-
const transport = new StdioServerTransport();
|
|
29
|
-
await server.connect(transport);
|
|
30
|
-
console.error("dap-mcp-server running on stdio");
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Ivan Iraci <ivan.iraci@professioneit.com>
|
|
3
|
-
*
|
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
* in the Software without restriction, including without limitation the rights
|
|
7
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
* furnished to do so, subject to the following conditions:
|
|
10
|
-
*
|
|
11
|
-
* The above copyright notice and this permission notice shall be included in
|
|
12
|
-
* all copies or substantial portions of the Software.
|
|
13
|
-
*
|
|
14
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
* SOFTWARE.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
import { describe, it, expect, afterEach } from "vitest";
|
|
24
|
-
import { DebugSession } from "../session/session.js";
|
|
25
|
-
import path from "node:path";
|
|
26
|
-
import { fileURLToPath } from "node:url";
|
|
27
|
-
|
|
28
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
29
|
-
const MOCK_ADAPTER = path.join(__dirname, "../test-fixtures/mock-adapter.js");
|
|
30
|
-
|
|
31
|
-
describe("Debug Lifecycle Integration", () => {
|
|
32
|
-
let session: DebugSession | undefined;
|
|
33
|
-
|
|
34
|
-
afterEach(async () => {
|
|
35
|
-
if (session && session.state !== "terminated") {
|
|
36
|
-
try { await session.disconnect(); } catch { /* ignore */ }
|
|
37
|
-
}
|
|
38
|
-
session = undefined;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("full debug lifecycle: launch, stop, inspect, step, evaluate, disconnect", async () => {
|
|
42
|
-
session = new DebugSession("integ-1", { type: "mock", runtime: "node", program: MOCK_ADAPTER });
|
|
43
|
-
|
|
44
|
-
// Initialize
|
|
45
|
-
const caps = await session.initialize();
|
|
46
|
-
expect(caps.supportsConfigurationDoneRequest).toBe(true);
|
|
47
|
-
expect(session.state).toBe("configuring");
|
|
48
|
-
|
|
49
|
-
// Send launch first (don't await — real adapters block until configurationDone)
|
|
50
|
-
const launchPromise = session.launch({ program: "/test/app.py", stopOnEntry: true });
|
|
51
|
-
|
|
52
|
-
// Set breakpoints while launch is pending
|
|
53
|
-
const bps = await session.setBreakpoints("/test/app.py", [{ line: 5 }, { line: 10 }]);
|
|
54
|
-
expect(bps).toHaveLength(2);
|
|
55
|
-
expect(bps[0].verified).toBe(true);
|
|
56
|
-
|
|
57
|
-
// Configuration done + await launch
|
|
58
|
-
await session.configurationDone();
|
|
59
|
-
await launchPromise;
|
|
60
|
-
|
|
61
|
-
// Wait for stopped on entry
|
|
62
|
-
const stoppedEvent = await session.waitForStopped(5000);
|
|
63
|
-
expect(stoppedEvent.body.reason).toBe("entry");
|
|
64
|
-
expect(session.state).toBe("stopped");
|
|
65
|
-
|
|
66
|
-
// Collect composite state
|
|
67
|
-
const state = await session.collectState(1, 10, 1);
|
|
68
|
-
expect(state.status).toBe("stopped");
|
|
69
|
-
expect(state.reason).toBe("entry");
|
|
70
|
-
expect(state.threads).toHaveLength(1);
|
|
71
|
-
expect(state.threads[0].name).toBe("MainThread");
|
|
72
|
-
expect(state.stackTrace.length).toBeGreaterThan(0);
|
|
73
|
-
expect(state.scopes.length).toBeGreaterThan(0);
|
|
74
|
-
|
|
75
|
-
// Check variables
|
|
76
|
-
const locals = state.scopes.find(s => s.name === "Locals");
|
|
77
|
-
expect(locals).toBeDefined();
|
|
78
|
-
expect(locals!.variables.some(v => v.name === "x" && v.value === "42")).toBe(true);
|
|
79
|
-
expect(locals!.variables.some(v => v.name === "name")).toBe(true);
|
|
80
|
-
|
|
81
|
-
// Step next
|
|
82
|
-
await session.next(1);
|
|
83
|
-
const stoppedAfterStep = await session.waitForStopped(5000);
|
|
84
|
-
expect(stoppedAfterStep.body.reason).toBe("step");
|
|
85
|
-
|
|
86
|
-
// Evaluate expression
|
|
87
|
-
const evalResult = await session.evaluate("x + 1", 1);
|
|
88
|
-
expect(evalResult.result).toBe("42");
|
|
89
|
-
|
|
90
|
-
// Continue
|
|
91
|
-
await session.continueExecution(1);
|
|
92
|
-
const stoppedAtBp = await session.waitForStopped(5000);
|
|
93
|
-
expect(stoppedAtBp.body.reason).toBe("breakpoint");
|
|
94
|
-
|
|
95
|
-
// Check output
|
|
96
|
-
const output = session.getOutput();
|
|
97
|
-
expect(output.output.some(o => o.text.includes("Program started"))).toBe(true);
|
|
98
|
-
|
|
99
|
-
// Disconnect
|
|
100
|
-
await session.disconnect();
|
|
101
|
-
expect(session.state).toBe("terminated");
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("returns nested children when collectState uses variableDepth > 1", async () => {
|
|
105
|
-
session = new DebugSession("integ-deep", { type: "mock", runtime: "node", program: MOCK_ADAPTER });
|
|
106
|
-
await session.initialize();
|
|
107
|
-
const launchPromise = session.launch({ program: "/test/app.py", stopOnEntry: true });
|
|
108
|
-
await session.configurationDone();
|
|
109
|
-
await launchPromise;
|
|
110
|
-
await session.waitForStopped(5000);
|
|
111
|
-
|
|
112
|
-
const state = await session.collectState(1, 10, 2);
|
|
113
|
-
const locals = state.scopes.find(s => s.name === "Locals");
|
|
114
|
-
const data = locals!.variables.find(v => v.name === "data");
|
|
115
|
-
expect(data).toBeDefined();
|
|
116
|
-
expect(data!.hasChildren).toBe(true);
|
|
117
|
-
expect(data!.children).toBeDefined();
|
|
118
|
-
expect(data!.children!.map(c => c.value)).toEqual(["1", "2", "3"]);
|
|
119
|
-
|
|
120
|
-
// Leaf variables should not get a children property.
|
|
121
|
-
const x = locals!.variables.find(v => v.name === "x");
|
|
122
|
-
expect(x!.children).toBeUndefined();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("handles adapter crash gracefully", async () => {
|
|
126
|
-
const crashAdapter = path.join(__dirname, "../test-fixtures/crash-adapter.js");
|
|
127
|
-
session = new DebugSession("integ-crash", { type: "mock", runtime: "node", program: crashAdapter });
|
|
128
|
-
await expect(session.initialize()).rejects.toThrow();
|
|
129
|
-
expect(session.state).toBe("terminated");
|
|
130
|
-
});
|
|
131
|
-
});
|