Skip to main content
Glama

replay

Replay recorded rr traces to debug Go programs using Delve MCP. Input the trace path and optionally specify a process ID to analyze specific execution sequences.

Instructions

Replay an rr trace

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
onProcessNoOptional PID to pass to rr
tracePathYesPath to the rr trace directory

Implementation Reference

  • Schema definition for the 'replay' tool, specifying input parameters tracePath (required) and onProcess (optional).
    { 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"] } },
  • src/server.ts:406-407 (registration)
    Tool call dispatch logic that routes 'replay' tool invocations to the handleDebugCommands function.
    if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args);
  • Core handler function for debug tools including 'replay'. Dispatches to startDebugSession based on tool name (specific case for 'replay' follows the pattern of other tools).
    export async function handleDebugCommands(name: string, args: any) { switch (name) { 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}` }] }; } case "attach": { const pid = Number(args?.pid); if (!pid) { throw new Error("Process ID is required"); } const session = await startDebugSession("attach", pid.toString()); return { content: [{ type: "text", text: `Attached to process ${pid} with session ${session.id}` }] }; } case "exec": { const binary = String(args?.binary); const cmdArgs = (args?.args as string[]) || []; const session = await startDebugSession("exec", binary, cmdArgs); return { content: [{ type: "text", text: `Started debug session ${session.id} for binary ${binary}` }] }; } case "test": { const pkg = (args?.package as string) || "."; const testFlags = (args?.testFlags as string[]) || []; const session = await startDebugSession("test", pkg, ["--", ...testFlags]); return { content: [{ type: "text", text: `Started test debug session ${session.id} for package ${pkg}` }] }; } case "core": { const { executable, corePath } = args; const session = await startDebugSession("core", executable, [corePath]); return { content: [{ type: "text", text: `Started core dump analysis session ${session.id} for ${executable} with core ${corePath}` }] }; } 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}` : ''}` }] }; } default: throw new Error("Unknown debug command"); }
  • Starts the Delve process for 'replay' type by spawning 'dlv replay --headless :port tracePath [args]', enabling the core tool execution.
    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; }
  • Type definition for DebugSession including 'replay' as a valid session type.
    type: string; // 'debug' | 'attach' | 'exec' | 'test' | 'core' | 'replay' | 'trace' | 'dap' target: string;

Other Tools

Related Tools

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