Skip to content

Commit 137126a

Browse files
committed
fix: Corrected tests for MCP metadata.
1 parent 4a58898 commit 137126a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/test_mcp.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ async def test_tool_response_metadata(run_context: RunContext[int]):
9999

100100
result = await server.direct_call_tool('get_collatz_conjecture', {'n': 7})
101101
assert isinstance(result, ToolReturn)
102-
assert result.return_value == snapshot([7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1])
102+
assert isinstance(result.content, list)
103+
assert result.content[0] == snapshot([7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1])
103104
assert result.metadata == snapshot({'pydantic_ai': {'tool': 'collatz_conjecture', 'n': 7, 'length': 17}})
104105

105106

@@ -113,9 +114,11 @@ async def test_tool_structured_response_metadata(run_context: RunContext[int]):
113114
assert tools[5].description.startswith('Return structured dict with metadata.')
114115

115116
result = await server.direct_call_tool('get_structured_text_content_with_metadata', {})
116-
assert isinstance(result, ToolReturn)
117-
assert result.return_value == 'This is some text content.'
118-
assert result.metadata == snapshot({'pydantic_ai': {'source': 'get_structured_text_content_with_metadata'}})
117+
assert isinstance(result, dict)
118+
assert 'result' in result
119+
assert result['result'] == 'This is some text content.'
120+
assert '_meta' in result
121+
assert result['_meta'] == snapshot({'pydantic_ai': {'source': 'get_structured_text_content_with_metadata'}})
119122

120123

121124
async def test_reentrant_context_manager():

0 commit comments

Comments
 (0)