Skip to main content
Glama

debug

Start debugging a Go package. Specify the package path and optional build flags.

Instructions

Start debugging a Go package

Input Schema

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

Implementation Reference

  • The handleDebugCommands function in src/handlers/debug.ts handles the 'debug' tool (and other debug session commands). The 'debug' case (lines 8-24) starts a debug session for a Go package using startDebugSession.
    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}`
            }]
          };
        }
  • The input schema for the 'debug' tool is defined in the ListToolsRequestSchema handler in src/server.ts, lines 69-84. It defines a tool named 'debug' with optional 'package' and 'buildFlags' string 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:402-408 (registration)
    The 'debug' tool is registered via the CallToolRequestSchema handler in src/server.ts. Line 406 checks if the tool name is 'debug' (among others) and routes to handleDebugCommands.
    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);
      }
  • The startDebugSession function in src/session.ts is a helper that spawns a dlv process in headless mode and creates a DebugSession object. It is used by the 'debug' handler.
    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 in src/types.ts defines the structure used for debug sessions, including the type field which can be 'debug'.
    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?

The description does not disclose any behavioral traits beyond the action. With no annotations, the agent learns nothing about side effects (e.g., starting a debug session, compiling), required permissions, or error states. This is insufficient for a tool that likely has significant side effects.

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

Conciseness4/5

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

The description is extremely concise at five words, effectively conveying the core purpose. However, it may be too brief to provide necessary context, balancing conciseness against completeness.

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 complexity of a debugging tool with no output schema and no annotations, the description is incomplete. It fails to explain what happens after execution (e.g., session start), return values, or state changes, leaving significant gaps for the agent.

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?

Schema coverage is 100% with descriptions for both parameters. The description adds no additional meaning beyond what the schema provides, so baseline score 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 'Start debugging a Go package' clearly identifies the action (start) and resource (debugging a Go package). It is distinguishable from sibling tools like 'continue' or 'step' which are subsequent actions. However, it does not differentiate from 'attach' which also initiates debugging but for an external process, leaving some ambiguity.

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 is provided on when to use this tool versus alternatives like 'attach' or 'test'. There is no mention of prerequisites or contexts where it should not be used, leaving the agent without decision support.

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