Skip to main content
Glama

ida_rename_global_variable

Rename global variables in the IDA database by specifying the old and new names to simplify reverse engineering and code analysis.

Instructions

Rename a global variable in the IDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
new_nameYes
old_nameYes

Implementation Reference

  • Core handler function that implements the global variable renaming logic using IDA's ida_name API: resolves old name to address, validates new name availability, calls set_name, and refreshes the view.
    def _rename_global_variable_internal(self, old_name: str, new_name: str) -> Dict[str, Any]: """Internal implementation for rename_global_variable without sync wrapper""" try: # Get variable address var_addr: int = ida_name.get_name_ea(0, old_name) if var_addr == idaapi.BADADDR: return {"success": False, "message": f"Variable '{old_name}' not found"} # Check if new name is already in use if ida_name.get_name_ea(0, new_name) != idaapi.BADADDR: return {"success": False, "message": f"Name '{new_name}' is already in use"} # Try to rename if not ida_name.set_name(var_addr, new_name): return {"success": False, "message": f"Failed to rename variable, possibly due to invalid name format or other IDA restrictions"} # Refresh view self._refresh_view_internal() return {"success": True, "message": f"Variable renamed from '{old_name}' to '{new_name}' at address {hex(var_addr)}"} except Exception as e: print(f"Error renaming variable: {str(e)}") traceback.print_exc() return {"success": False, "message": str(e)}
  • Pydantic BaseModel defining the input schema for the tool: old_name and new_name strings.
    class RenameGlobalVariable(BaseModel): old_name: str new_name: str
  • MCP tool registration in server.list_tools(): specifies name, description, and inputSchema.
    Tool( name=IDATools.RENAME_GLOBAL_VARIABLE, description="Rename a global variable in the IDA database", inputSchema=RenameGlobalVariable.schema(), ),
  • Proxy handler in MCP server's IDAProFunctions class: sends 'rename_global_variable' request to IDA plugin via communicator and formats response.
    def rename_global_variable(self, old_name: str, new_name: str) -> str: """Rename a global variable""" try: response: Dict[str, Any] = self.communicator.send_request( "rename_global_variable", {"old_name": old_name, "new_name": new_name} ) if "error" in response: return f"Error renaming global variable from '{old_name}' to '{new_name}': {response['error']}" success: bool = response.get("success", False) message: str = response.get("message", "") if success: return f"Successfully renamed global variable from '{old_name}' to '{new_name}': {message}" else: return f"Failed to rename global variable from '{old_name}' to '{new_name}': {message}" except Exception as e: self.logger.error(f"Error renaming global variable: {str(e)}", exc_info=True) return f"Error renaming global variable from '{old_name}' to '{new_name}': {str(e)}"
  • Tool handler dispatch in MCP server's call_tool(): maps tool name to ida_functions.rename_global_variable and returns TextContent response.
    case IDATools.RENAME_GLOBAL_VARIABLE: result: str = ida_functions.rename_global_variable( arguments["old_name"], arguments["new_name"] ) return [TextContent( type="text", text=result )]

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