Skip to content

Commit d53f0a8

Browse files
committed
Modernized MCP architecture. Consolidated tool namespace, added resources and prompts.
1 parent 3e26371 commit d53f0a8

File tree

12 files changed

+3125
-661
lines changed

12 files changed

+3125
-661
lines changed

README.md

Lines changed: 253 additions & 167 deletions
Large diffs are not rendered by default.

__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
Binary Ninja requires this __init__.py file in the root directory to recognize the plugin.
66
"""
77

8+
# Fix pywin32 paths on Windows (required for mcp library)
9+
# Binary Ninja doesn't process .pth files, so we add the paths manually
10+
import sys
11+
import os
12+
if sys.platform == 'win32':
13+
_site_packages = os.path.join(os.environ.get('APPDATA', ''), 'Binary Ninja', 'python310', 'site-packages')
14+
_win32_paths = [
15+
os.path.join(_site_packages, 'win32'),
16+
os.path.join(_site_packages, 'win32', 'lib'),
17+
os.path.join(_site_packages, 'Pythonwin'),
18+
]
19+
for _p in _win32_paths:
20+
if _p not in sys.path and os.path.isdir(_p):
21+
sys.path.insert(0, _p)
22+
823
import logging
924

1025
# Configure logging early
@@ -56,7 +71,7 @@ def on_binaryview_analysis_completion(bv):
5671
except ImportError as import_err:
5772
logger.error(f"Failed to import BinAssistMCP modules: {import_err}")
5873
bn.log_error(f"BinAssistMCP plugin failed to load - missing dependencies: {import_err}")
59-
bn.log_info("To fix this, install BinAssistMCP dependencies: pip install anyio hypercorn mcp trio pydantic pydantic-settings click")
74+
bn.log_info("To fix this, install BinAssistMCP dependencies: pip install anyio hypercorn mcp pydantic pydantic-settings click")
6075

6176
except Exception as plugin_err:
6277
logger.error(f"Failed to initialize BinAssistMCP plugin: {plugin_err}")

binassistmcp-on-windows.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# BinAssist on Windows - Installation Guide
2+
3+
This guide covers the steps required to get BinAssist and BinAssistMCP plugins working on Windows with Binary Ninja.
4+
5+
## Prerequisites
6+
7+
- Binary Ninja installed (typically at `C:\Program Files\Vector35\BinaryNinja\`)
8+
- Plugins cloned to `%APPDATA%\Binary Ninja\plugins\`
9+
- `BinAssist\`
10+
- `BinAssistMCP\`
11+
12+
## The Problem
13+
14+
Binary Ninja on Windows uses a bundled Python environment, but:
15+
1. It doesn't fully process `.pth` files during site initialization
16+
2. The `mcp` library requires `pywin32`, which needs special DLL handling on Windows
17+
3. Packages must be installed to Binary Ninja's user site-packages, not the system Python
18+
19+
## Step 1: Configure Binary Ninja Python Environment
20+
21+
In Binary Ninja, go to **Settings → Python** and configure:
22+
- **Python Environment**: `C:\Program Files\Vector35\BinaryNinja\plugins\python\python310.dll`
23+
- **Site-packages**: `C:/Users/<username>/AppData/Roaming/Binary Ninja/python310/site-packages`
24+
25+
This ensures packages are installed to a user-writable location.
26+
27+
## Step 2: Install pywin32 DLLs (Administrator Required)
28+
29+
The `pywin32` package includes DLLs that must be accessible at runtime. Copy them to the Binary Ninja installation folder.
30+
31+
Open **Command Prompt as Administrator** and run:
32+
33+
```cmd
34+
copy "C:\Users\<username>\AppData\Roaming\Binary Ninja\python310\site-packages\pywin32_system32\*.dll" "C:\Program Files\Vector35\BinaryNinja\"
35+
```
36+
37+
Or if pywin32 is in the Program Files site-packages:
38+
39+
```cmd
40+
copy "C:\Program Files\Vector35\BinaryNinja\plugins\python\Lib\site-packages\pywin32_system32\*.dll" "C:\Program Files\Vector35\BinaryNinja\"
41+
```
42+
43+
This copies `pythoncom310.dll` and `pywintypes310.dll` to a location on the DLL search path.
44+
45+
## Step 3: Install Plugin Dependencies
46+
47+
Install all required packages to Binary Ninja's user site-packages using `--target`:
48+
49+
**Install pywin32:**
50+
```cmd
51+
"C:\Program Files\Vector35\BinaryNinja\plugins\python\python.exe" -m pip install --target "C:\Users\<username>\AppData\Roaming\Binary Ninja\python310\site-packages" pywin32
52+
```
53+
54+
**Install BinAssist dependencies:**
55+
```cmd
56+
"C:\Program Files\Vector35\BinaryNinja\plugins\python\python.exe" -m pip install --target "C:\Users\<username>\AppData\Roaming\Binary Ninja\python310\site-packages" -r "C:\Users\<username>\AppData\Roaming\Binary Ninja\plugins\BinAssist\requirements.txt"
57+
```
58+
59+
**Install BinAssistMCP dependencies:**
60+
```cmd
61+
"C:\Program Files\Vector35\BinaryNinja\plugins\python\python.exe" -m pip install --target "C:\Users\<username>\AppData\Roaming\Binary Ninja\python310\site-packages" -r "C:\Users\<username>\AppData\Roaming\Binary Ninja\plugins\BinAssistMCP\requirements.txt"
62+
```
63+
64+
> **Note:** Replace `<username>` with your actual Windows username, or use `%APPDATA%` in the path (though `--target` may not expand environment variables).
65+
66+
## Step 4: Restart Binary Ninja
67+
68+
Close all Binary Ninja instances and restart. The plugins should now load correctly.
69+
70+
## Verification
71+
72+
In Binary Ninja's Python console, verify the imports work:
73+
74+
```python
75+
import pywintypes
76+
print("pywintypes OK")
77+
78+
import mcp
79+
print("mcp OK")
80+
```
81+
82+
## Notes: pywin32 Path Fix (Already Applied - For Reference Only)
83+
84+
Binary Ninja doesn't process `.pth` files, so the `win32` and `win32\lib` directories aren't automatically added to `sys.path`.
85+
86+
Both plugins include a fix in their `__init__.py` that adds these paths before importing the `mcp` library:
87+
88+
```python
89+
# Fix pywin32 paths on Windows (required for mcp library)
90+
# Binary Ninja doesn't process .pth files, so we add the paths manually
91+
import sys
92+
import os
93+
if sys.platform == 'win32':
94+
_site_packages = os.path.join(os.environ.get('APPDATA', ''), 'Binary Ninja', 'python310', 'site-packages')
95+
_win32_paths = [
96+
os.path.join(_site_packages, 'win32'),
97+
os.path.join(_site_packages, 'win32', 'lib'),
98+
os.path.join(_site_packages, 'Pythonwin'),
99+
]
100+
for _p in _win32_paths:
101+
if _p not in sys.path and os.path.isdir(_p):
102+
sys.path.insert(0, _p)
103+
```
104+
105+
This code is already included in the plugin source.
106+
107+
108+
## Troubleshooting
109+
110+
### "ModuleNotFoundError: No module named 'pywintypes'"
111+
112+
- Ensure the DLLs were copied to `C:\Program Files\Vector35\BinaryNinja\`
113+
- Verify the path fix is in `__init__.py` and runs before any mcp imports
114+
- Check that `win32\lib\pywintypes.py` exists in your site-packages
115+
116+
### "Access is denied" when installing packages
117+
118+
- Use the `--target` flag to install to the roaming site-packages
119+
- Or run the command prompt as Administrator
120+
121+
### Packages installing to wrong location
122+
123+
- Always use the full path to Binary Ninja's Python:
124+
```
125+
"C:\Program Files\Vector35\BinaryNinja\plugins\python\python.exe"
126+
```
127+
- Use `--target` to explicitly specify the destination
128+
129+
### Check sys.path
130+
131+
In Binary Ninja's Python console:
132+
133+
```python
134+
import sys
135+
print('\n'.join(sys.path))
136+
```
137+
138+
Ensure your roaming site-packages and the win32 subdirectories are listed.

plugin.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"description": "Comprehensive MCP server for Binary Ninja with SSE transport support",
1414
"license": {
1515
"name": "MIT",
16-
"text": "Copyright (c) 2025\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
16+
"text": "Copyright (c) 2026\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."
1717
},
1818
"platforms": [
1919
"Darwin",
@@ -25,15 +25,14 @@
2525
"Linux": "Install via Binary Ninja plugin manager or copy to ~/.binaryninja/plugins/",
2626
"Windows": "Install via Binary Ninja plugin manager or copy to %APPDATA%\\Binary Ninja\\plugins\\"
2727
},
28-
"version": "1.1.0",
28+
"version": "2.0.0",
2929
"minimumbinaryninjaversion": 5000,
3030
"dependencies": {
3131
"pip": [
3232
"anyio>=4.6.0",
3333
"hypercorn>=0.17.0",
34-
"mcp>=1.23.3",
34+
"mcp>=1.23.3",
3535
"click>=8.0.0",
36-
"trio>=0.27.0",
3736
"pydantic>=2.0.0",
3837
"pydantic-settings>=2.0.0"
3938
]

0 commit comments

Comments
 (0)