Skip to main content
Glama

ida_get_function_decompiled_by_address

Retrieve decompiled pseudocode for a specific function using its memory address in IDA Pro. This tool helps analyze binary code by converting machine instructions into readable pseudocode.

Instructions

Get decompiled pseudocode for a function by address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes

Implementation Reference

  • Core IDA plugin implementation: performs Hex-Rays decompilation of the function at the given address and returns pseudocode as string.
    def _get_function_decompiled_by_address_internal(self, address: int) -> Dict[str, Any]:
        """Internal implementation for get_function_decompiled_by_address without sync wrapper"""
        try:
            # Get function from address
            func = idaapi.get_func(address)
            if not func:
                return {"error": f"No function found at address 0x{address:X}"}
            
            # Get function name
            func_name = idaapi.get_func_name(func.start_ea)
            
            # Try to import decompiler module
            try:
                import ida_hexrays
            except ImportError:
                return {"error": "Hex-Rays decompiler is not available"}
            
            # Check if decompiler is available
            if not ida_hexrays.init_hexrays_plugin():
                return {"error": "Unable to initialize Hex-Rays decompiler"}
            
            # Get decompiled function
            cfunc = None
            try:
                cfunc = ida_hexrays.decompile(func.start_ea)
            except Exception as e:
                return {"error": f"Unable to decompile function: {str(e)}"}
            
            if not cfunc:
                return {"error": "Decompilation failed"}
            
            # Get pseudocode as string
            decompiled_code = str(cfunc)
            
            return {"decompiled_code": decompiled_code, "function_name": func_name}
        except Exception as e:
            traceback.print_exc()
            return {"error": str(e)}
  • MCP server-side handler: proxies the tool call by sending socket request to IDA plugin and formats the response.
    def get_function_decompiled_by_address(self, address: str) -> str:
        """Get decompiled pseudocode for a function by its address"""
        try:
            # Convert string address to int
            try:
                addr_int = int(address, 16) if address.startswith("0x") else int(address)
            except ValueError:
                return f"Error: Invalid address format '{address}', expected hexadecimal (0x...) or decimal"
                
            response: Dict[str, Any] = self.communicator.send_request(
                "get_function_decompiled_by_address", 
                {"address": addr_int}
            )
            
            if "error" in response:
                return f"Error retrieving decompiled code for address '{address}': {response['error']}"
            
            decompiled_code: Any = response.get("decompiled_code")
            function_name: str = response.get("function_name", "Unknown function")
            
            # Detailed type checking and conversion
            if decompiled_code is None:
                return f"Error: No decompiled code returned for address '{address}'"
                
            # Ensure result is string
            if not isinstance(decompiled_code, str):
                self.logger.warning(f"Decompiled code type is not string but {type(decompiled_code).__name__}, attempting conversion")
                try:
                    decompiled_code = str(decompiled_code)
                except Exception as e:
                    return f"Error: Failed to convert decompiled code: {str(e)}"
            
            return f"Decompiled code for function '{function_name}' at address {address}:\n{decompiled_code}"
        except Exception as e:
            self.logger.error(f"Error getting function decompiled code by address: {str(e)}", exc_info=True)
            return f"Error retrieving decompiled code for address '{address}': {str(e)}"
  • MCP tool registration in server.list_tools(): defines tool name, description, and input schema.
    Tool(
        name=IDATools.GET_FUNCTION_DECOMPILED_BY_ADDRESS,
        description="Get decompiled pseudocode for a function by address",
        inputSchema=GetFunctionDecompiledByAddress.schema(),
    ),
  • Pydantic model defining the input schema: expects 'address' as string.
    class GetFunctionDecompiledByAddress(BaseModel):
        address: str  # Hexadecimal address as string
  • Enum constant defining the exact tool name string used for registration and dispatching.
    GET_FUNCTION_DECOMPILED_BY_ADDRESS = "ida_get_function_decompiled_by_address"
  • IDA plugin socket request handler: dispatches 'get_function_decompiled_by_address' request to IDAMCPCore.
    elif request_type == "get_function_decompiled_by_address":
        response.update(self.core.get_function_decompiled_by_address(request_data.get("address", 0)))
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe traits like whether it's read-only or mutating, potential errors (e.g., invalid address), or output format (e.g., text, structured data). This leaves significant gaps in understanding how the tool behaves.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and appropriately sized for a simple tool, with no wasted information.

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 (decompilation likely involves non-trivial processing), lack of annotations, no output schema, and low schema coverage, the description is inadequate. It doesn't explain what 'decompiled pseudocode' entails, potential limitations, or return values, making it incomplete for effective use by an AI agent.

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

Parameters2/5

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

The input schema has 0% description coverage, with one parameter 'address' undocumented. The description mentions 'by address' but doesn't specify the format (e.g., hexadecimal, decimal), valid ranges, or examples. It adds minimal semantic value beyond what's implied by the parameter name, failing to compensate for the low schema coverage.

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 action ('Get decompiled pseudocode') and target ('for a function by address'), making the purpose understandable. However, it doesn't explicitly differentiate from its sibling 'ida_get_function_decompiled_by_name', which performs a similar function but uses a name instead of an address as input.

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. The description lacks context about prerequisites (e.g., whether the function must exist at the address) or comparisons to siblings like 'ida_get_current_function_decompiled' or 'ida_get_function_decompiled_by_name', leaving usage unclear.

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/MxIris-Reverse-Engineering/ida-mcp-server'

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