Skip to main content
Glama

ida_rename_global_variable

Rename global variables in IDA databases to improve code readability and maintain consistent naming conventions during reverse engineering analysis.

Instructions

Rename a global variable in the IDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
old_nameYes
new_nameYes

Implementation Reference

  • Pydantic input schema for the ida_rename_global_variable tool, defining old_name and new_name as strings.
    class RenameGlobalVariable(BaseModel):
        old_name: str
        new_name: str
  • MCP tool registration in list_tools(), specifying name, description, and input schema.
    Tool(
        name=IDATools.RENAME_GLOBAL_VARIABLE,
        description="Rename a global variable in the IDA database",
        inputSchema=RenameGlobalVariable.schema(),
    ),
  • MCP server-side handler in IDAProFunctions class that proxies the rename request to the IDA plugin via socket communication.
    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)}"
  • Socket server dispatch in IDA plugin that routes 'rename_global_variable' requests to the core handler.
    elif request_type == "rename_global_variable":
        response.update(self.core.rename_global_variable(
            request_data.get("old_name", ""),
            request_data.get("new_name", "")
        ))
  • Core IDA plugin handler (@idawrite decorated) that implements the rename logic using IDA APIs: get_name_ea to find address and set_name to rename the global variable.
    def rename_global_variable(self, old_name: str, new_name: str) -> Dict[str, Any]:
        """Rename a global variable"""
        return self._rename_global_variable_internal(old_name, new_name)
        
    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)}
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action 'rename' but doesn't describe traits such as whether this is a destructive mutation, if it requires specific permissions in IDA, potential side effects (e.g., updating references), or error handling (e.g., what happens if the old name doesn't exist). This leaves significant gaps for an agent to understand the tool's behavior.

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 without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 a mutation tool with no annotations, no output schema, and 0% schema coverage, the description is incomplete. It lacks details on behavioral traits, parameter semantics, and usage context, which are crucial for an agent to correctly invoke this tool in an IDA database environment. The description does the minimum but leaves too many gaps.

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 schema provides no descriptions for the parameters 'old_name' and 'new_name'. The description doesn't add any semantic details about these parameters, such as format constraints (e.g., string patterns), examples, or validation rules. However, with only 2 parameters and straightforward names, the baseline is 3 as the description doesn't compensate for the lack of schema coverage but the simplicity keeps it from being lower.

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 verb 'rename' and the resource 'global variable in the IDA database', making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'ida_rename_local_variable' or 'ida_rename_multi_global_variables', which would require mentioning it's for single global variables versus multi-renaming or local variables.

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. It doesn't mention prerequisites (e.g., needing an existing global variable), exclusions (e.g., not for local variables), or direct comparisons to siblings like 'ida_rename_multi_global_variables' for batch operations or 'ida_rename_local_variable' for different variable types.

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