@@ -1069,7 +1069,6 @@ async def logging_tool(msg: str, ctx: Context) -> str:
10691069 mock_log .assert_any_call (level = "warning" , data = "Warning message" , logger = None , related_request_id = "1" )
10701070 mock_log .assert_any_call (level = "error" , data = "Error message" , logger = None , related_request_id = "1" )
10711071
1072- @pytest .mark .anyio
10731072 async def test_context_logging_with_structured_data (self ):
10741073 """Test that context logging accepts structured data per MCP spec (issue #397)."""
10751074 mcp = MCPServer ()
@@ -1083,6 +1082,8 @@ async def structured_logging_tool(msg: str, ctx: Context) -> str:
10831082 await ctx .warning (404 )
10841083 # Test with boolean
10851084 await ctx .error (True )
1085+ # Test with null
1086+ await ctx .info (None )
10861087 # Test string still works (backward compatibility)
10871088 await ctx .info ("Plain string message" )
10881089 return f"Logged structured data for { msg } "
@@ -1098,7 +1099,7 @@ async def structured_logging_tool(msg: str, ctx: Context) -> str:
10981099 assert "Logged structured data for test" in content .text
10991100
11001101 # Verify all log calls were made with correct data types
1101- assert mock_log .call_count == 5
1102+ assert mock_log .call_count == 6
11021103
11031104 # Check dictionary logging
11041105 mock_log .assert_any_call (
@@ -1132,6 +1133,14 @@ async def structured_logging_tool(msg: str, ctx: Context) -> str:
11321133 related_request_id = "1" ,
11331134 )
11341135
1136+ # Check null logging
1137+ mock_log .assert_any_call (
1138+ level = "info" ,
1139+ data = None ,
1140+ logger = None ,
1141+ related_request_id = "1" ,
1142+ )
1143+
11351144 # Check string still works
11361145 mock_log .assert_any_call (
11371146 level = "info" ,
0 commit comments