
BinjaLattice
STDIOSecure communication protocol for Binary Ninja enabling interaction with external MCP servers and tools.
Secure communication protocol for Binary Ninja enabling interaction with external MCP servers and tools.
BinjaLattice is a secure communication protocol for Binary Ninja that enables interaction with external Model Context Protocol (MCP) servers and tools. It provides a structured way to acquire information from Binary Ninja and the ability to modify an active Binary Ninja database over HTTP with a REST API.
Copy lattice_server_plugin.py
to your Binary Ninja plugins directory:
~/.binaryninja/plugins/
~/Library/Application Support/Binary Ninja/plugins/
%APPDATA%\Binary Ninja\plugins\
Create a virtual environment pip -m venv venv-test
(or your preferred dependency manager)
Activate your virtual environment and install required Python dependencies:
pip install -r requirements.txt
(or your preferred method)Plugins > Start Lattice Protocol Server
BNJLAT
environment variable in your MCP configurationExample MCP configuration (mcp.json
) from Cursor:
{ "mcpServers": { "binja-lattice-mcp": { "command": "/path/to/venv/bin/python", "args": ["/path/to/mcp_server.py"], "env": { "BNJLAT": "your_api_key_here" } } } }
The following tools are available through the MCP server:
get_all_function_names
: Get a list of all function names in the binaryget_binary_info
: Get information about the binary being analyzedupdate_function_name
: Update the name of a functionupdate_variable_name
: Change variable name within function to specified nameget_global_variable_data
: Get data from global variableadd_comment_to_address
: Add a comment to a specific addressadd_comment_to_function
: Add a comment to a functionget_function_disassembly
: Get disassembly for a functionget_function_pseudocode
: Get pseudocode for a functionget_function_variables
: Get variables and parameters for a functionget_cross_references_to_function
: Get cross references to a functionThe Lattice
client library provides a Python interface for interacting with the BinjaLattice server:
from lib.lattice import Lattice # Initialize client client = Lattice(host='localhost', port=9000, use_ssl=False) # Authenticate with API key client.authenticate("username", "API_KEY") # Example: Get binary information binary_info = client.get_binary_info() # Example: Update function name client.update_function_name("old_name", "new_name") # Example: Add comment to function client.add_comment_to_function("function_name", "This function handles authentication")
The project includes lattice_client.py
, which provides an interactive command-line interface for testing and debugging the BinjaLattice server:
python lattice_client.py --host localhost --port 9000 [--ssl] --username user --password YOUR_API_KEY
--host
: Server host (default: localhost)--port
: Server port (default: 9000)--ssl
: Enable SSL/TLS encryption--interactive
, -i
: Run in interactive mode--username
: Username for authentication--password
: Password/API key for authentication--token
: Authentication token (if you have one from previous authentication)The interactive mode provides a menu-driven interface with the following options:
Example usage with interactive mode:
python lattice_client.py -i --ssl --username user --password YOUR_API_KEY
You can also use the client to execute single commands:
# Get binary information python lattice_client.py --username user --password YOUR_API_KEY --get-binary-info # Get function disassembly python lattice_client.py --username user --password YOUR_API_KEY --get-function-disassembly "main" # Add comment to a function python lattice_client.py --username user --password YOUR_API_KEY --add-comment-to-function "main" "Entry point of the program"
plugin/lattice_server_plugin.py
mcp_server.py
lib/lattice.py
To add new functionality:
LatticeRequestHandler
class in lattice_server_plugin.py
Lattice
class in lib/lattice.py
mcp_server.py
requirements.txt
install_api.py
provided in your Binary Ninja installation directorypytest tests/ -v