From 9d6daaed8c10e705032ed96405e701cf41451f1c Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sun, 7 Dec 2025 02:26:45 +0530 Subject: [PATCH] SimpleSallap:SimpleMCP:Body Bytes to Json within mcp_run Given that there could be other service paths beyond /mcp exposed in future, and given that it is not necessary that their post body contain json data, so move conversion to json to within mcp_run handler. While retaining reading of the body in the generic do_POST ensures that the read size limit is implicitly enforced, whether /mcp now or any other path in future. --- tools/server/public_simplechat/local.tools/simplemcp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/server/public_simplechat/local.tools/simplemcp.py b/tools/server/public_simplechat/local.tools/simplemcp.py index 34c7a9cf15..c2c167dba0 100644 --- a/tools/server/public_simplechat/local.tools/simplemcp.py +++ b/tools/server/public_simplechat/local.tools/simplemcp.py @@ -122,7 +122,8 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler): tcl = mTC.MCPToolsList(oRPC["id"], mTC.MCPTLResult(gMe.op.toolManager.meta())) self.send_mcp(200, "tools/list follows", tcl) - def mcp_run(self, oRPC: Any): + def mcp_run(self, body: bytes): + oRPC = json.loads(body) if oRPC["method"] == "tools/call": self.mcp_toolscall(oRPC) elif oRPC["method"] == "tools/list": @@ -140,14 +141,13 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler): if not acGot.callOk: self.send_error(acGot.statusCode, acGot.statusMsg) pr = urllib.parse.urlparse(self.path) - print(f"DBUG:ProxyHandler:GET:{pr}") + print(f"DBUG:PH:Post:{pr}") if pr.path != '/mcp': self.send_error(400, f"WARN:UnknownPath:{pr.path}") body = self.rfile.read(gMe.nw.maxReadBytes) if len(body) == gMe.nw.maxReadBytes: self.send_error(400, f"WARN:RequestOverflow:{pr.path}") - oRPC = json.loads(body) - self.mcp_run(oRPC) + self.mcp_run(body) def do_POST(self): """