decompile_function
Convert binary function code to readable C code for analysis and debugging in Binary Ninja.
Instructions
Decompile a function to C
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| function | Yes |
Implementation Reference
- bridge/bn_mcp_bridge_stdio.py:67-72 (handler)FastMCP stdio bridge handler for the decompile_function tool. Proxies the function name via HTTP POST to localhost:9009/decompile for decompilation by Binary Ninja server.@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)
- bridge/bn_mcp_bridge_http.py:368-385 (handler)FastMCP SSE bridge handler for the decompile_function tool. Proxies the function name via HTTP POST to localhost:9009/decompile, with error handling and JSON normalization.@mcp.tool() def decompile_function(name: str): """ Decompile a function by exact name. """ try: if not name or not name.strip(): return {"ok": False, "error": "Function name cannot be empty"} data, err = _request("POST", "decompile", data=name.strip()) if err: return {"ok": False, "error": err} # Normalize to JSON code = data if isinstance(data, str) else json.dumps(data) return {"ok": True, "code": code} except Exception as e: logger.error(f"Error in decompile_function: {e}") return {"ok": False, "error": str(e)}
- binaryninja-mcp-bridge.js:99-102 (schema)Input schema definition for decompile_function tool (requires path and function params) in the JS MCP bridge's list_tools handler.name: "decompile_function", description: "Decompile a function to C", inputSchema: zodToJsonSchema(FunctionSchema), }
- binaryninja-mcp-bridge.js:164-173 (handler)Handler case in JS MCP bridge's call_tool for decompile_function: validates arguments with Zod schema and proxies JSON-RPC call 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;
- binaryninja_mcp_http_server.py:70-81 (schema)Explicit JSON schema for decompile_function tool registered in MCP_TOOLS list for the HTTP MCP server."name": "decompile_function", "description": "Decompile to C", "streaming": False, "inputSchema": { "type": "object", "properties": { "path": {"type": "string"}, "function": {"type": "string"} }, "required": ["path", "function"] } },