Skip to main content
Glama
opensensor

Binary Ninja Cline MCP Server

by opensensor

decompile_function

Convert binary functions into readable C code by specifying the binary path and function name, enabling analysis of compiled programs within the Binary Ninja environment.

Instructions

Decompile a function to C

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
functionYes
pathYes

Implementation Reference

  • MCP tool handler decorated with @mcp.tool() that proxies the decompile_function request to the Binary Ninja HTTP server endpoint /decompile.
    @mcp.tool() def decompile_function(name: str) -> str: """ Decompile a specific function by name and return the decompiled C code. """ return safe_post("decompile", name)
  • Tool registration in the list_tools handler, defining the name, description, and input schema for decompile_function.
    { name: "decompile_function", description: "Decompile a function to C", inputSchema: zodToJsonSchema(FunctionSchema), }
  • Handler case in the CallToolRequestSchema that validates arguments with Zod schema and forwards to Binary Ninja HTTP server.
    case "decompile_function": { try { const args = FunctionSchema.parse(request.params.arguments); result = await callBinaryNinjaServer("decompile_function", args); } catch (error) { console.error(`[ERROR] Failed to parse arguments for decompile_function: ${error.message}`); console.error(`[ERROR] Arguments received: ${JSON.stringify(request.params.arguments)}`); throw error; } break;
  • Input schema definition for the decompile_function tool in the MCP_TOOLS list.
    "name": "decompile_function", "description": "Decompile to C", "streaming": False, "inputSchema": { "type": "object", "properties": { "path": {"type": "string"}, "function": {"type": "string"} }, "required": ["path", "function"] } },
  • HTTP MCP server handler for decompile_function that extracts path and function name, calls client.get_hlil, and wraps the result.
    elif method == "decompile_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"Decompiling function {func} in file: {path}") hlil = self.client.get_hlil(path, function_name=func) return self._wrap_result(request_id, "\n".join(hlil) if isinstance(hlil, list) else str(hlil))

Other Tools

Related 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