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.
Files changed (58) hide show
  1. package/README.md +25 -7
  2. package/SKILL.md +37 -186
  3. package/build/adapters/detect.d.ts +12 -0
  4. package/build/adapters/detect.js +91 -0
  5. package/build/adapters/detect.js.map +1 -1
  6. package/build/adapters/registry.js +35 -12
  7. package/build/adapters/registry.js.map +1 -1
  8. package/build/diagnostics/doctor.d.ts +64 -0
  9. package/build/diagnostics/doctor.js +209 -0
  10. package/build/diagnostics/doctor.js.map +1 -0
  11. package/build/server.js +305 -83
  12. package/build/server.js.map +1 -1
  13. package/build/session/inspect.d.ts +6 -2
  14. package/build/session/inspect.js +24 -8
  15. package/build/session/inspect.js.map +1 -1
  16. package/build/session/run.js +2 -9
  17. package/build/session/run.js.map +1 -1
  18. package/build/session/session.d.ts +16 -0
  19. package/build/session/session.js +63 -8
  20. package/build/session/session.js.map +1 -1
  21. package/integrations/claude/dap-debugging/.claude-plugin/plugin.json +9 -0
  22. package/integrations/claude/dap-debugging/.mcp.json +8 -0
  23. package/integrations/claude/dap-debugging/skills/dap-debugging/SKILL.md +49 -0
  24. package/package.json +8 -3
  25. package/.forgejo/workflows/publish.yml +0 -63
  26. package/CLAUDE.md +0 -71
  27. package/TODO.md +0 -32
  28. package/docs/plans/2026-03-05-dap-wrapper-mcp-design.md +0 -326
  29. package/docs/plans/2026-03-05-dap-wrapper-mcp-implementation.md +0 -2815
  30. package/src/adapters/builtin.ts +0 -75
  31. package/src/adapters/detect.test.ts +0 -36
  32. package/src/adapters/detect.ts +0 -36
  33. package/src/adapters/registry.test.ts +0 -74
  34. package/src/adapters/registry.ts +0 -86
  35. package/src/dap/dap-client.test.ts +0 -118
  36. package/src/dap/dap-client.ts +0 -588
  37. package/src/dap/protocol.test.ts +0 -82
  38. package/src/dap/protocol.ts +0 -78
  39. package/src/dap/ring-buffer.test.ts +0 -82
  40. package/src/dap/ring-buffer.ts +0 -64
  41. package/src/dap/types.ts +0 -115
  42. package/src/index.ts +0 -30
  43. package/src/integration/debug-lifecycle.test.ts +0 -131
  44. package/src/server.ts +0 -1096
  45. package/src/session/inspect.test.ts +0 -126
  46. package/src/session/inspect.ts +0 -160
  47. package/src/session/run.test.ts +0 -74
  48. package/src/session/run.ts +0 -144
  49. package/src/session/session-manager.test.ts +0 -74
  50. package/src/session/session-manager.ts +0 -67
  51. package/src/session/session.test.ts +0 -126
  52. package/src/session/session.ts +0 -482
  53. package/src/test-fixtures/crash-adapter.js +0 -23
  54. package/src/test-fixtures/mock-adapter.js +0 -164
  55. package/src/test-fixtures/no-stop-adapter.js +0 -77
  56. package/src/test-fixtures/silent-adapter.js +0 -24
  57. package/src/test-fixtures/tcp-mock-adapter.js +0 -87
  58. package/tsconfig.json +0 -16
@@ -1,75 +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 { AdapterConfig } from "../dap/types.js";
24
-
25
- export const BUILTIN_ADAPTERS: AdapterConfig[] = [
26
- {
27
- type: "python",
28
- runtime: "python3",
29
- program: "-m",
30
- args: ["debugpy.adapter"],
31
- launchDefaults: {
32
- console: "internalConsole",
33
- },
34
- installHint: "pip install debugpy",
35
- },
36
- {
37
- type: "go",
38
- program: "dlv",
39
- args: ["dap", "--listen=127.0.0.1:0"],
40
- transport: "tcp",
41
- // Matches: "DAP server listening at: 127.0.0.1:38251"
42
- portMatcher: "DAP server listening at:\\s*\\S+:(\\d+)",
43
- installHint: "go install github.com/go-delve/delve/cmd/dlv@latest",
44
- },
45
- // node adapter: vscode-js-debug's dapDebugServer.js. The user must install
46
- // it (no universal path); the registry's availability check will mark this
47
- // unavailable when the program is missing.
48
- {
49
- type: "node",
50
- runtime: "node",
51
- program: "dapDebugServer.js",
52
- // Bind to IPv4 explicitly; the default is IPv6 ('::1') which our client
53
- // (which connects to 127.0.0.1) can't reach on systems without v4↔v6
54
- // bridging.
55
- args: ["0", "127.0.0.1"],
56
- transport: "tcp",
57
- // Matches: "Debug server listening at 127.0.0.1:38251" (vscode-js-debug)
58
- portMatcher: "[Ll]istening at\\s*\\S*?:(\\d+)",
59
- // vscode-js-debug requires these in the launch request; pwa-node is the
60
- // "production worker agent" Node launcher.
61
- launchDefaults: {
62
- type: "pwa-node",
63
- request: "launch",
64
- },
65
- installHint:
66
- "Install vscode-js-debug DAP server and set the adapter's `program` to its dapDebugServer.js path " +
67
- "(e.g. via `configure_adapter`). See https://github.com/microsoft/vscode-js-debug.",
68
- },
69
- {
70
- type: "cppdbg",
71
- program: "lldb-dap",
72
- args: [],
73
- installHint: "apt install lldb (Debian/Ubuntu) or brew install llvm (macOS)",
74
- },
75
- ];
@@ -1,36 +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 { checkAdapterAvailable } from "./detect.js";
25
-
26
- describe("checkAdapterAvailable", () => {
27
- it("detects 'node' as available", async () => {
28
- const result = await checkAdapterAvailable("node");
29
- expect(result).toBe(true);
30
- });
31
-
32
- it("detects non-existent binary as unavailable", async () => {
33
- const result = await checkAdapterAvailable("definitely-not-a-real-binary-xyz");
34
- expect(result).toBe(false);
35
- });
36
- });
@@ -1,36 +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 { execFile } from "node:child_process";
24
- import { promisify } from "node:util";
25
-
26
- const execFileAsync = promisify(execFile);
27
-
28
- export async function checkAdapterAvailable(command: string): Promise<boolean> {
29
- try {
30
- const whichCmd = process.platform === "win32" ? "where" : "which";
31
- await execFileAsync(whichCmd, [command]);
32
- return true;
33
- } catch {
34
- return false;
35
- }
36
- }
@@ -1,74 +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, beforeEach, afterEach } from "vitest";
24
- import { AdapterRegistry } from "./registry.js";
25
- import fs from "node:fs/promises";
26
- import os from "node:os";
27
- import path from "node:path";
28
-
29
- describe("AdapterRegistry", () => {
30
- let tmpDir: string;
31
- let registry: AdapterRegistry;
32
-
33
- beforeEach(async () => {
34
- tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "dap-mcp-test-"));
35
- registry = new AdapterRegistry(tmpDir, tmpDir);
36
- });
37
-
38
- afterEach(async () => {
39
- await fs.rm(tmpDir, { recursive: true, force: true });
40
- });
41
-
42
- it("returns built-in adapters", () => {
43
- const adapters = registry.listAll();
44
- expect(adapters.some((a) => a.type === "python")).toBe(true);
45
- expect(adapters.some((a) => a.type === "go")).toBe(true);
46
- // node adapter now points at vscode-js-debug's dapDebugServer.js via TCP.
47
- // The user must install/configure it; the registry just publishes the entry.
48
- expect(adapters.some((a) => a.type === "node")).toBe(true);
49
- });
50
-
51
- it("registers a custom adapter", () => {
52
- registry.register({ type: "ruby", program: "/usr/bin/rdbg", args: ["--open", "--dap"] });
53
- const ruby = registry.get("ruby");
54
- expect(ruby).toBeDefined();
55
- expect(ruby!.program).toBe("/usr/bin/rdbg");
56
- });
57
-
58
- it("project-local overrides built-in", () => {
59
- registry.register({ type: "python", program: "/custom/debugpy" });
60
- const python = registry.get("python");
61
- expect(python!.program).toBe("/custom/debugpy");
62
- });
63
-
64
- it("saves and loads config from disk", async () => {
65
- registry.register({ type: "ruby", program: "/usr/bin/rdbg" });
66
- await registry.save("project");
67
-
68
- const registry2 = new AdapterRegistry(tmpDir, tmpDir);
69
- await registry2.load();
70
- const ruby = registry2.get("ruby");
71
- expect(ruby).toBeDefined();
72
- expect(ruby!.program).toBe("/usr/bin/rdbg");
73
- });
74
- });
@@ -1,86 +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 { AdapterConfig } from "../dap/types.js";
24
- import { BUILTIN_ADAPTERS } from "./builtin.js";
25
- import fs from "node:fs/promises";
26
- import path from "node:path";
27
-
28
- export class AdapterRegistry {
29
- private builtins: Map<string, AdapterConfig>;
30
- private global: Map<string, AdapterConfig> = new Map();
31
- private project: Map<string, AdapterConfig> = new Map();
32
- private globalDir: string;
33
- private projectDir: string;
34
-
35
- constructor(globalDir: string, projectDir: string) {
36
- this.globalDir = globalDir;
37
- this.projectDir = projectDir;
38
- this.builtins = new Map(BUILTIN_ADAPTERS.map((a) => [a.type, a]));
39
- }
40
-
41
- get(type: string): AdapterConfig | undefined {
42
- return this.project.get(type) ?? this.global.get(type) ?? this.builtins.get(type);
43
- }
44
-
45
- register(config: AdapterConfig, scope: "global" | "project" = "project"): void {
46
- const map = scope === "global" ? this.global : this.project;
47
- map.set(config.type, config);
48
- }
49
-
50
- listAll(): Array<AdapterConfig & { source: "builtin" | "global" | "project" }> {
51
- const result = new Map<string, AdapterConfig & { source: "builtin" | "global" | "project" }>();
52
- for (const [type, config] of this.builtins) {
53
- result.set(type, { ...config, source: "builtin" });
54
- }
55
- for (const [type, config] of this.global) {
56
- result.set(type, { ...config, source: "global" });
57
- }
58
- for (const [type, config] of this.project) {
59
- result.set(type, { ...config, source: "project" });
60
- }
61
- return Array.from(result.values());
62
- }
63
-
64
- async load(): Promise<void> {
65
- this.global = await this.loadFile(path.join(this.globalDir, "adapters.json"));
66
- this.project = await this.loadFile(path.join(this.projectDir, "adapters.json"));
67
- }
68
-
69
- async save(scope: "global" | "project"): Promise<void> {
70
- const dir = scope === "global" ? this.globalDir : this.projectDir;
71
- const map = scope === "global" ? this.global : this.project;
72
- await fs.mkdir(dir, { recursive: true });
73
- const data = Object.fromEntries(map);
74
- await fs.writeFile(path.join(dir, "adapters.json"), JSON.stringify(data, null, 2));
75
- }
76
-
77
- private async loadFile(filePath: string): Promise<Map<string, AdapterConfig>> {
78
- try {
79
- const data = await fs.readFile(filePath, "utf-8");
80
- const parsed = JSON.parse(data) as Record<string, AdapterConfig>;
81
- return new Map(Object.entries(parsed));
82
- } catch {
83
- return new Map();
84
- }
85
- }
86
- }
@@ -1,118 +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 { DAPClient, DAPClientError } from "./dap-client.js";
25
- import path from "node:path";
26
- import { fileURLToPath } from "node:url";
27
-
28
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
29
-
30
- describe("DAPClient", () => {
31
- let client: DAPClient | undefined;
32
-
33
- afterEach(async () => {
34
- if (client) {
35
- try { await client.dispose(); } catch { /* ignore */ }
36
- client = undefined;
37
- }
38
- });
39
-
40
- it("spawns adapter and sends initialize request", async () => {
41
- client = new DAPClient("node", path.join(__dirname, "../test-fixtures/mock-adapter.js"));
42
- await client.spawn();
43
- const response = await client.sendRequest("initialize", {
44
- adapterID: "test",
45
- linesStartAt1: true,
46
- columnsStartAt1: true,
47
- pathFormat: "path",
48
- });
49
- expect(response.success).toBe(true);
50
- expect(response.command).toBe("initialize");
51
- });
52
-
53
- it("receives events from adapter", async () => {
54
- client = new DAPClient("node", path.join(__dirname, "../test-fixtures/mock-adapter.js"));
55
- await client.spawn();
56
-
57
- const eventPromise = new Promise<any>((resolve) => {
58
- client!.on("initialized", resolve);
59
- });
60
-
61
- await client.sendRequest("initialize", {
62
- adapterID: "test",
63
- linesStartAt1: true,
64
- columnsStartAt1: true,
65
- pathFormat: "path",
66
- });
67
-
68
- const event = await eventPromise;
69
- expect(event.event).toBe("initialized");
70
- });
71
-
72
- it("rejects on adapter exit during request", async () => {
73
- client = new DAPClient("node", path.join(__dirname, "../test-fixtures/crash-adapter.js"));
74
- await client.spawn();
75
- await expect(
76
- client.sendRequest("initialize", { adapterID: "test" })
77
- ).rejects.toThrow();
78
- });
79
-
80
- it("times out if adapter does not respond", async () => {
81
- client = new DAPClient("node", path.join(__dirname, "../test-fixtures/silent-adapter.js"));
82
- await client.spawn();
83
- await expect(
84
- client.sendRequest("initialize", { adapterID: "test" }, 500)
85
- ).rejects.toThrow(/timeout/i);
86
- });
87
-
88
- it("speaks DAP over TCP when configured", async () => {
89
- client = new DAPClient(
90
- "node",
91
- path.join(__dirname, "../test-fixtures/tcp-mock-adapter.js"),
92
- [],
93
- {
94
- transport: "tcp",
95
- portMatcher: "DAP server listening at:\\s*\\S+:(\\d+)",
96
- tcpConnectTimeout: 3000,
97
- }
98
- );
99
- await client.spawn();
100
- const response = await client.sendRequest("initialize", {
101
- adapterID: "test",
102
- linesStartAt1: true,
103
- columnsStartAt1: true,
104
- pathFormat: "path",
105
- });
106
- expect(response.success).toBe(true);
107
- expect(response.command).toBe("initialize");
108
- });
109
-
110
- it("rejects TCP transport without a portMatcher", () => {
111
- expect(
112
- () =>
113
- new DAPClient("node", "irrelevant.js", [], {
114
- transport: "tcp",
115
- })
116
- ).toThrow(DAPClientError);
117
- });
118
- });