dap-mcp-server 0.1.10 → 0.1.12
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 +5 -2
- package/SKILL.md +175 -28
- package/TODO.md +32 -0
- package/build/adapters/builtin.js +27 -3
- package/build/adapters/builtin.js.map +1 -1
- package/build/dap/dap-client.d.ts +71 -4
- package/build/dap/dap-client.js +324 -53
- package/build/dap/dap-client.js.map +1 -1
- package/build/dap/types.d.ts +29 -7
- package/build/server.js +229 -34
- package/build/server.js.map +1 -1
- package/build/session/inspect.d.ts +64 -0
- package/build/session/inspect.js +116 -0
- package/build/session/inspect.js.map +1 -0
- package/build/session/run.d.ts +52 -0
- package/build/session/run.js +111 -0
- package/build/session/run.js.map +1 -0
- package/build/session/session.d.ts +8 -9
- package/build/session/session.js +67 -9
- package/build/session/session.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/builtin.ts +28 -3
- package/src/adapters/registry.test.ts +3 -2
- package/src/dap/dap-client.test.ts +31 -0
- package/src/dap/dap-client.ts +402 -52
- package/src/dap/types.ts +30 -7
- package/src/integration/debug-lifecycle.test.ts +21 -0
- package/src/server.ts +254 -34
- package/src/session/inspect.test.ts +126 -0
- package/src/session/inspect.ts +160 -0
- package/src/session/run.test.ts +74 -0
- package/src/session/run.ts +144 -0
- package/src/session/session.test.ts +42 -0
- package/src/session/session.ts +68 -21
- package/src/test-fixtures/mock-adapter.js +23 -1
- package/src/test-fixtures/no-stop-adapter.js +77 -0
- package/src/test-fixtures/tcp-mock-adapter.js +87 -0
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
// Mock adapter that completes the DAP handshake but never emits stopped events.
|
|
24
|
+
// Used to test client behavior when a breakpoint is never hit (e.g. timeout paths).
|
|
25
|
+
|
|
26
|
+
const TWO_CRLF = "\r\n\r\n";
|
|
27
|
+
let buffer = Buffer.alloc(0);
|
|
28
|
+
let contentLength = -1;
|
|
29
|
+
|
|
30
|
+
process.stdin.on("data", (chunk) => {
|
|
31
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
32
|
+
while (true) {
|
|
33
|
+
if (contentLength === -1) {
|
|
34
|
+
const idx = buffer.indexOf(TWO_CRLF);
|
|
35
|
+
if (idx === -1) return;
|
|
36
|
+
const header = buffer.subarray(0, idx).toString();
|
|
37
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
38
|
+
if (!match) return;
|
|
39
|
+
contentLength = parseInt(match[1], 10);
|
|
40
|
+
buffer = buffer.subarray(idx + TWO_CRLF.length);
|
|
41
|
+
}
|
|
42
|
+
if (buffer.length < contentLength) return;
|
|
43
|
+
const body = buffer.subarray(0, contentLength).toString();
|
|
44
|
+
buffer = buffer.subarray(contentLength);
|
|
45
|
+
contentLength = -1;
|
|
46
|
+
handleMessage(JSON.parse(body));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function send(msg) {
|
|
51
|
+
const json = JSON.stringify(msg);
|
|
52
|
+
const header = `Content-Length: ${Buffer.byteLength(json)}${TWO_CRLF}`;
|
|
53
|
+
process.stdout.write(header + json);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let seq = 1;
|
|
57
|
+
|
|
58
|
+
function handleMessage(msg) {
|
|
59
|
+
if (msg.type !== "request") return;
|
|
60
|
+
switch (msg.command) {
|
|
61
|
+
case "initialize":
|
|
62
|
+
send({ seq: seq++, type: "response", request_seq: msg.seq, command: "initialize", success: true,
|
|
63
|
+
body: { supportsConfigurationDoneRequest: true } });
|
|
64
|
+
send({ seq: seq++, type: "event", event: "initialized", body: {} });
|
|
65
|
+
break;
|
|
66
|
+
case "setBreakpoints":
|
|
67
|
+
send({ seq: seq++, type: "response", request_seq: msg.seq, command: "setBreakpoints", success: true,
|
|
68
|
+
body: { breakpoints: (msg.arguments.breakpoints || []).map((bp, i) => ({ id: i+1, verified: true, line: bp.line })) } });
|
|
69
|
+
break;
|
|
70
|
+
case "disconnect":
|
|
71
|
+
send({ seq: seq++, type: "response", request_seq: msg.seq, command: "disconnect", success: true, body: {} });
|
|
72
|
+
setTimeout(() => process.exit(0), 20);
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
send({ seq: seq++, type: "response", request_seq: msg.seq, command: msg.command, success: true, body: {} });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
// TCP-mode mock DAP adapter for testing the TCP transport.
|
|
24
|
+
// Opens a TCP listener on a random port, prints the listen address banner to
|
|
25
|
+
// stdout (matching the regex "DAP server listening at: \S+:(\d+)"), accepts a
|
|
26
|
+
// single client connection, and runs a tiny DAP server on it.
|
|
27
|
+
|
|
28
|
+
import net from "node:net";
|
|
29
|
+
|
|
30
|
+
const TWO_CRLF = "\r\n\r\n";
|
|
31
|
+
|
|
32
|
+
const server = net.createServer((socket) => {
|
|
33
|
+
let buffer = Buffer.alloc(0);
|
|
34
|
+
let contentLength = -1;
|
|
35
|
+
let seq = 1;
|
|
36
|
+
|
|
37
|
+
const send = (msg) => {
|
|
38
|
+
const json = JSON.stringify(msg);
|
|
39
|
+
const header = `Content-Length: ${Buffer.byteLength(json)}${TWO_CRLF}`;
|
|
40
|
+
socket.write(header + json);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
socket.on("data", (chunk) => {
|
|
44
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
45
|
+
while (true) {
|
|
46
|
+
if (contentLength === -1) {
|
|
47
|
+
const idx = buffer.indexOf(TWO_CRLF);
|
|
48
|
+
if (idx === -1) return;
|
|
49
|
+
const header = buffer.subarray(0, idx).toString();
|
|
50
|
+
const match = header.match(/Content-Length:\s*(\d+)/i);
|
|
51
|
+
if (!match) return;
|
|
52
|
+
contentLength = parseInt(match[1], 10);
|
|
53
|
+
buffer = buffer.subarray(idx + TWO_CRLF.length);
|
|
54
|
+
}
|
|
55
|
+
if (buffer.length < contentLength) return;
|
|
56
|
+
const body = buffer.subarray(0, contentLength).toString();
|
|
57
|
+
buffer = buffer.subarray(contentLength);
|
|
58
|
+
contentLength = -1;
|
|
59
|
+
const msg = JSON.parse(body);
|
|
60
|
+
if (msg.type === "request" && msg.command === "initialize") {
|
|
61
|
+
send({
|
|
62
|
+
seq: seq++,
|
|
63
|
+
type: "response",
|
|
64
|
+
request_seq: msg.seq,
|
|
65
|
+
command: msg.command,
|
|
66
|
+
success: true,
|
|
67
|
+
body: { supportsConfigurationDoneRequest: true },
|
|
68
|
+
});
|
|
69
|
+
send({ seq: seq++, type: "event", event: "initialized" });
|
|
70
|
+
} else if (msg.type === "request") {
|
|
71
|
+
send({
|
|
72
|
+
seq: seq++,
|
|
73
|
+
type: "response",
|
|
74
|
+
request_seq: msg.seq,
|
|
75
|
+
command: msg.command,
|
|
76
|
+
success: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
server.listen(0, "127.0.0.1", () => {
|
|
84
|
+
const { address, port } = server.address();
|
|
85
|
+
// Print the listen banner in the same shape delve uses.
|
|
86
|
+
process.stdout.write(`DAP server listening at: ${address}:${port}\n`);
|
|
87
|
+
});
|