Skip to main content
Glama

ida_add_assembly_comment

Add custom comments to specific addresses in the IDA database assembly view, enhancing code analysis and documentation for improved reverse engineering workflows.

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

  • Exact IDA Pro implementation of the tool: parses address, validates it, calls idc.set_cmt(addr, comment, is_repeatable) to add the comment, refreshes view.
    def add_assembly_comment(self, address: str, comment: str, is_repeatable: bool) -> Dict[str, Any]: """Add an assembly comment""" return self._add_assembly_comment_internal(address, comment, is_repeatable) 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)}
  • Pydantic input schema for the tool defining parameters: address, comment, is_repeatable.
    class AddAssemblyComment(BaseModel): address: str # Can be a hexadecimal address string comment: str is_repeatable: bool = False # Whether the comment should be repeatable
  • MCP tool registration in server.list_tools() using the tool name and schema.
    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-side handler that forwards the request to the IDA plugin via socket communicator.
    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)}"
  • Plugin server dispatch: routes 'add_assembly_comment' socket requests to IDAMCPCore.add_assembly_comment.
    elif request_type == "add_assembly_comment": response.update(self.core.add_assembly_comment( request_data.get("address", ""), request_data.get("comment", ""), request_data.get("is_repeatable", False) ))

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