Skip to main content
Glama

debug

Debug Go packages by specifying the target package and build flags. Integrates with Delve MCP server for efficient debugging, tracing, and analysis of Go code using natural language commands.

Instructions

Start debugging a Go package

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
buildFlagsNoBuild flags to pass to the compiler
packageNoPackage to debug (defaults to current directory)

Implementation Reference

  • Core handler logic for the 'debug' tool: parses arguments, constructs Delve command args, starts a debug session via startDebugSession, and returns success message with session ID.
    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}` }] }; }
  • Input schema definition for the 'debug' tool as returned in ListTools response.
    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)
    Dispatch logic in CallToolRequestSchema handler that routes 'debug' tool invocations to the handleDebugCommands function.
    if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args); }
  • src/server.ts:64-397 (registration)
    ListToolsRequestSchema handler that registers/returns the 'debug' tool in the tools list (excerpt abbreviated).
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ // Debug tools { 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" } } } }, { name: "attach", description: "Attach to a running process", inputSchema: { type: "object", properties: { pid: { type: "number", description: "Process ID to attach to" } }, required: ["pid"] } }, { name: "exec", description: "Debug a precompiled binary", inputSchema: { type: "object", properties: { binary: { type: "string", description: "Path to the binary" }, args: { type: "array", items: { type: "string" }, description: "Arguments to pass to the binary" } }, required: ["binary"] } }, { name: "test", description: "Debug tests in a package", inputSchema: { type: "object", properties: { package: { type: "string", description: "Package to test (defaults to current directory)" }, testFlags: { type: "array", items: { type: "string" }, description: "Flags to pass to go test" } } } }, // Control tools { name: "setBreakpoint", description: "Set a breakpoint in the debugged program", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" }, file: { type: "string", description: "File path where to set the breakpoint" }, line: { type: "number", description: "Line number for the breakpoint" }, condition: { type: "string", description: "Optional condition for the breakpoint" } }, required: ["sessionId", "file", "line"] } }, { name: "removeBreakpoint", description: "Remove a breakpoint", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" }, breakpointId: { type: "number", description: "ID of the breakpoint to remove" } }, required: ["sessionId", "breakpointId"] } }, { name: "continue", description: "Continue program execution", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "next", description: "Step over to next line", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "step", description: "Step into function call", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "stepout", description: "Step out of current function", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "variables", description: "List local variables in current scope", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" } }, required: ["sessionId"] } }, { name: "evaluate", description: "Evaluate an expression in current scope", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the debug session" }, expr: { type: "string", description: "Expression to evaluate" } }, required: ["sessionId", "expr"] } }, // Advanced debug tools { name: "core", description: "Examine a core dump", inputSchema: { type: "object", properties: { executable: { type: "string", description: "Path to the executable that produced the core dump" }, corePath: { type: "string", description: "Path to the core dump file" } }, required: ["executable", "corePath"] } }, { 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" } } } }, { name: "replay", description: "Replay an rr trace", inputSchema: { type: "object", properties: { tracePath: { type: "string", description: "Path to the rr trace directory" }, onProcess: { type: "number", description: "Optional PID to pass to rr" } }, required: ["tracePath"] } }, { name: "trace", description: "Trace program execution", inputSchema: { type: "object", properties: { regexp: { type: "string", description: "Regular expression to match functions to trace" }, pkg: { type: "string", description: "Package to trace (defaults to .)" }, ebpf: { type: "boolean", description: "Use eBPF for tracing (experimental)" }, stack: { type: "number", description: "Show stack trace with given depth" }, pid: { type: "number", description: "Pid to attach to" } }, required: ["regexp"] } }, // Configuration tools { name: "version", description: "Get Delve version information", inputSchema: { type: "object", properties: {} } }, { name: "setBackend", description: "Set the backend for debugging", inputSchema: { type: "object", properties: { backend: { type: "string", description: "Backend to use (default, native, lldb, or rr)", enum: ["default", "native", "lldb", "rr"] } }, required: ["backend"] } }, { name: "configureLogging", description: "Configure debug logging", inputSchema: { type: "object", properties: { components: { type: "array", items: { type: "string", enum: ["debugger", "gdbwire", "lldbout", "debuglineerr", "rpc", "dap", "fncall", "minidump", "stack"] }, description: "Components to enable logging for" }, destination: { type: "string", description: "Log destination (file path or file descriptor)" } }, required: ["components"] } } ] }; });
  • Import of startDebugSession helper used by the 'debug' handler.
    import { sessions, startDebugSession, sendDelveCommand } from '../session.js';

Other Tools

Related Tools

  • @dwisiswant0/delve-mcp
  • @dwisiswant0/delve-mcp
  • @dwisiswant0/delve-mcp
  • @dwisiswant0/delve-mcp
  • @dwisiswant0/delve-mcp
  • @dwisiswant0/delve-mcp

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dwisiswant0/delve-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server