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)}

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