Skip to main content
Glama

lldb_examine_variables

Read-onlyIdempotent

Inspect local variables and function arguments at a breakpoint in C/C++ programs to debug code execution and analyze program state.

Instructions

Examine local variables and arguments at a breakpoint.

Runs the program until the specified breakpoint, then displays
the values of local variables and function arguments.

Args:
    params: ExamineVariablesInput with executable, breakpoint, and optional variable names

Returns:
    str: Variable values at the breakpoint

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async handler function implementing the core logic of the lldb_examine_variables tool. It constructs LLDB commands to set a breakpoint, run the program, examine variables, and formats the output as Markdown or JSON.
    async def lldb_examine_variables(params: ExamineVariablesInput) -> str:
        """Examine local variables and arguments at a breakpoint.
    
        Runs the program until the specified breakpoint, then displays
        the values of local variables and function arguments.
    
        Args:
            params: ExamineVariablesInput with executable, breakpoint, and optional variable names
    
        Returns:
            str: Variable values at the breakpoint
        """
        commands = [
            f"target create {params.executable}",
            f"breakpoint set --name {params.breakpoint}",
            "run" + (" " + " ".join(params.args) if params.args else ""),
        ]
    
        if params.variables:
            for var in params.variables:
                commands.append(f"frame variable {var}")
        else:
            commands.append("frame variable")
    
        commands.append("quit")
    
        result = _run_lldb_script(commands)
    
        if params.response_format == ResponseFormat.JSON:
            return json.dumps(
                {
                    "success": result["success"],
                    "breakpoint": params.breakpoint,
                    "output": result["output"],
                    "error": result.get("error"),
                },
                indent=2,
            )
    
        lines = [
            f"## Variables at `{params.breakpoint}`",
            "",
            "```",
            result["output"].strip() if result["success"] else result.get("error", "Unknown error"),
            "```",
        ]
    
        return "\n".join(lines)
  • Pydantic BaseModel defining the input schema (parameters) for the lldb_examine_variables tool.
    class ExamineVariablesInput(BaseModel):
        """Input for examining variables."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        executable: str = Field(..., description="Path to the executable", min_length=1)
        breakpoint: str = Field(..., description="Breakpoint location to stop at", min_length=1)
        variables: list[str] | None = Field(
            default=None, description="Specific variable names to examine (if None, shows all locals)"
        )
        args: list[str] | None = Field(
            default=None, description="Command-line arguments to pass to the program"
        )
        response_format: ResponseFormat = Field(
            default=ResponseFormat.MARKDOWN, description="Output format"
        )
  • The @mcp.tool decorator that registers the lldb_examine_variables function as an MCP tool with specified name and annotations.
    @mcp.tool(
        name="lldb_examine_variables",
        annotations={
            "title": "Examine Variables",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False,
        },
    )
  • Helper utility function used by the tool (and others) to execute a list of LLDB commands in batch mode and return structured results.
    def _run_lldb_script(
        commands: list[str],
        target: str | None = None,
        working_dir: str | None = None,
        timeout: int = 60,
    ) -> dict[str, Any]:
        """
        Execute multiple LLDB commands in sequence.
        """
        cmd = [LLDB_EXECUTABLE]
    
        if target:
            cmd.extend(["--file", target])
    
        cmd.append("--batch")
    
        for command in commands:
            cmd.extend(["-o", command])
    
        try:
            result = subprocess.run(
                cmd, capture_output=True, text=True, timeout=timeout, cwd=working_dir or os.getcwd()
            )
            return {
                "success": result.returncode == 0,
                "output": result.stdout,
                "error": result.stderr if result.returncode != 0 else None,
                "return_code": result.returncode,
            }
        except subprocess.TimeoutExpired:
            return {
                "success": False,
                "output": "",
                "error": f"Commands timed out after {timeout} seconds",
                "return_code": -1,
            }
        except Exception as e:
            return {"success": False, "output": "", "error": str(e), "return_code": -1}
Behavior3/5

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

Annotations already provide important behavioral hints (readOnlyHint=true, destructiveHint=false, idempotentHint=true), so the agent knows this is a safe, non-destructive read operation. The description adds useful context about program execution ('runs the program until the specified breakpoint') and display behavior, but doesn't mention potential side effects like program state changes during execution or any rate limits.

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 well-structured with purpose first, then execution behavior, followed by parameter and return value sections. It's appropriately sized at 4 sentences, though the parameter section could be slightly more detailed given the 0% schema coverage. Every sentence adds value without redundancy.

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

Completeness4/5

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

For a debugging tool with good annotations and an output schema, the description provides adequate context. It explains what the tool does, when to use it, and the main parameters. The presence of an output schema means the description doesn't need to detail return values. However, with 0% schema coverage and multiple sibling tools, more parameter guidance would be beneficial.

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

Parameters4/5

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

With 0% schema description coverage, the description carries the full burden of parameter documentation. It mentions the main parameter ('ExamineVariablesInput with executable, breakpoint, and optional variable names') and provides semantic context about what these represent. However, it doesn't detail all sub-parameters like 'args' or 'response_format' that appear in the schema, leaving some gaps.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('examine', 'runs', 'displays') and resources ('local variables and arguments at a breakpoint'). It distinguishes itself from siblings like lldb_backtrace (stack trace) or lldb_registers (register values) by focusing specifically on variable inspection during debugging.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('at a breakpoint' for examining variables), but doesn't explicitly state when NOT to use it or name specific alternatives. It implies usage during debugging sessions but lacks explicit exclusions or comparisons to similar tools like lldb_evaluate (which evaluates expressions).

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/benpm/claude_lldb_mcp'

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