@@ -152,54 +152,28 @@ def test_header_rung_rejects_on_disagreement(headers: dict[str, str]) -> None:
152152 assert_rejected (classify_inbound_request (envelope (), headers = headers ), HEADER_MISMATCH )
153153
154154
155- # --- rung 4: method-exists-at-version ------------------------------------------
156-
157-
158- @pytest .mark .parametrize (
159- "method" ,
160- [
161- "initialize" ,
162- "ping" ,
163- "logging/setLevel" ,
164- "resources/subscribe" ,
165- "resources/unsubscribe" ,
166- ],
167- )
168- def test_method_rung_rejects_methods_removed_at_modern_version (method : str ) -> None :
169- """Spec-mandated: absence from ``CLIENT_REQUESTS`` at the modern version *is* the gate — removed methods reject."""
170- rejection = assert_rejected (classify_inbound_request (envelope (method )), METHOD_NOT_FOUND )
171- assert method in rejection .message
172-
173-
174- def test_method_rung_rejects_unknown_method () -> None :
175- """Spec-mandated: a method name not in the version's request table rejects METHOD_NOT_FOUND."""
176- assert_rejected (classify_inbound_request (envelope ("does/not/exist" )), METHOD_NOT_FOUND )
177-
178-
179- def test_method_rung_rejects_absent_method_key () -> None :
180- """Spec-mandated: a body with no ``method`` key cannot route and rejects METHOD_NOT_FOUND."""
181- body = envelope ()
182- del body ["method" ]
183- assert_rejected (classify_inbound_request (body ), METHOD_NOT_FOUND )
184-
185-
186155# --- all rungs pass ------------------------------------------------------------
187156
188157
189- @pytest .mark .parametrize ("method" , ["tools/list" , "tools/call" , "server/discover" ])
190- def test_all_rungs_pass_yields_route (method : str ) -> None :
158+ def test_all_rungs_pass_yields_route () -> None :
191159 """Spec-mandated: a complete envelope at a supported version with agreeing header routes, surfacing the envelope."""
192- result = classify_inbound_request (envelope (method ), headers = {MCP_PROTOCOL_VERSION_HEADER : MODERN })
160+ result = classify_inbound_request (envelope (), headers = {MCP_PROTOCOL_VERSION_HEADER : MODERN })
193161 assert isinstance (result , InboundModernRoute )
194- assert result .method == method
195162 assert result .protocol_version == MODERN
196163 assert result .client_info == CLIENT_INFO
197164 assert result .client_capabilities == CLIENT_CAPS
198165
199166
167+ @pytest .mark .parametrize ("method" , ["initialize" , "myorg/custom" , "does/not/exist" ])
168+ def test_classifier_passes_unknown_method_through_to_route (method : str ) -> None :
169+ """SDK-defined: the classifier does not gate on method — kernel dispatch is the single owner of that decision."""
170+ result = classify_inbound_request (envelope (method ), headers = {MCP_PROTOCOL_VERSION_HEADER : MODERN })
171+ assert isinstance (result , InboundModernRoute )
172+
173+
200174def test_ladder_first_failure_wins () -> None :
201- """Spec-mandated: rungs evaluate in order — version, header and method would all fail; the version rung fires."""
202- body = envelope ("initialize" , version = LATEST_PROTOCOL_VERSION )
175+ """Spec-mandated: rungs evaluate in order — version and header would both fail; the version rung fires."""
176+ body = envelope (version = LATEST_PROTOCOL_VERSION )
203177 result = classify_inbound_request (body , headers = {MCP_PROTOCOL_VERSION_HEADER : MODERN })
204178 assert_rejected (result , UNSUPPORTED_PROTOCOL_VERSION )
205179
@@ -224,7 +198,7 @@ def test_error_code_http_status_table(code: int, status: int) -> None:
224198
225199def test_error_code_http_status_covers_every_ladder_code () -> None :
226200 """SDK-defined: every code the ladder can emit has an HTTP-status entry, so the transport never has to default."""
227- ladder_codes = {INVALID_PARAMS , UNSUPPORTED_PROTOCOL_VERSION , HEADER_MISMATCH , METHOD_NOT_FOUND }
201+ ladder_codes = {INVALID_PARAMS , UNSUPPORTED_PROTOCOL_VERSION , HEADER_MISMATCH }
228202 assert ladder_codes <= ERROR_CODE_HTTP_STATUS .keys ()
229203
230204
0 commit comments