@@ -187,6 +187,42 @@ async def query_client_result(name: str, arguments: dict[str, Any]) -> list[type
187187 assert "EmptyResult" in result .content [0 ].text
188188
189189
190+ @pytest .mark .anyio
191+ async def test_server_queries_client_get_task_payload_without_task_store ():
192+ """Test server querying client for task payload without task store configured."""
193+ server = Server ("test" , task_store = InMemoryTaskStore ())
194+
195+ @server .list_tools ()
196+ async def list_tools () -> list [types .Tool ]:
197+ return [
198+ types .Tool (
199+ name = "query_payload_no_store" ,
200+ description = "Query payload without store" ,
201+ inputSchema = {"type" : "object" , "properties" : {}, "required" : []},
202+ )
203+ ]
204+
205+ @server .call_tool ()
206+ async def query_payload_no_store (name : str , arguments : dict [str , Any ]) -> list [types .TextContent ]:
207+ try :
208+ session = server .request_context .session
209+ await session .get_task_result ("some-task" , types .ClientResult )
210+ return [types .TextContent (type = "text" , text = "Should have failed" )]
211+ except Exception as e :
212+ return [types .TextContent (type = "text" , text = f"Error: { str (e )} " )]
213+
214+ async with create_connected_server_and_client_session (server ) as client_session :
215+ # No task store on client
216+ await client_session .initialize ()
217+
218+ result = await client_session .call_tool ("query_payload_no_store" , {})
219+
220+ assert len (result .content ) == 1
221+ assert isinstance (result .content [0 ], types .TextContent )
222+ assert "Error" in result .content [0 ].text
223+ assert "Task store not configured" in result .content [0 ].text or "INVALID_REQUEST" in result .content [0 ].text
224+
225+
190226@pytest .mark .anyio
191227async def test_server_queries_client_list_tasks ():
192228 """Test server querying client's task list."""
0 commit comments