binary-ninja-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +111 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +752 -0
- package/dist/tools.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Binary Ninja MCP Server (TypeScript)
|
|
2
|
+
|
|
3
|
+
This is the TypeScript implementation of the Binary Ninja MCP bridge server. It provides a standalone MCP server that connects to a running Binary Ninja instance and exposes its capabilities through the Model Context Protocol.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Standalone MCP Server**: Run independently with any MCP client
|
|
8
|
+
- **50+ Tools**: Full access to Binary Ninja's reverse engineering capabilities
|
|
9
|
+
- **Easy Configuration**: CLI options and environment variables for host/port
|
|
10
|
+
- **TypeScript**: Full type safety and better developer experience
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
### Using npx (Recommended)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx -y @binary-ninja/mcp-server
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Global Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g @binary-ninja/mcp-server
|
|
24
|
+
binary-ninja-mcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### From Source
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cd bridge
|
|
31
|
+
npm install
|
|
32
|
+
npm run build
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### Command Line Options
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Connect to default (localhost:9009)
|
|
41
|
+
npx -y @binary-ninja/mcp-server
|
|
42
|
+
|
|
43
|
+
# Connect to custom host/port
|
|
44
|
+
npx -y @binary-ninja/mcp-server --host 192.168.1.100 --port 9009
|
|
45
|
+
|
|
46
|
+
# Show help
|
|
47
|
+
npx -y @binary-ninja/mcp-server --help
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Environment Variables
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Set host and port via environment
|
|
54
|
+
BINJA_MCP_HOST=localhost BINJA_MCP_PORT=9009 npx -y @binary-ninja/mcp-server
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### MCP Client Configuration
|
|
58
|
+
|
|
59
|
+
#### Claude Desktop
|
|
60
|
+
|
|
61
|
+
Add to `~/.config/claude-desktop/claude_desktop_config.json`:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"mcpServers": {
|
|
66
|
+
"binary-ninja-mcp": {
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "@binary-ninja/mcp-server", "--host", "localhost", "--port", "9009"]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Cline
|
|
75
|
+
|
|
76
|
+
Add to your Cline MCP configuration:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"binary-ninja-mcp": {
|
|
82
|
+
"command": "npx",
|
|
83
|
+
"args": ["-y", "@binary-ninja/mcp-server"]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Custom Installation
|
|
90
|
+
|
|
91
|
+
If installed globally:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcpServers": {
|
|
96
|
+
"binary-ninja-mcp": {
|
|
97
|
+
"command": "binary-ninja-mcp",
|
|
98
|
+
"args": ["--host", "localhost", "--port", "9009"]
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Available Tools
|
|
105
|
+
|
|
106
|
+
### Function Analysis
|
|
107
|
+
|
|
108
|
+
- `list_methods` - List all function names with pagination
|
|
109
|
+
- `get_entry_points` - List entry point(s) of the loaded binary
|
|
110
|
+
- `search_functions_by_name` - Search functions by name substring
|
|
111
|
+
- `decompile_function` - Decompile a function to C code
|
|
112
|
+
- `get_il` - Get IL (HLIL/MLIL/LLIL) for a function
|
|
113
|
+
- `fetch_disassembly` - Get assembly mnemonics for a function
|
|
114
|
+
|
|
115
|
+
### Rename Tools
|
|
116
|
+
|
|
117
|
+
- `rename_function` - Rename a function
|
|
118
|
+
- `rename_single_variable` - Rename a single variable
|
|
119
|
+
- `rename_multi_variables` - Batch rename multiple variables
|
|
120
|
+
- `rename_data` - Rename a data label
|
|
121
|
+
|
|
122
|
+
### Comment Tools
|
|
123
|
+
|
|
124
|
+
- `set_comment` - Set comment at an address
|
|
125
|
+
- `get_comment` - Get comment at an address
|
|
126
|
+
- `delete_comment` - Delete comment at an address
|
|
127
|
+
- `set_function_comment` - Set function comment
|
|
128
|
+
- `get_function_comment` - Get function comment
|
|
129
|
+
- `delete_function_comment` - Delete function comment
|
|
130
|
+
|
|
131
|
+
### Type Tools
|
|
132
|
+
|
|
133
|
+
- `define_types` - Define types from C code
|
|
134
|
+
- `list_local_types` - List local types
|
|
135
|
+
- `search_types` - Search types by name
|
|
136
|
+
- `get_user_defined_type` - Get user defined type definition
|
|
137
|
+
- `get_type_info` - Get type information
|
|
138
|
+
- `declare_c_type` - Declare C type
|
|
139
|
+
- `retype_variable` - Retype a variable
|
|
140
|
+
- `set_local_variable_type` - Set local variable type
|
|
141
|
+
|
|
142
|
+
### Data Tools
|
|
143
|
+
|
|
144
|
+
- `list_data_items` - List data labels
|
|
145
|
+
- `hexdump_address` - Hexdump at address
|
|
146
|
+
- `hexdump_data` - Hexdump data symbol
|
|
147
|
+
- `get_data_decl` - Get data declaration and hexdump
|
|
148
|
+
|
|
149
|
+
### Cross-Reference Tools
|
|
150
|
+
|
|
151
|
+
- `get_xrefs_to` - Get xrefs to address
|
|
152
|
+
- `get_xrefs_to_field` - Get xrefs to struct field
|
|
153
|
+
- `get_xrefs_to_struct` - Get xrefs to struct
|
|
154
|
+
- `get_xrefs_to_type` - Get xrefs to type
|
|
155
|
+
- `get_xrefs_to_enum` - Get xrefs to enum
|
|
156
|
+
- `get_xrefs_to_union` - Get xrefs to union
|
|
157
|
+
|
|
158
|
+
### Binary Modification Tools
|
|
159
|
+
|
|
160
|
+
- `set_function_prototype` - Set function prototype
|
|
161
|
+
- `make_function_at` - Create function at address
|
|
162
|
+
- `list_platforms` - List available platforms
|
|
163
|
+
- `patch_bytes` - Patch bytes in binary
|
|
164
|
+
|
|
165
|
+
### Utility Tools
|
|
166
|
+
|
|
167
|
+
- `function_at` - Find function at address
|
|
168
|
+
- `get_stack_frame_vars` - Get stack frame variables
|
|
169
|
+
- `list_classes` - List classes/namespaces
|
|
170
|
+
- `list_namespaces` - List namespaces
|
|
171
|
+
- `list_segments` - List memory segments
|
|
172
|
+
- `list_sections` - List sections
|
|
173
|
+
- `list_imports` - List imports
|
|
174
|
+
- `list_exports` - List exports
|
|
175
|
+
- `list_strings` - List strings
|
|
176
|
+
- `list_all_strings` - List all strings (aggregated)
|
|
177
|
+
- `get_binary_status` - Get binary status
|
|
178
|
+
- `list_binaries` - List open binaries
|
|
179
|
+
- `select_binary` - Select active binary
|
|
180
|
+
- `format_value` - Format and annotate value
|
|
181
|
+
- `convert_number` - Convert number representations
|
|
182
|
+
|
|
183
|
+
## Requirements
|
|
184
|
+
|
|
185
|
+
- Node.js 18.0.0 or higher
|
|
186
|
+
- A running Binary Ninja instance with the MCP plugin
|
|
187
|
+
- MCP client (Claude Desktop, Cline, etc.)
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
GPL-3.0 - See LICENSE file for details.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for communicating with the Binary Ninja MCP server.
|
|
3
|
+
*/
|
|
4
|
+
export interface BinjaServerConfig {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class BinjaHttpClient {
|
|
9
|
+
private client;
|
|
10
|
+
private baseUrl;
|
|
11
|
+
constructor(config: BinjaServerConfig);
|
|
12
|
+
/**
|
|
13
|
+
* Perform a GET request and return raw text.
|
|
14
|
+
*/
|
|
15
|
+
getText(endpoint: string, params?: Record<string, string | number>, timeout?: number): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Perform a GET request and return parsed JSON.
|
|
18
|
+
*/
|
|
19
|
+
getJson<T = unknown>(endpoint: string, params?: Record<string, string | number>, timeout?: number): Promise<T | {
|
|
20
|
+
error: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Perform a GET request and return lines of text.
|
|
24
|
+
*/
|
|
25
|
+
getLines(endpoint: string, params?: Record<string, string | number>, timeout?: number): Promise<string[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Perform a POST request.
|
|
28
|
+
*/
|
|
29
|
+
post(endpoint: string, data: Record<string, unknown> | string): Promise<string>;
|
|
30
|
+
private handleError;
|
|
31
|
+
private getErrorMessage;
|
|
32
|
+
}
|
|
33
|
+
export declare function createClient(host?: string, port?: number): BinjaHttpClient;
|
|
34
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,iBAAiB;IAChC,IAAI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
|
|
6
|
+
client;
|
|
7
|
+
baseUrl;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.baseUrl = `http://${config.host}:${config.port}`;
|
|
10
|
+
this.client = axios.create({
|
|
11
|
+
baseURL: this.baseUrl,
|
|
12
|
+
timeout: 30000, // 30 seconds
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Perform a GET request and return raw text.
|
|
17
|
+
*/
|
|
18
|
+
async getText(endpoint, params = {}, timeout) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await this.client.get(endpoint, {
|
|
21
|
+
params,
|
|
22
|
+
timeout,
|
|
23
|
+
responseType: "text",
|
|
24
|
+
});
|
|
25
|
+
if (response.status >= 200 && response.status < 300) {
|
|
26
|
+
return response.data;
|
|
27
|
+
}
|
|
28
|
+
return `Error ${response.status}: ${response.data}`;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return this.handleError(error, "GET", endpoint);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Perform a GET request and return parsed JSON.
|
|
36
|
+
*/
|
|
37
|
+
async getJson(endpoint, params = {}, timeout) {
|
|
38
|
+
try {
|
|
39
|
+
const response = await this.client.get(endpoint, {
|
|
40
|
+
params,
|
|
41
|
+
timeout,
|
|
42
|
+
});
|
|
43
|
+
response.data;
|
|
44
|
+
if (response.status >= 200 && response.status < 300) {
|
|
45
|
+
return response.data;
|
|
46
|
+
}
|
|
47
|
+
// Non-OK: return parsed error object if available
|
|
48
|
+
if (response.data && typeof response.data === "object" && "error" in response.data) {
|
|
49
|
+
return response.data;
|
|
50
|
+
}
|
|
51
|
+
return { error: `Error ${response.status}: ${response.statusText}` };
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const errorMsg = this.getErrorMessage(error);
|
|
55
|
+
return { error: `Request failed: ${errorMsg}` };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Perform a GET request and return lines of text.
|
|
60
|
+
*/
|
|
61
|
+
async getLines(endpoint, params = {}, timeout) {
|
|
62
|
+
const text = await this.getText(endpoint, params, timeout);
|
|
63
|
+
return text.split("\n");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Perform a POST request.
|
|
67
|
+
*/
|
|
68
|
+
async post(endpoint, data) {
|
|
69
|
+
try {
|
|
70
|
+
let response;
|
|
71
|
+
if (typeof data === "string") {
|
|
72
|
+
response = await this.client.post(endpoint, data, {
|
|
73
|
+
headers: { "Content-Type": "text/plain" },
|
|
74
|
+
responseType: "text",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
response = await this.client.post(endpoint, data, {
|
|
79
|
+
responseType: "text",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (response.status >= 200 && response.status < 300) {
|
|
83
|
+
return response.data.trim();
|
|
84
|
+
}
|
|
85
|
+
return `Error ${response.status}: ${response.data}`;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return this.handleError(error, "POST", endpoint);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
handleError(error, method, endpoint) {
|
|
92
|
+
const msg = this.getErrorMessage(error);
|
|
93
|
+
return `Error: ${method} ${endpoint} failed: ${msg}`;
|
|
94
|
+
}
|
|
95
|
+
getErrorMessage(error) {
|
|
96
|
+
if (axios.isAxiosError(error)) {
|
|
97
|
+
if (error.response) {
|
|
98
|
+
return `Server returned ${error.response.status}: ${error.response.statusText}`;
|
|
99
|
+
}
|
|
100
|
+
if (error.request) {
|
|
101
|
+
return "No response from server - is Binary Ninja running with the MCP plugin?";
|
|
102
|
+
}
|
|
103
|
+
return error.message;
|
|
104
|
+
}
|
|
105
|
+
return String(error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function createClient(host = "localhost", port = 9009) {
|
|
109
|
+
return new BinjaHttpClient({ host, port });
|
|
110
|
+
}
|
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C,KAAK,CAAC,CAAC;IACvB,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAC,OAAe,WAAW,EAAE,OAAe,IAAI;IAC1E,OAAO,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Binary Ninja MCP Server - Main entry point
|
|
4
|
+
*
|
|
5
|
+
* This MCP server connects to a running Binary Ninja instance with the MCP plugin
|
|
6
|
+
* and exposes its capabilities through the Model Context Protocol.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx @binary-ninja/mcp-server [options]
|
|
10
|
+
*
|
|
11
|
+
* Options:
|
|
12
|
+
* --host <host> Binary Ninja MCP server host (default: localhost)
|
|
13
|
+
* --port <port> Binary Ninja MCP server port (default: 9009)
|
|
14
|
+
* --help Show this help message
|
|
15
|
+
*
|
|
16
|
+
* Environment variables:
|
|
17
|
+
* BINJA_MCP_HOST Binary Ninja MCP server host
|
|
18
|
+
* BINJA_MCP_PORT Binary Ninja MCP server port
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Binary Ninja MCP Server - Main entry point
|
|
4
|
+
*
|
|
5
|
+
* This MCP server connects to a running Binary Ninja instance with the MCP plugin
|
|
6
|
+
* and exposes its capabilities through the Model Context Protocol.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx @binary-ninja/mcp-server [options]
|
|
10
|
+
*
|
|
11
|
+
* Options:
|
|
12
|
+
* --host <host> Binary Ninja MCP server host (default: localhost)
|
|
13
|
+
* --port <port> Binary Ninja MCP server port (default: 9009)
|
|
14
|
+
* --help Show this help message
|
|
15
|
+
*
|
|
16
|
+
* Environment variables:
|
|
17
|
+
* BINJA_MCP_HOST Binary Ninja MCP server host
|
|
18
|
+
* BINJA_MCP_PORT Binary Ninja MCP server port
|
|
19
|
+
*/
|
|
20
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
21
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
22
|
+
import { createClient } from "./client.js";
|
|
23
|
+
import { registerTools } from "./tools.js";
|
|
24
|
+
// Parse command line arguments
|
|
25
|
+
function parseArgs() {
|
|
26
|
+
const args = process.argv.slice(2);
|
|
27
|
+
let host = "localhost";
|
|
28
|
+
let port = 9009;
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const arg = args[i];
|
|
31
|
+
switch (arg) {
|
|
32
|
+
case "--host":
|
|
33
|
+
if (i + 1 < args.length) {
|
|
34
|
+
host = args[++i];
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
case "--port":
|
|
38
|
+
if (i + 1 < args.length) {
|
|
39
|
+
port = parseInt(args[++i], 10);
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case "--help":
|
|
43
|
+
case "-h":
|
|
44
|
+
console.log(`Binary Ninja MCP Server
|
|
45
|
+
|
|
46
|
+
Usage: npx binary-ninja-mcp [options]
|
|
47
|
+
|
|
48
|
+
Options:
|
|
49
|
+
--host <host> Binary Ninja MCP server host (default: localhost)
|
|
50
|
+
--port <port> Binary Ninja MCP server port (default: 9009)
|
|
51
|
+
--help, -h Show this help message
|
|
52
|
+
|
|
53
|
+
Environment variables:
|
|
54
|
+
BINJA_MCP_HOST Binary Ninja MCP server host
|
|
55
|
+
BINJA_MCP_PORT Binary Ninja MCP server port
|
|
56
|
+
`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Environment variables override defaults
|
|
62
|
+
if (process.env.BINJA_MCP_HOST) {
|
|
63
|
+
host = process.env.BINJA_MCP_HOST;
|
|
64
|
+
}
|
|
65
|
+
if (process.env.BINJA_MCP_PORT) {
|
|
66
|
+
port = parseInt(process.env.BINJA_MCP_PORT, 10) || port;
|
|
67
|
+
}
|
|
68
|
+
return { host, port };
|
|
69
|
+
}
|
|
70
|
+
// Main entry point
|
|
71
|
+
async function main() {
|
|
72
|
+
const { host, port } = parseArgs();
|
|
73
|
+
console.error(`Binary Ninja MCP Server connecting to ${host}:${port}`);
|
|
74
|
+
// Create MCP server
|
|
75
|
+
const server = new McpServer({
|
|
76
|
+
name: "binary-ninja-mcp",
|
|
77
|
+
version: "1.0.0",
|
|
78
|
+
});
|
|
79
|
+
// Create HTTP client for Binary Ninja
|
|
80
|
+
const client = createClient(host, port);
|
|
81
|
+
// Register all tools
|
|
82
|
+
registerTools(server, client);
|
|
83
|
+
// Create stdio transport
|
|
84
|
+
const transport = new StdioServerTransport();
|
|
85
|
+
// Connect and run
|
|
86
|
+
await server.connect(transport);
|
|
87
|
+
console.error("Binary Ninja MCP Server ready");
|
|
88
|
+
}
|
|
89
|
+
main().catch((error) => {
|
|
90
|
+
console.error("Fatal error:", error);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,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I,IAAI,CAAC;IAC1D,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC;AAED,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,CAAC;IAEnC,OAAO,CAAC,KAAK,CAAC,yCAAyC,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAEvE,oBAAoB;IACpB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,sCAAsC;IACtC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAExC,qBAAqB;IACrB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B,yBAAyB;IACzB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,kBAAkB;IAClB,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACjD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Tool definitions for Binary Ninja integration.
|
|
3
|
+
*/
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import { BinjaHttpClient } from "./client.js";
|
|
6
|
+
export declare function registerTools(server: McpServer, client: BinjaHttpClient): void;
|
|
7
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAikC9E"}
|