Skip to content

Commit 6876bbf

Browse files
committed
down
1 parent e123266 commit 6876bbf

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

Makefile

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,3 @@ src/Makefile:
77
./configure
88

99
.PHONY: $(SRC_TARGETS) help
10-
11-
help:
12-
@echo "Available targets:"
13-
@echo " all - Build the server (default)"
14-
@echo " check_deps - Check for required dependencies"
15-
@echo " clean - Remove built binaries"
16-
@echo " install - Install the server to /usr/local/bin"
17-
@echo " uninstall - Install the server to /usr/local/bin"
18-
@echo " user-install - Install the server to /usr/local/bin"
19-
@echo " user-uninstall - Install the server to /usr/local/bin"
20-
@echo " help - Display this help message"
21-
@echo
22-
@echo "Usage: make [target]"

src/r2mcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ char *r2mcp_cmd(ServerState *ss, const char *cmd) {
116116
char *res = r_core_cmd_str (core, filteredCommand);
117117
char *err = r2mcp_log_drain (ss);
118118
free (filteredCommand);
119-
r2state_settings (core);
119+
// r2state_settings (core);
120120
if (err) {
121121
char *newres = r_str_newf ("%s<log>\n%s\n</log>\n", res, err);
122122
free (res);

src/tools.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ static inline ToolMode current_mode(const ServerState *ss) {
3535

3636
static ToolSpec *tool(const char *name, const char *desc, const char *schema, int modes) {
3737
ToolSpec *t = R_NEW0 (ToolSpec);
38-
if (!t) {
39-
return NULL;
40-
}
4138
t->name = name;
4239
t->description = desc;
4340
t->schema_json = schema;
@@ -63,7 +60,7 @@ void tools_registry_init(ServerState *ss) {
6360
r_list_append (ss->tools, tool ("openFile", "Opens a binary file with radare2 for analysis <think>Call this tool before any other one from r2mcp. Use an absolute filePath</think>", "{\"type\":\"object\",\"properties\":{\"filePath\":{\"type\":\"string\",\"description\":\"Path to the file to open\"}},\"required\":[\"filePath\"]}", TOOL_MODE_NORMAL | M_MINI));
6461

6562
if (ss->enable_run_command_tool) {
66-
r_list_append(ss->tools, tool("runCommand", "Executes a raw radare2 command directly", "{\"type\":\"object\",\"properties\":{\"command\":{\"type\":\"string\",\"description\":\"The radare2 command to execute\"}},\"required\":[\"command\"]}", TOOL_MODE_NORMAL | M_MINI | M_HTTP));
63+
r_list_append (ss->tools, tool ("runCommand", "Executes a raw radare2 command directly", "{\"type\":\"object\",\"properties\":{\"command\":{\"type\":\"string\",\"description\":\"The radare2 command to execute\"}},\"required\":[\"command\"]}", TOOL_MODE_NORMAL | M_MINI | M_HTTP));
6764
}
6865

6966
r_list_append ( ss->tools, tool ("closeFile", "Close the currently open file", "{\"type\":\"object\",\"properties\":{}}", TOOL_MODE_NORMAL));
@@ -410,14 +407,14 @@ char *tools_call(ServerState *ss, const char *tool_name, RJson *tool_args) {
410407
return jsonrpc_error_response (-32603, "Relative paths are not allowed. Use an absolute path", NULL, NULL);
411408
}
412409
if (strstr (path, "/../") != NULL) {
413-
return jsonrpc_error_response(-32603, "Path traversal is not allowed (contains '/../')", NULL, NULL);
410+
return jsonrpc_error_response (-32603, "Path traversal is not allowed (contains '/../')", NULL, NULL);
414411
}
415412
if (ss->sandbox && *ss->sandbox) {
416-
size_t plen = strlen(path);
417-
size_t slen = strlen(ss->sandbox);
418-
if (slen == 0 || slen > plen || strncmp(path, ss->sandbox, slen) != 0 ||
413+
size_t plen = strlen (path);
414+
size_t slen = strlen (ss->sandbox);
415+
if (slen == 0 || slen > plen || strncmp (path, ss->sandbox, slen) != 0 ||
419416
(plen > slen && path[slen] != '/')) {
420-
return jsonrpc_error_response(-32603, "Access denied: path is outside of the sandbox", NULL, NULL);
417+
return jsonrpc_error_response (-32603, "Access denied: path is outside of the sandbox", NULL, NULL);
421418
}
422419
}
423420

@@ -733,21 +730,19 @@ char *tools_call(ServerState *ss, const char *tool_name, RJson *tool_args) {
733730
return response;
734731
}
735732

736-
if (!strcmp(tool_name, "runCommand")) {
737-
const char *command = r_json_get_str(tool_args, "command");
733+
if (!strcmp (tool_name, "runCommand")) {
734+
const char *command = r_json_get_str (tool_args, "command");
738735
if (!command) {
739-
return jsonrpc_error_response(-32602, "Missing required parameter: command", NULL, NULL);
736+
return jsonrpc_error_response (-32602, "Missing required parameter: command", NULL, NULL);
740737
}
741-
char *res = r2mcp_cmd(ss, command);
742-
char *o = jsonrpc_tooltext_response(res);
743-
free(res);
738+
char *res = r2mcp_cmd (ss, command);
739+
char *o = jsonrpc_tooltext_response (res);
740+
free (res);
744741
return o;
745742
}
746743

747-
{
748-
char *tmp = r_str_newf ("Unknown tool: %s", tool_name);
749-
char *err = jsonrpc_error_response (-32602, tmp, NULL, NULL);
750-
free (tmp);
751-
return err;
752-
}
744+
char *tmp = r_str_newf ("Unknown tool: %s", tool_name);
745+
char *err = jsonrpc_error_response (-32602, tmp, NULL, NULL);
746+
free (tmp);
747+
return err;
753748
}

0 commit comments

Comments
 (0)