@@ -537,27 +537,6 @@ def get_user(user_id: int) -> UserOutput:
537537 assert isinstance (result .content [0 ], TextContent )
538538 assert '"name": "John Doe"' in result .content [0 ].text
539539
540- async def test_tool_mirror_structured_content_false_omits_text_block (self ):
541- """mirror_structured_content=False returns structuredContent only, with empty content."""
542-
543- class UserOutput (BaseModel ):
544- name : str
545- age : int
546-
547- mcp = MCPServer ()
548-
549- @mcp .tool (mirror_structured_content = False )
550- def get_user (user_id : int ) -> UserOutput :
551- """Get user by ID"""
552- return UserOutput (name = "John Doe" , age = 30 )
553-
554- async with Client (mcp ) as client :
555- result = await client .call_tool ("get_user" , {"user_id" : 123 })
556- assert result .is_error is False
557- assert result .structured_content == {"name" : "John Doe" , "age" : 30 }
558- # The serialised text mirror is suppressed; structuredContent is the sole representation.
559- assert result .content == []
560-
561540 async def test_tool_structured_output_primitive (self ):
562541 """Test tool with structured output returning primitive type"""
563542
@@ -2366,3 +2345,25 @@ def greeting() -> str: # pragma: no cover
23662345 assert mcp ._prompt_manager .list_prompts () == []
23672346 with pytest .raises (ValueError , match = "Unknown prompt: greeting" ):
23682347 mcp .remove_prompt ("greeting" )
2348+
2349+
2350+ async def test_tool_mirror_structured_content_false_omits_text_block ():
2351+ """mirror_structured_content=False returns structuredContent only, with empty content."""
2352+
2353+ class UserOutput (BaseModel ):
2354+ name : str
2355+ age : int
2356+
2357+ mcp = MCPServer ()
2358+
2359+ @mcp .tool (mirror_structured_content = False )
2360+ def get_user (user_id : int ) -> UserOutput :
2361+ """Get user by ID"""
2362+ return UserOutput (name = "John Doe" , age = 30 )
2363+
2364+ async with Client (mcp ) as client :
2365+ result = await client .call_tool ("get_user" , {"user_id" : 123 })
2366+ assert result .is_error is False
2367+ assert result .structured_content == {"name" : "John Doe" , "age" : 30 }
2368+ # The serialized text mirror is suppressed; structuredContent is the sole representation.
2369+ assert result .content == []
0 commit comments