@@ -239,9 +239,9 @@ def test_static_files(self, test_client):
239239class TestProtocolEndpoints :
240240 """Tests for MCP protocol operations: initialize, ping, notifications, etc."""
241241
242- @patch ("mcpgateway.main.validate_request" )
242+ # @patch("mcpgateway.main.validate_request")
243243 @patch ("mcpgateway.main.session_registry.handle_initialize_logic" )
244- def test_initialize_endpoint (self , mock_handle_initialize , _mock_validate , test_client , auth_headers ):
244+ def test_initialize_endpoint (self , mock_handle_initialize , test_client , auth_headers ):
245245 """Test MCP protocol initialization."""
246246 mock_capabilities = ServerCapabilities (
247247 prompts = {"listChanged" : True },
@@ -271,8 +271,8 @@ def test_initialize_endpoint(self, mock_handle_initialize, _mock_validate, test_
271271 assert body ["protocolVersion" ] == PROTOCOL_VERSION
272272 mock_handle_initialize .assert_called_once ()
273273
274- @patch ("mcpgateway.main.validate_request" )
275- def test_ping_endpoint (self , _mock_validate , test_client , auth_headers ):
274+ # @patch("mcpgateway.main.validate_request")
275+ def test_ping_endpoint (self , test_client , auth_headers ):
276276 """Test MCP ping endpoint."""
277277 req = {"jsonrpc" : "2.0" , "method" : "ping" , "id" : "test-id" }
278278 response = test_client .post ("/protocol/ping" , json = req , headers = auth_headers )
@@ -807,8 +807,8 @@ def test_rpc_tool_invocation(self, mock_invoke_tool, test_client, auth_headers):
807807 mock_invoke_tool .assert_called_once_with (db = ANY , name = "test_tool" , arguments = {"param" : "value" })
808808
809809 @patch ("mcpgateway.main.prompt_service.get_prompt" )
810- @patch ("mcpgateway.main.validate_request" )
811- def test_rpc_prompt_get (self , _mock_validate , mock_get_prompt , test_client , auth_headers ):
810+ # @patch("mcpgateway.main.validate_request")
811+ def test_rpc_prompt_get (self , mock_get_prompt , test_client , auth_headers ):
812812 """Test prompt retrieval via JSON-RPC."""
813813 mock_get_prompt .return_value = {
814814 "messages" : [{"role" : "user" , "content" : {"type" : "text" , "text" : "Rendered prompt" }}],
@@ -829,8 +829,8 @@ def test_rpc_prompt_get(self, _mock_validate, mock_get_prompt, test_client, auth
829829 mock_get_prompt .assert_called_once_with (ANY , "test_prompt" , {"param" : "value" })
830830
831831 @patch ("mcpgateway.main.tool_service.list_tools" )
832- @patch ("mcpgateway.main.validate_request" )
833- def test_rpc_list_tools (self , _mock_validate , mock_list_tools , test_client , auth_headers ):
832+ # @patch("mcpgateway.main.validate_request")
833+ def test_rpc_list_tools (self , mock_list_tools , test_client , auth_headers ):
834834 """Test listing tools via JSON-RPC."""
835835 mock_tool = MagicMock ()
836836 mock_tool .model_dump .return_value = MOCK_TOOL_READ
@@ -849,26 +849,26 @@ def test_rpc_list_tools(self, _mock_validate, mock_list_tools, test_client, auth
849849 assert isinstance (body , list )
850850 mock_list_tools .assert_called_once ()
851851
852- @patch ("mcpgateway.main.validate_request " )
853- def test_rpc_invalid_request (self , mock_validate , test_client , auth_headers ):
852+ @patch ("mcpgateway.main.RPCRequest " )
853+ def test_rpc_invalid_request (self , mock_rpc_request , test_client , auth_headers ):
854854 """Test RPC error handling for invalid requests."""
855- mock_validate .side_effect = Exception ("Invalid request " )
855+ mock_rpc_request .side_effect = ValueError ("Invalid method " )
856856
857857 req = {"jsonrpc" : "1.0" , "id" : "test-id" , "method" : "invalid_method" }
858858 response = test_client .post ("/rpc/" , json = req , headers = auth_headers )
859859
860- assert response .status_code == 200
860+ assert response .status_code == 422
861861 body = response .json ()
862- assert "error" in body and "Invalid request" in body [ "error" ][ "data" ]
862+ assert "Method invalid" in body . get ( "message" )
863863
864864 def test_rpc_invalid_json (self , test_client , auth_headers ):
865865 """Test RPC error handling for malformed JSON."""
866866 headers = auth_headers
867867 headers ["content-type" ] = "application/json"
868868 response = test_client .post ("/rpc/" , content = "invalid json" , headers = headers )
869- assert response .status_code == 200 # Returns error response, not HTTP error
869+ assert response .status_code == 422 # Returns error response, not HTTP error
870870 body = response .json ()
871- assert "error " in body
871+ assert "Method invalid " in body . get ( "message" )
872872
873873 @patch ("mcpgateway.main.logging_service.set_level" )
874874 def test_set_log_level_endpoint (self , mock_set_level , test_client , auth_headers ):
0 commit comments