Skip to main content
Glama

ida_get_current_function_assembly

Extract assembly code for the function at the current cursor position in IDA, enabling precise analysis and automation of binary data.

Instructions

Get assembly code for the function at the current cursor position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool registration in server.list_tools() defining the tool name, description, and schema
    Tool( name=IDATools.GET_CURRENT_FUNCTION_ASSEMBLY, description="Get assembly code for the function at the current cursor position", inputSchema=GetCurrentFunctionAssembly.schema(), ),
  • Pydantic input schema for the tool (no parameters)
    class GetCurrentFunctionAssembly(BaseModel): pass
  • MCP server tool call handler dispatching to IDAProFunctions
    case IDATools.GET_CURRENT_FUNCTION_ASSEMBLY: assembly: str = ida_functions.get_current_function_assembly() return [TextContent( type="text", text=assembly )]
  • Server-side proxy handler sending socket RPC to IDA plugin and formatting response
    def get_current_function_assembly(self) -> str: """Get assembly code for the function at current cursor position""" try: response: Dict[str, Any] = self.communicator.send_request( "get_current_function_assembly", {} ) if "error" in response: return f"Error retrieving assembly for current function: {response['error']}" assembly: Any = response.get("assembly") function_name: str = response.get("function_name", "Current function") # Verify assembly is string type if assembly is None: return f"Error: No assembly data returned for current function" 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 current function assembly: {str(e)}", exc_info=True) return f"Error retrieving assembly for current function: {str(e)}"
  • IDA plugin RPC handler getting current screen EA and delegating to internal assembly getter
    def get_current_function_assembly(self) -> Dict[str, Any]: """Get assembly code for the function at the current cursor position""" try: # Get current address curr_addr = idaapi.get_screen_ea() if curr_addr == idaapi.BADADDR: return {"error": "No valid cursor position"} # Use the internal implementation without decorator return self._get_function_assembly_by_address_internal(curr_addr) except Exception as e: traceback.print_exc() return {"error": str(e)}
  • Core logic extracting assembly disassembly lines from function using IDA APIs (idautils.FuncItems, idc.GetDisasm)
    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)}
  • Enum definition for the tool name constant
    GET_CURRENT_FUNCTION_ASSEMBLY = "ida_get_current_function_assembly"

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