@@ -318,6 +318,40 @@ public async Task PostMalformedJson_Returns400_InvalidRequest_WithNullId()
318318 Assert . Equal ( ( int ) McpErrorCode . InvalidRequest , doc . RootElement . GetProperty ( "error" ) . GetProperty ( "code" ) . GetInt32 ( ) ) ;
319319 }
320320
321+ [ Fact ]
322+ public async Task InitializeWithMissingClientVersion_Returns400_InvalidParams_WithRequestId ( )
323+ {
324+ await StartAsync ( ) ;
325+
326+ const string request = """
327+ {"jsonrpc":"2.0","id":7,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"IntegrationTestClient"}}}
328+ """ ;
329+
330+ using var response = await HttpClient . PostAsync ( "" , JsonContent ( request ) , TestContext . Current . CancellationToken ) ;
331+ Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
332+ Assert . False ( response . Headers . Contains ( "mcp-session-id" ) ) ;
333+
334+ using var doc = JsonDocument . Parse ( await response . Content . ReadAsStringAsync ( TestContext . Current . CancellationToken ) ) ;
335+ Assert . Equal ( 7 , doc . RootElement . GetProperty ( "id" ) . GetInt64 ( ) ) ;
336+ Assert . Equal ( ( int ) McpErrorCode . InvalidParams , doc . RootElement . GetProperty ( "error" ) . GetProperty ( "code" ) . GetInt32 ( ) ) ;
337+ Assert . Contains ( "version" , doc . RootElement . GetProperty ( "error" ) . GetProperty ( "message" ) . GetString ( ) , StringComparison . OrdinalIgnoreCase ) ;
338+ }
339+
340+ [ Theory ]
341+ [ InlineData ( "{\" jsonrpc\" :\" 2.0\" ,\" id\" :8,\" method\" :\" initialize\" }" ) ]
342+ [ InlineData ( "{\" jsonrpc\" :\" 2.0\" ,\" id\" :9,\" method\" :\" initialize\" ,\" params\" :null}" ) ]
343+ public async Task InitializeWithMissingOrNullParams_Returns400_InvalidParams_WithoutCreatingSession ( string request )
344+ {
345+ await StartAsync ( ) ;
346+
347+ using var response = await HttpClient . PostAsync ( "" , JsonContent ( request ) , TestContext . Current . CancellationToken ) ;
348+ Assert . Equal ( HttpStatusCode . BadRequest , response . StatusCode ) ;
349+ Assert . False ( response . Headers . Contains ( "mcp-session-id" ) ) ;
350+
351+ using var doc = JsonDocument . Parse ( await response . Content . ReadAsStringAsync ( TestContext . Current . CancellationToken ) ) ;
352+ Assert . Equal ( ( int ) McpErrorCode . InvalidParams , doc . RootElement . GetProperty ( "error" ) . GetProperty ( "code" ) . GetInt32 ( ) ) ;
353+ }
354+
321355 [ Fact ]
322356 public async Task PostRequestWithExplicitNullId_Returns400_InvalidRequest_WithNullId ( )
323357 {
0 commit comments