Skip to main content
Glama

ida_get_function_decompiled_by_name

Retrieve decompiled pseudocode for a specific function by its name to analyze program behavior and logic in IDA Pro.

Instructions

Get decompiled pseudocode for a function by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
function_nameYes

Implementation Reference

  • Core implementation of decompilation by function name: resolves name to EA, decompiles using Hex-Rays ida_hexrays.decompile(), returns pseudocode string or error.
    @idaread
    def get_function_decompiled_by_name(self, function_name: str) -> Dict[str, Any]:
        """Get decompiled code for a function by its name"""
        try:
            # Get function address from name
            func_addr = idaapi.get_name_ea(0, function_name)
            if func_addr == idaapi.BADADDR:
                return {"error": f"Function '{function_name}' not found"}
            
            # Call internal implementation without decorator
            result = self._get_function_decompiled_by_address_internal(func_addr)
            
            # If successful, add function name to result
            if "error" not in result:
                result["function_name"] = function_name
                
            return result
        except Exception as e:
            traceback.print_exc()
            return {"error": str(e)}
    
    @idaread
    def get_function_decompiled_by_address(self, address: int) -> Dict[str, Any]:
        """Get decompiled code for a function by its address"""
        return self._get_function_decompiled_by_address_internal(address)
    
    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)}
  • Pydantic input schema for the tool requiring 'function_name' string parameter.
    class GetFunctionDecompiledByName(BaseModel):
        function_name: str
  • MCP Tool registration in server.list_tools(), specifying name 'ida_get_function_decompiled_by_name', description, and input schema.
    Tool(
        name=IDATools.GET_FUNCTION_DECOMPILED_BY_NAME,
        description="Get decompiled pseudocode for a function by name",
        inputSchema=GetFunctionDecompiledByName.schema(),
    ),
  • MCP server call_tool() dispatch for the tool: calls IDAProFunctions wrapper with function_name argument.
    case IDATools.GET_FUNCTION_DECOMPILED_BY_NAME:
        decompiled: str = ida_functions.get_function_decompiled_by_name(arguments["function_name"])
        return [TextContent(
            type="text",
            text=decompiled
        )]
  • Socket request dispatcher in IDA plugin that maps 'get_function_decompiled_by_name' to IDAMCPCore.get_function_decompiled_by_name call.
    elif request_type == "get_function_decompiled_by_name":
        response.update(self.core.get_function_decompiled_by_name(request_data.get("function_name", "")))
    elif request_type == "get_function_decompiled_by_address":
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 the tool's purpose but lacks critical details: it doesn't specify if this is a read-only operation (likely, but not confirmed), what happens if the function name isn't found (e.g., returns error or null), or any performance considerations like rate limits. The description is minimal and doesn't compensate for the absence of annotations.

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, clear sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded and appropriately sized for a simple tool, with no wasted verbiage.

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 (a tool interacting with a disassembler like IDA), no annotations, no output schema, and low parameter coverage, the description is incomplete. It doesn't address key aspects such as error handling, output format (e.g., text or structured data), or integration context, making it inadequate for safe and effective use by an 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 1 parameter with 0% description coverage, and the tool description doesn't add any semantic details about the 'function_name' parameter. It doesn't explain what constitutes a valid function name (e.g., format, case-sensitivity, or scope), leaving the agent with only the parameter title and type from the schema. This is insufficient given 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 resource ('for a function by name'), which is specific and unambiguous. However, it doesn't explicitly differentiate from its sibling 'ida_get_function_decompiled_by_address', which performs a similar operation but uses an address instead of a name as the identifier.

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 doesn't mention prerequisites (e.g., whether the function name must exist in the current IDA database), nor does it contrast with siblings like 'ida_get_function_decompiled_by_address' or 'ida_get_current_function_decompiled', leaving the agent to infer usage context.

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