File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,15 @@ static bool is_valid_json_response(const char *str) {
5050 if (!str || * str != '{' ) {
5151 return false;
5252 }
53- RJson * json = r_json_parse ((char * )str );
54- if (!json ) {
55- return false;
56- }
57- r_json_free (json );
58- return true;
53+ char * copy = strdup (str );
54+ RJson * json = r_json_parse (copy );
55+ if (json ) {
56+ free (copy );
57+ r_json_free (json );
58+ return true;
59+ }
60+ free (copy );
61+ return false;
5962}
6063
6164// Local I/O mode helper (moved from utils.inc.c to avoid unused warnings in other TUs)
@@ -305,8 +308,8 @@ static bool is_valid_mcp_method(const char *method) {
305308 if (!method || !* method ) {
306309 return false;
307310 }
308- // MCP method names must be lowercase, dot-separated strings
309- // Format: category/name or category/subcategory/name
311+ // MCP method names must be lowercase letters with optional '/' or '.' separators
312+ // Examples: initialize, ping, tools/list, notifications/initialized
310313 for (int i = 0 ; method [i ]; i ++ ) {
311314 char c = method [i ];
312315 if (c == '/' || c == '.' ) {
@@ -316,8 +319,7 @@ static bool is_valid_mcp_method(const char *method) {
316319 return false;
317320 }
318321 }
319- // Must contain at least one '/' to be valid
320- return strchr (method , '/' ) != NULL ;
322+ return true;
321323}
322324
323325static char * handle_mcp_request (ServerState * ss , const char * method , RJson * params , const char * id ) {
You can’t perform that action at this time.
0 commit comments