Skip to main content
Glama

attach

Attach to a running process by providing its process ID to enable debugging with Delve.

Instructions

Attach to a running process

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pidYesProcess ID to attach to

Implementation Reference

  • The handler for the 'attach' tool. Extracts the PID from arguments, validates it, then starts a debug session of type 'attach' with the PID.
    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:399-421 (registration)
    The CallToolRequestSchema handler that routes the 'attach' tool name to handleDebugCommands.
    /**
     * Handler for debug tools
     */
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      // Debug commands
      if (["debug", "attach", "exec", "test", "core", "dap", "replay", "trace"].includes(name)) {
        return handleDebugCommands(name, args);
      }
    
      // Control commands
      if (["setBreakpoint", "removeBreakpoint", "continue", "next", "step", "stepout", "variables", "evaluate"].includes(name)) {
        return handleControlCommands(name, args);
      }
    
      // Configuration commands
      if (["setBackend", "configureLogging", "version"].includes(name)) {
        return handleConfigCommands(name, args);
      }
    
      throw new Error("Unknown tool");
    });
  • src/server.ts:85-98 (registration)
    Tool registration with name 'attach', description 'Attach to a running process', and input schema requiring a 'pid' (number).
    {
      name: "attach",
      description: "Attach to a running process",
      inputSchema: {
        type: "object",
        properties: {
          pid: {
            type: "number",
            description: "Process ID to attach to"
          }
        },
        required: ["pid"]
      }
    },
  • The startDebugSession function that spawns a 'dlv' process with the given type (e.g., 'attach'), target (PID), and arguments.
    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;
    }
  • The DebugSession interface where the 'type' property can be 'attach' among other debug session types.
    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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description is too brief. It does not disclose effects like suspending the process, debugging capabilities, or permission requirements. For a tool that modifies process state, more detail is needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short (6 words), which is concise but at the expense of needed detail. It is front-loaded but overall feels incomplete for a debugger attach action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (1 required param, no output schema, no annotations), the description is insufficient. Missing info on side effects, detaching, or interaction with other debug tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema fully describes the single parameter 'pid' with a clear description. The tool description adds no extra meaning, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'attach' and the resource 'running process', indicating it connects a debugger to an existing process. However, it does not differentiate from sibling debugging tools like 'debug' or 'exec'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. The description lacks context about prerequisites or scenarios (e.g., should the process be stopped? what if already attached?).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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