Skip to main content
Glama
opensensor

Binary Ninja Cline MCP Server

by opensensor

disassemble_function

Analyze binary files by extracting and displaying the assembly code of specific functions to understand program behavior.

Instructions

Disassemble a function from a binary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
functionYes

Implementation Reference

  • Input schema definition for the disassemble_function tool in the list_tools MCP method response.
    "name": "disassemble_function",
    "description": "Disassemble a function in a binary file",
    "inputSchema": {
        "type": "object",
        "properties": {
            "path": {
                "type": "string",
                "description": "Path to the binary file"
            },
            "function": {
                "type": "string",
                "description": "Name of the function to disassemble"
            }
        },
        "required": ["path", "function"]
    }
  • Registration and dispatching of call_tool 'disassemble_function' to the internal method handler.
    elif tool_name == "disassemble_function":
        return handle_request({
            "method": "disassemble_function",
            "params": tool_args
        }, client)
  • Core handler for the disassemble_function MCP method: validates params, calls BinaryNinjaHTTPClient.get_disassembly, returns disassembly lines.
    elif method == "disassemble_function":
        path = params.get("path")
        func_name = params.get("function")
        if not path or not func_name:
            return {"error": "Path and function parameters are required"}
            
        # We assume the binary is already loaded
        # Just log the path for debugging
        logger.info(f"Using binary: {path}")
            
        disasm = client.get_disassembly(path, function_name=func_name)
        return {"result": disasm}
  • HTTP MCP server handler for disassemble_function with JSON-RPC error handling and response wrapping.
    elif method == "disassemble_function":
        path = params.get("path")
        func = params.get("function")
        if not path:
            logger.error("Missing 'path' parameter")
            return self._error_response(request_id, -32602, "Missing 'path' parameter")
        if not func:
            logger.error("Missing 'function' parameter")
            return self._error_response(request_id, -32602, "Missing 'function' parameter")
        if not isinstance(path, str):
            logger.error(f"Invalid path type: {type(path)}")
            return self._error_response(request_id, -32602, "Parameter 'path' must be a string")
        if not isinstance(func, str):
            logger.error(f"Invalid function type: {type(func)}")
            return self._error_response(request_id, -32602, "Parameter 'function' must be a string")
        
        logger.debug(f"Disassembling function {func} in file: {path}")
        code = self.client.get_disassembly(path, function_name=func)
        return self._wrap_result(request_id, "\n".join(code))
  • Helper method implementing the disassembly logic by searching functions and providing function info + decompiled HLIL as pseudo-disassembly via Binary Ninja HTTP API.
    def get_disassembly(self, file_path=None, function_name=None, function_address=None):
        """Get the disassembly of a specific function."""
        try:
            # Get function info first to get the address
            identifier = function_name if function_name else function_address
            if identifier is None:
                return ["No function identifier provided"]
                
            # Convert to string if it's not already
            if not isinstance(identifier, str):
                identifier = str(identifier)
                
            # Use the function info endpoint to get the function details
            # Since there's no direct disassembly endpoint, we'll use the function info
            # and format it as disassembly lines
            try:
                # First try to get function info
                response = self._request('GET', 'searchFunctions', params={"query": identifier})
                matches = response.get("matches", [])
                
                if not matches:
                    return [f"Function '{identifier}' not found"]
                
                # Get the first match
                func = matches[0]
                
                # Format the function info as disassembly lines
                disasm = []
                disasm.append(f"Function: {func.get('name', 'unknown')}")
                disasm.append(f"Address: {func.get('address', '0x0')}")
                
                # Try to get the decompiled code to show as pseudo-disassembly
                try:
                    decompiled = self.get_hlil(file_path, function_name=func.get('name'))
                    if decompiled and decompiled != "No decompilation available":
                        disasm.append("Decompiled code:")
                        for line in decompiled.split("\n"):
                            disasm.append(f"  {line}")
                except Exception:
                    pass
                
                return disasm
            except Exception as e:
                logger.warning(f"Failed to get function info: {e}")
                return [f"Error getting disassembly: {e}"]
        except Exception as e:
            logger.error(f"Failed to get disassembly: {e}")
            raise

Tool Definition Quality

Score is being calculated. Check back soon.

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/opensensor/bn_cline_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server