feat: add validation for missing name parameter in tools/call requests
This commit is contained in:
committed by
Igor Lins e Silva
parent
55d79dc8cd
commit
a85d432b54
@@ -2007,6 +2007,12 @@ def handle_request(request):
|
||||
},
|
||||
}
|
||||
elif method == "tools/call":
|
||||
if not isinstance(params, dict) or "name" not in params:
|
||||
return {
|
||||
"jsonrpc": "2.0",
|
||||
"id": req_id,
|
||||
"error": {"code": -32602, "message": "Invalid params: 'name' is required for tools/call"},
|
||||
}
|
||||
tool_name = params.get("name")
|
||||
tool_args = params.get("arguments") or {}
|
||||
if tool_name not in TOOLS:
|
||||
|
||||
@@ -148,6 +148,20 @@ class TestHandleRequest:
|
||||
)
|
||||
assert resp["error"]["code"] == -32601
|
||||
|
||||
def test_tools_call_missing_params(self):
|
||||
from mempalace.mcp_server import handle_request
|
||||
|
||||
for bad_params in [None, {}, {"arguments": {}}]:
|
||||
resp = handle_request(
|
||||
{
|
||||
"method": "tools/call",
|
||||
"id": 15,
|
||||
"params": bad_params,
|
||||
}
|
||||
)
|
||||
assert resp["error"]["code"] == -32602
|
||||
assert "Invalid params" in resp["error"]["message"]
|
||||
|
||||
def test_unknown_method(self):
|
||||
from mempalace.mcp_server import handle_request
|
||||
|
||||
|
||||
Reference in New Issue
Block a user