attach
Connect to a running Go process by specifying its Process ID to enable debugging operations through the Delve debugger interface.
Instructions
Attach to a running process
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | Yes | Process ID to attach to |
Implementation Reference
- src/handlers/debug.ts:26-39 (handler)The core handler logic for the 'attach' tool. It validates the 'pid' argument, calls startDebugSession to attach to the process, and returns a confirmation message with the session ID.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}` }] }; }
- src/server.ts:86-98 (registration)Tool registration entry for 'attach', defining the tool name, description, and input schema (requiring a numeric 'pid').name: "attach", description: "Attach to a running process", inputSchema: { type: "object", properties: { pid: { type: "number", description: "Process ID to attach to" } }, required: ["pid"] } },
- src/server.ts:406-408 (registration)Routing logic in the main request handler that dispatches 'attach' tool calls to handleDebugCommands in debug.ts.if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) { return handleDebugCommands(name, args); }
- src/types.ts:18-19 (schema)Type definition for DebugSession 'type' field that includes 'attach' as a valid mode.type: string; // 'debug' | 'attach' | 'exec' | 'test' | 'core' | 'replay' | 'trace' | 'dap' target: string;