Skip to main content
Glama

ida_get_function_assembly_by_name

Retrieve assembly code for a specific function by name to analyze program behavior in IDA Pro.

Instructions

Get assembly code for a function by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
function_nameYes

Implementation Reference

  • Core handler logic: extracts assembly by iterating idautils.FuncItems(address) and collecting idc.GetDisasm for each instruction.
    def _get_function_assembly_by_address_internal(self, address: int) -> Dict[str, Any]:
        """Internal implementation for get_function_assembly_by_address without sync wrapper"""
        try:
            # Get function object
            func = ida_funcs.get_func(address)
            
            # Get function name
            func_name = idaapi.get_func_name(func.start_ea)
            
            if not func:
                return {"error": f"Invalid function at {hex(address)}"}
            
            # Collect all assembly instructions
            assembly_lines = []
            for instr_addr in idautils.FuncItems(address):
                disasm = idc.GetDisasm(instr_addr)
                assembly_lines.append(f"{hex(instr_addr)}: {disasm}")
            
            if not assembly_lines:
                return {"error": "No assembly instructions found"}
                
            return {"assembly": "\n".join(assembly_lines), "function_name": func_name}
        except Exception as e:
            print(f"Error getting function assembly: {str(e)}")
            traceback.print_exc()
            return {"error": str(e)}
  • IDA plugin handler: resolves function_name to func ea using idaapi.get_name_ea and get_func, then calls internal assembly extractor.
    def get_function_assembly_by_name(self, function_name: str) -> Dict[str, Any]:
        """Get assembly code for a function by its name"""
        try:
            # Get function address from name
            func = idaapi.get_func(idaapi.get_name_ea(0, function_name))
            if not func:
                return {"error": f"Function '{function_name}' not found"}
            
            # Call address-based implementation
            result = self._get_function_assembly_by_address_internal(func.start_ea)
            
            # 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)}
  • MCP server proxy handler: sends 'get_function_assembly_by_name' request to IDA Pro communicator and processes/formats the response.
    def get_function_assembly_by_name(self, function_name: str) -> str:
        """Get assembly code for a function by its name"""
        try:
            response: Dict[str, Any] = self.communicator.send_request(
                "get_function_assembly_by_name", 
                {"function_name": function_name}
            )
            
            if "error" in response:
                return f"Error retrieving assembly for function '{function_name}': {response['error']}"
            
            assembly: Any = response.get("assembly")
            # Verify assembly is string type
            if assembly is None:
                return f"Error: No assembly data returned for function '{function_name}'"
            if not isinstance(assembly, str):
                self.logger.warning(f"Assembly data type is not string but {type(assembly).__name__}, attempting conversion")
                assembly = str(assembly)
            
            return f"Assembly code for function '{function_name}':\n{assembly}"
        except Exception as e:
            self.logger.error(f"Error getting function assembly: {str(e)}", exc_info=True)
            return f"Error retrieving assembly for function '{function_name}': {str(e)}"
  • Tool registration in @server.list_tools(): defines the tool name, description, and input schema.
    Tool(
        name=IDATools.GET_FUNCTION_ASSEMBLY_BY_NAME,
        description="Get assembly code for a function by name",
        inputSchema=GetFunctionAssemblyByName.schema(),
  • Pydantic input schema/model for the tool: requires 'function_name' string.
    class GetFunctionAssemblyByName(BaseModel):
        function_name: str
  • MCP @server.call_tool() dispatch: match case that invokes the tool handler with arguments and returns TextContent response.
    case IDATools.GET_FUNCTION_ASSEMBLY_BY_NAME:
        assembly: str = ida_functions.get_function_assembly_by_name(arguments["function_name"])
        return [TextContent(
            type="text",
            text=assembly
        )]
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't reveal any behavioral traits such as whether it's read-only, potential errors (e.g., if function doesn't exist), output format, or any side effects. This leaves significant gaps for safe and effective use.

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 with zero wasted words. It's appropriately sized for a simple tool and front-loads the key information without unnecessary elaboration.

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 lack of annotations, no output schema, and low schema description coverage, the description is incomplete. It doesn't address behavioral aspects, error conditions, or output details, which are crucial for a tool that interacts with a complex system like IDA Pro. The agent would have significant uncertainty about how to interpret results or handle failures.

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 description coverage is 0%, so the description must compensate. It mentions 'by name' which implies the 'function_name' parameter, adding some semantic context beyond the bare schema. However, it doesn't specify format requirements (e.g., case sensitivity, naming conventions) or provide examples, leaving the parameter only partially clarified.

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 assembly code') and target ('for a function by name'), which is specific and unambiguous. However, it doesn't differentiate from its sibling 'ida_get_function_assembly_by_address' which serves a similar purpose but uses a different identifier (address vs name).

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?

The description provides no guidance on when to use this tool versus alternatives like 'ida_get_function_assembly_by_address' or 'ida_get_current_function_assembly'. There's no mention of prerequisites, context requirements, or any exclusion criteria, leaving the agent to infer usage from tool names alone.

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