Skip to main content
Glama

ida_get_function_assembly_by_address

Extract assembly code for a specific function using its memory address to analyze program behavior and structure.

Instructions

Get assembly code for a function by address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes

Implementation Reference

  • Core IDA plugin handler that retrieves function assembly by address using IDA APIs: get_func, FuncItems iterator, and GetDisasm. Wrapped with @idaread for main thread execution.
    def get_function_assembly_by_address(self, address: int) -> Dict[str, Any]:
        """Get assembly code for a function by its address"""
        return self._get_function_assembly_by_address_internal(address)
        
    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)}
  • MCP server-side tool handler. Converts address string to int, sends socket request to IDA plugin, receives and formats the assembly response as text.
    def get_function_assembly_by_address(self, address: str) -> str:
        """Get assembly code 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_assembly_by_address", 
                {"address": addr_int}
            )
            
            if "error" in response:
                return f"Error retrieving assembly for address '{address}': {response['error']}"
            
            assembly: Any = response.get("assembly")
            function_name: str = response.get("function_name", "Unknown function")
            
            # Verify assembly is string type
            if assembly is None:
                return f"Error: No assembly data returned for address '{address}'"
            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}' at address {address}:\n{assembly}"
        except Exception as e:
            self.logger.error(f"Error getting function assembly by address: {str(e)}", exc_info=True)
            return f"Error retrieving assembly for address '{address}': {str(e)}"
  • Pydantic input schema model for the tool, defining the 'address' parameter as string.
    class GetFunctionAssemblyByAddress(BaseModel):
        address: str  # Hexadecimal address as string
  • MCP tool registration in server.list_tools(), specifying name, description, and input schema.
        name=IDATools.GET_FUNCTION_ASSEMBLY_BY_ADDRESS,
        description="Get assembly code for a function by address",
        inputSchema=GetFunctionAssemblyByAddress.schema(),
    ),
  • Tool dispatch/execution in server.call_tool(), matching tool name and calling the handler function.
    case IDATools.GET_FUNCTION_ASSEMBLY_BY_ADDRESS:
        assembly: str = ida_functions.get_function_assembly_by_address(arguments["address"])
        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 the full burden of behavioral disclosure. It states what the tool does but lacks details on permissions required, error handling, output format, or any side effects. This is inadequate for a tool that likely interacts with a disassembler like IDA Pro, where context such as analysis state or session requirements would be helpful.

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 with no wasted words, making it easy to parse. It front-loads the core action and target efficiently, which is ideal for quick understanding.

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 of interacting with a disassembler, no annotations, no output schema, and low schema coverage, the description is insufficient. It doesn't explain what 'assembly code' entails (e.g., raw bytes, formatted text), potential errors, or how it integrates with sibling tools, leaving significant gaps for 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?

Schema description coverage is 0%, so the description must compensate for the undocumented parameter. It mentions 'by address' which hints at the 'address' parameter, but doesn't specify the expected format (e.g., hex string, decimal), valid ranges, or examples. This adds minimal value beyond the schema's basic structure.

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 address'), making the purpose understandable. However, it doesn't distinguish this tool from its sibling 'ida_get_function_assembly_by_name' which performs a similar function using a different identifier, missing explicit differentiation.

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 like 'ida_get_function_assembly_by_name' or 'ida_get_current_function_assembly'. The description implies usage by address but offers no context on prerequisites, error conditions, or comparative scenarios with sibling tools.

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