Skip to main content
Glama

ida_add_assembly_comment

Add comments to assembly code at specific addresses in IDA Pro to document analysis and improve code understanding during reverse engineering.

Instructions

Add a comment at a specific address in the assembly view of the IDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes
commentYes
is_repeatableNo

Implementation Reference

  • Pydantic input schema/model for the tool defining parameters: address (str), comment (str), is_repeatable (bool)
    class AddAssemblyComment(BaseModel):
        address: str  # Can be a hexadecimal address string
        comment: str
        is_repeatable: bool = False  # Whether the comment should be repeatable
  • Tool registration in the list_tools() handler, associating name, description, and schema with the tool
    Tool(
        name=IDATools.ADD_ASSEMBLY_COMMENT,
        description="Add a comment at a specific address in the assembly view of the IDA database",
        inputSchema=AddAssemblyComment.schema(),
    ),
  • MCP server call_tool() dispatch handler for ida_add_assembly_comment, calls proxy method and returns TextContent result
    case IDATools.ADD_ASSEMBLY_COMMENT:
        result: str = ida_functions.add_assembly_comment(
            arguments["address"], 
            arguments["comment"], 
            arguments.get("is_repeatable", False)
        )
        return [TextContent(
            type="text",
            text=result
        )]
  • Proxy handler in IDAProFunctions class that forwards the request to IDA plugin via socket communication
    def add_assembly_comment(self, address: str, comment: str, is_repeatable: bool = False) -> str:
        """Add an assembly comment"""
        try:
            response: Dict[str, Any] = self.communicator.send_request(
                "add_assembly_comment", 
                {"address": address, "comment": comment, "is_repeatable": is_repeatable}
            )
            
            if "error" in response:
                return f"Error adding assembly comment at address '{address}': {response['error']}"
            
            success: bool = response.get("success", False)
            message: str = response.get("message", "")
            
            if success:
                comment_type: str = "repeatable" if is_repeatable else "regular"
                return f"Successfully added {comment_type} assembly comment at address '{address}': {message}"
            else:
                return f"Failed to add assembly comment at address '{address}': {message}"
        except Exception as e:
            self.logger.error(f"Error adding assembly comment: {str(e)}", exc_info=True)
            return f"Error adding assembly comment at address '{address}': {str(e)}"
  • Core IDA implementation: parses address, calls idc.set_cmt(addr, comment, is_repeatable) to add comment, refreshes views
    def _add_assembly_comment_internal(self, address: str, comment: str, is_repeatable: bool) -> Dict[str, Any]:
        """Internal implementation for add_assembly_comment without sync wrapper"""
        try:
            # Convert address string to integer
            addr: int
            if isinstance(address, str):
                if address.startswith("0x"):
                    addr = int(address, 16)
                else:
                    try:
                        addr = int(address, 16)  # Try parsing as hex
                    except ValueError:
                        try:
                            addr = int(address)  # Try parsing as decimal
                        except ValueError:
                            return {"success": False, "message": f"Invalid address format: {address}"}
            else:
                addr = address
            
            # Check if address is valid
            if addr == idaapi.BADADDR or not ida_bytes.is_loaded(addr):
                return {"success": False, "message": f"Invalid or unloaded address: {hex(addr)}"}
            
            # Add comment
            result: bool = idc.set_cmt(addr, comment, is_repeatable)
            if result:
                # Refresh view
                self._refresh_view_internal()
                comment_type: str = "repeatable" if is_repeatable else "regular"
                return {"success": True, "message": f"Added {comment_type} assembly comment at address {hex(addr)}"}
            else:
                return {"success": False, "message": f"Failed to add assembly comment at address {hex(addr)}"}
        
        except Exception as e:
            print(f"Error adding assembly comment: {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?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool adds a comment, implying a mutation, but doesn't cover critical aspects like whether this action is reversible, if it requires specific user permissions, potential side effects (e.g., overwriting existing comments), or error conditions. This leaves significant gaps in understanding the tool's behavior beyond the basic action.

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 that efficiently conveys the core purpose without unnecessary words. It is front-loaded with the key action and target, making it easy to understand at a glance, which is ideal for conciseness in tool definitions.

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 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is insufficient. It lacks details on parameter usage, behavioral traits, error handling, and output expectations, making it incomplete for safe and effective agent invocation in this context.

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 schema provides no parameter descriptions. The description mentions 'address' and 'comment' but doesn't explain their formats, constraints, or the meaning of 'is_repeatable'. It adds minimal semantic value beyond naming the parameters, failing to compensate for the lack of schema documentation, especially for the boolean parameter.

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 ('Add a comment') and target ('at a specific address in the assembly view of the IDA database'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'ida_add_function_comment' or 'ida_add_pseudocode_comment' beyond mentioning 'assembly view', leaving some ambiguity about when to choose this exact tool over similar ones.

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, such as the sibling tools for adding comments in different contexts (e.g., function or pseudocode views). It also lacks information on prerequisites, like whether an IDA database must be open or if specific permissions are needed, leaving usage context implied but not stated.

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