@@ -76,7 +76,7 @@ def test_mcp_client():
76
76
77
77
sse_mcp_client = MCPClient (lambda : sse_client ("http://127.0.0.1:8000/sse" ))
78
78
stdio_mcp_client = MCPClient (
79
- lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/echo_server.py" ]))
79
+ lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/mcp/ echo_server.py" ]))
80
80
)
81
81
82
82
with sse_mcp_client , stdio_mcp_client :
@@ -150,19 +150,19 @@ def test_mcp_client():
150
150
151
151
# With the new MCPToolResult, structured content is in its own field
152
152
assert "structuredContent" in result
153
- assert result ["structuredContent" ][ "result" ] == {"echoed" : "STRUCTURED_DATA_TEST" }
153
+ assert result ["structuredContent" ] == {"echoed" : "STRUCTURED_DATA_TEST" , "message_length" : 20 }
154
154
155
155
# Verify the result is an MCPToolResult (at runtime it's just a dict, but type-wise it should be MCPToolResult)
156
156
assert result ["status" ] == "success"
157
157
assert result ["toolUseId" ] == tool_use_id
158
158
159
159
assert len (result ["content" ]) == 1
160
- assert json .loads (result ["content" ][0 ]["text" ]) == {"echoed" : "STRUCTURED_DATA_TEST" }
160
+ assert json .loads (result ["content" ][0 ]["text" ]) == {"echoed" : "STRUCTURED_DATA_TEST" , "message_length" : 20 }
161
161
162
162
163
163
def test_can_reuse_mcp_client ():
164
164
stdio_mcp_client = MCPClient (
165
- lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/echo_server.py" ]))
165
+ lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/mcp/ echo_server.py" ]))
166
166
)
167
167
with stdio_mcp_client :
168
168
stdio_mcp_client .list_tools_sync ()
@@ -185,7 +185,7 @@ async def test_mcp_client_async_structured_content():
185
185
that appears in structuredContent field.
186
186
"""
187
187
stdio_mcp_client = MCPClient (
188
- lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/echo_server.py" ]))
188
+ lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/mcp/ echo_server.py" ]))
189
189
)
190
190
191
191
with stdio_mcp_client :
@@ -200,20 +200,20 @@ async def test_mcp_client_async_structured_content():
200
200
assert "structuredContent" in result
201
201
# "result" nesting is not part of the MCP Structured Content specification,
202
202
# but rather a FastMCP implementation detail
203
- assert result ["structuredContent" ][ "result" ] == {"echoed" : "ASYNC_STRUCTURED_TEST" }
203
+ assert result ["structuredContent" ] == {"echoed" : "ASYNC_STRUCTURED_TEST" , "message_length" : 21 }
204
204
205
205
# Verify basic MCPToolResult structure
206
206
assert result ["status" ] in ["success" , "error" ]
207
207
assert result ["toolUseId" ] == tool_use_id
208
208
209
209
assert len (result ["content" ]) == 1
210
- assert json .loads (result ["content" ][0 ]["text" ]) == {"echoed" : "ASYNC_STRUCTURED_TEST" }
210
+ assert json .loads (result ["content" ][0 ]["text" ]) == {"echoed" : "ASYNC_STRUCTURED_TEST" , "message_length" : 21 }
211
211
212
212
213
213
def test_mcp_client_without_structured_content ():
214
214
"""Test that MCP client works correctly when tools don't return structured content."""
215
215
stdio_mcp_client = MCPClient (
216
- lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/echo_server.py" ]))
216
+ lambda : stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/mcp/ echo_server.py" ]))
217
217
)
218
218
219
219
with stdio_mcp_client :
@@ -279,7 +279,7 @@ def test_mcp_client_timeout_integration():
279
279
280
280
def slow_transport ():
281
281
time .sleep (4 ) # Longer than timeout
282
- return stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/echo_server.py" ]))
282
+ return stdio_client (StdioServerParameters (command = "python" , args = ["tests_integ/mcp/ echo_server.py" ]))
283
283
284
284
client = MCPClient (slow_transport , startup_timeout = 2 )
285
285
initial_threads = threading .active_count ()
0 commit comments