debug
Debug Go packages by starting the Delve debugger to trace and analyze code execution, with options for specifying packages and build flags.
Instructions
Start debugging a Go package
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package | No | Package to debug (defaults to current directory) | |
| buildFlags | No | Build flags to pass to the compiler |
Implementation Reference
- src/handlers/debug.ts:8-24 (handler)Core handler logic for the 'debug' tool: parses arguments, starts a Delve debug session for the specified Go package, and returns session info.case "debug": { const pkg = (args?.package as string) || "."; const buildFlags = args?.buildFlags as string | undefined; const cmdArgs: string[] = []; if (buildFlags) { cmdArgs.push("--build-flags", buildFlags); } const session = await startDebugSession("debug", pkg, cmdArgs); return { content: [{ type: "text", text: `Started debug session ${session.id} for package ${pkg}` }] }; }
- src/server.ts:68-84 (schema)Tool schema registration for 'debug': defines name, description, and input schema with optional 'package' and 'buildFlags' parameters.{ name: "debug", description: "Start debugging a Go package", inputSchema: { type: "object", properties: { package: { type: "string", description: "Package to debug (defaults to current directory)" }, buildFlags: { type: "string", description: "Build flags to pass to the compiler" } } } },
- src/server.ts:406-408 (registration)MCP CallToolRequest handler that registers and routes the 'debug' tool invocation to handleDebugCommands.if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args); }
- src/types.ts:16-25 (helper)Type definition for DebugSession used by the 'debug' tool implementation.export interface DebugSession { id: string; type: string; // 'debug' | 'attach' | 'exec' | 'test' | 'core' | 'replay' | 'trace' | 'dap' target: string; process?: ChildProcess; port: number; breakpoints: Map<number, Breakpoint>; logOutput?: string[]; backend?: string; }