dap
Initiate a DAP server to connect with clients for debugging Go programs via the Delve debugger, enabling code analysis and tracing using natural language commands.
Instructions
Start a DAP (Debug Adapter Protocol) server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientAddr | No | Optional address where DAP client is waiting for connection |
Implementation Reference
- src/handlers/debug.ts:78-89 (handler)The main handler logic for the 'dap' tool. Extracts optional clientAddr, prepares dlv args, starts DAP session via startDebugSession, returns session info.case "dap": { const { clientAddr } = args; const cmdArgs = clientAddr ? ["--client-addr", clientAddr] : []; const session = await startDebugSession("dap", "", cmdArgs); return { content: [{ type: "text", text: `Started DAP server session ${session.id}${clientAddr ? ` connecting to ${clientAddr}` : ''}` }] }; }
- src/server.ts:288-300 (schema)Input schema and metadata definition for the 'dap' tool in the tools list.{ name: "dap", description: "Start a DAP (Debug Adapter Protocol) server", inputSchema: { type: "object", properties: { clientAddr: { type: "string", description: "Optional address where DAP client is waiting for connection" } } } },
- src/server.ts:406-407 (registration)Dispatches 'dap' tool invocations to the debug handler in the CallToolRequestSchema handler.if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args);
- src/session.ts:35-64 (helper)Core utility that starts the dlv process in 'dap' mode when called with type='dap', binding to a dynamic port and registering the session.export async function startDebugSession(type: string, target: string, args: string[] = []): Promise<DebugSession> { const port = await getAvailablePort(); const id = Math.random().toString(36).substring(7); const dlvArgs = [ type, "--headless", `--listen=:${port}`, "--accept-multiclient", "--api-version=2", target, ...args ]; const process = spawn("dlv", dlvArgs, { stdio: ["pipe", "pipe", "pipe"] }); const session: DebugSession = { id, type, target, process, port, breakpoints: new Map() }; sessions.set(id, session); return session; }
- src/types.ts:18-18 (schema)Type definition for DebugSession.type including 'dap'.type: string; // 'debug' | 'attach' | 'exec' | 'test' | 'core' | 'replay' | 'trace' | 'dap'