Skip to main content
Glama

lldb_source

Read-onlyIdempotent

Display source code from debugged executables by line number, function name, or current position to inspect program logic during debugging sessions.

Instructions

List source code for a file, function, or current location.

Can display:
- Source around a specific line
- Source for a named function
- Source at the current debug position

Args:
    params: ListSourceInput specifying what source to show

Returns:
    str: Source code listing with line numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function executes LLDB source listing commands based on the provided input parameters and formats the output as markdown.
    async def lldb_source(params: ListSourceInput) -> str:
        """List source code for a file, function, or current location.
    
        Can display:
        - Source around a specific line
        - Source for a named function
        - Source at the current debug position
    
        Args:
            params: ListSourceInput specifying what source to show
    
        Returns:
            str: Source code listing with line numbers
        """
        commands = [f"target create {params.executable}"]
    
        if params.function:
            commands.append(f"source list --name {params.function} --count {params.count}")
        elif params.file and params.line:
            commands.append(
                f"source list --file {params.file} --line {params.line} --count {params.count}"
            )
        elif params.file:
            commands.append(f"source list --file {params.file} --count {params.count}")
        else:
            commands.append(f"source list --count {params.count}")
    
        result = _run_lldb_script(commands)
    
        title = params.function or params.file or "Source"
        return f"## {title}\n\n```cpp\n{result['output'].strip()}\n```"
  • Pydantic input model defining parameters for the lldb_source tool: executable path, optional file/line/function, and line count.
    class ListSourceInput(BaseModel):
        """Input for listing source code."""
    
        model_config = ConfigDict(str_strip_whitespace=True)
    
        executable: str = Field(..., description="Path to the executable", min_length=1)
        file: str | None = Field(
            default=None, description="Source file to list (if None, lists around current location)"
        )
        line: int | None = Field(default=None, description="Line number to center on", ge=1)
        count: int = Field(default=20, description="Number of lines to show", ge=1, le=500)
        function: str | None = Field(default=None, description="Show source for a specific function")
  • MCP tool registration decorator that registers the lldb_source handler with metadata annotations.
    @mcp.tool(
        name="lldb_source",
        annotations={
            "title": "List Source Code",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False,
        },
    )
Behavior4/5

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

The description adds valuable behavioral context beyond what annotations provide: it specifies the three display modes (line-specific, function-specific, current position) and mentions the return format ('Source code listing with line numbers'). Annotations already declare readOnlyHint=true and idempotentHint=true, so the description appropriately focuses on operational behavior rather than repeating safety information.

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

Conciseness5/5

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

The description is perfectly structured and front-loaded: the first sentence states the core purpose, bullet points efficiently enumerate capabilities, and the Args/Returns sections are clear and minimal. Every sentence earns its place with zero wasted text.

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?

Given the tool's moderate complexity (debugging source code display), the description covers purpose, usage contexts, and return format well. With annotations covering safety aspects and an output schema presumably detailing the string return, the description is mostly complete. The main gap is lack of parameter details, but this is partially mitigated by the clear overall purpose statement.

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?

With 0% schema description coverage, the schema provides no parameter descriptions, but the tool description only mentions 'params: ListSourceInput specifying what source to show' without explaining individual parameters. While the description doesn't detail parameters like 'executable', 'line', or 'count', it does clarify the overall purpose of the params object. This partial compensation earns a baseline score.

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 ('List source code') and resources ('for a file, function, or current location'), distinguishing it from siblings like lldb_disassemble (assembly code) or lldb_examine_variables (variable inspection). The three bullet points further clarify the specific use cases.

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 about when to use this tool (to display source code in various scenarios) but doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools. The bullet points offer good guidance on different usage contexts without explicit exclusions.

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