|
9 | 9 | pytestmark = pytest.mark.anyio |
10 | 10 |
|
11 | 11 |
|
| 12 | +async def test_list_tools_cursor_parameter(): |
| 13 | + """Test that the cursor parameter is accepted for list_tools. |
| 14 | + |
| 15 | + Note: FastMCP doesn't currently implement pagination, so this test |
| 16 | + only verifies that the cursor parameter is accepted by the client. |
| 17 | + """ |
| 18 | + server = FastMCP("test") |
| 19 | + |
| 20 | + # Create a couple of test tools |
| 21 | + @server.tool(name="test_tool_1") |
| 22 | + async def test_tool_1() -> str: |
| 23 | + """First test tool""" |
| 24 | + return "Result 1" |
| 25 | + |
| 26 | + @server.tool(name="test_tool_2") |
| 27 | + async def test_tool_2() -> str: |
| 28 | + """Second test tool""" |
| 29 | + return "Result 2" |
| 30 | + |
| 31 | + async with create_session(server._mcp_server) as client_session: |
| 32 | + # Test without cursor parameter (omitted) |
| 33 | + result1 = await client_session.list_tools() |
| 34 | + assert len(result1.tools) == 2 |
| 35 | + |
| 36 | + # Test with cursor=None |
| 37 | + result2 = await client_session.list_tools(cursor=None) |
| 38 | + assert len(result2.tools) == 2 |
| 39 | + |
| 40 | + # Test with cursor as string |
| 41 | + result3 = await client_session.list_tools(cursor="some_cursor_value") |
| 42 | + assert len(result3.tools) == 2 |
| 43 | + |
| 44 | + # Test with empty string cursor |
| 45 | + result4 = await client_session.list_tools(cursor="") |
| 46 | + assert len(result4.tools) == 2 |
| 47 | + |
| 48 | + |
12 | 49 | async def test_list_resources_cursor_parameter(): |
13 | 50 | """Test that the cursor parameter is accepted for list_resources. |
14 | 51 |
|
|
0 commit comments