Skip to main content
Glama

ida_rename_multi_global_variables

Rename multiple global variables simultaneously in IDA databases to improve code readability and maintain consistency during reverse engineering analysis.

Instructions

Rename multiple global variables at once in the IDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rename_pairs_old2newYes

Implementation Reference

  • Core handler implementing the multi-rename logic by iterating over pairs and delegating to single rename. Performs the actual IDA API calls via the single rename helper.
    def rename_multi_global_variables(self, rename_pairs_old2new: List[Dict[str, str]]) -> Dict[str, Any]:
        """Rename multiple global variables at once"""
        try:
            success_count: int = 0
            failed_pairs: List[Dict[str, str]] = []
    
            for pair in rename_pairs_old2new:
                old_name = next(iter(pair.keys()))
                new_name = pair[old_name]
                
                # Call existing rename_global_variable_internal for each pair
                result = self._rename_global_variable_internal(old_name, new_name)
                
                if result.get("success", False):
                    success_count += 1
                else:
                    failed_pairs.append({
                        "old_name": old_name,
                        "new_name": new_name,
                        "error": result.get("message", "Unknown error")
                    })
    
            return {
                "success": True,
                "message": f"Renamed {success_count} out of {len(rename_pairs_old2new)} global variables",
                "success_count": success_count,
                "failed_pairs": failed_pairs
            }
    
        except Exception as e:
            print(f"Error in rename_multi_global_variables: {str(e)}")
            traceback.print_exc()
            return {
                "success": False,
                "message": str(e),
                "success_count": 0,
                "failed_pairs": rename_pairs_old2new
            }
  • Helper function performing the single global variable rename using IDA's ida_name.set_name API.
    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 model defining the input schema: list of dicts with old_name to new_name pairs.
    class RenameMultiGlobalVariables(BaseModel):
        rename_pairs_old2new: List[Dict[str, str]]
  • MCP tool registration in list_tools() with name, description, and input schema.
    Tool(
        name=IDATools.RENAME_MULTI_GLOBAL_VARIABLES,
        description="Rename multiple global variables at once in the IDA database", 
        inputSchema=RenameMultiGlobalVariables.schema(),
    ),
  • MCP server-side handler proxy that sends the request to IDA plugin via socket and formats response.
    def rename_multi_global_variables(self, rename_pairs_old2new: List[Dict[str, str]]) -> str:
        """Rename multiple global variables at once"""
        try:
            response: Dict[str, Any] = self.communicator.send_request(
                "rename_multi_global_variables", 
                {"rename_pairs_old2new": rename_pairs_old2new}
            )
            
            if "error" in response:
                return f"Error renaming multiple global variables: {response['error']}"
            
            success_count: int = response.get("success_count", 0)
            failed_pairs: List[Dict[str, str]] = response.get("failed_pairs", [])
            
            result_parts: List[str] = [
                f"Successfully renamed {success_count} global variables"
            ]
            
            if failed_pairs:
                result_parts.append("\nFailed renamings:")
                for pair in failed_pairs:
                    result_parts.append(f"- {pair['old_name']} → {pair['new_name']}: {pair.get('error', 'Unknown error')}")
            
            return "\n".join(result_parts)
        except Exception as e:
            self.logger.error(f"Error renaming multiple global variables: {str(e)}", exc_info=True)
            return f"Error renaming multiple global variables: {str(e)}"
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. While 'Rename' implies a destructive mutation, the description doesn't address critical behavioral aspects: whether this requires specific permissions, if changes are reversible, what happens to references to renamed variables, or potential side effects. This is inadequate for a mutation tool with zero annotation coverage.

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 perfectly concise - a single sentence that directly states the tool's purpose with zero wasted words. It's front-loaded with the core action and appropriately sized for what it communicates.

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?

For a mutation tool with no annotations, 0% schema coverage, and no output schema, the description is insufficient. It doesn't explain the parameter format, behavioral implications, error conditions, or what the tool returns. Given the complexity of batch renaming operations in a database context, more contextual information is needed.

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 undocumented parameters. The description mentions 'multiple global variables' which hints at the array parameter, but provides no details about the 'rename_pairs_old2new' structure, expected format, or how to specify old-to-new mappings. This leaves the single parameter largely unexplained.

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 ('Rename multiple global variables at once') and resource ('in the IDA database'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'ida_rename_global_variable' (singular) or 'ida_rename_multi_functions' (different resource type), which would be needed for a perfect score.

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 when to prefer this over the singular 'ida_rename_global_variable' tool or when batch renaming is appropriate versus individual operations, leaving the agent without usage context.

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