diff --git a/docs/clients/client.mdx b/docs/clients/client.mdx index f9ed5ca1b..0f5dc0f1e 100644 --- a/docs/clients/client.mdx +++ b/docs/clients/client.mdx @@ -176,7 +176,7 @@ async with client: # Execute a tool result = await client.call_tool("multiply", {"a": 5, "b": 3}) - print(result[0].text) # "15" + print(result.data) # 15 ``` See [Tools](/clients/tools) for detailed documentation. diff --git a/docs/patterns/testing.mdx b/docs/patterns/testing.mdx index 910ac6686..82e4ee1c2 100644 --- a/docs/patterns/testing.mdx +++ b/docs/patterns/testing.mdx @@ -22,7 +22,7 @@ from fastmcp import FastMCP, Client def mcp_server(): server = FastMCP("TestServer") -@server.tool + @server.tool def greet(name: str) -> str: return f"Hello, {name}!" @@ -32,7 +32,7 @@ async def test_tool_functionality(mcp_server): # Pass the server directly to the Client constructor async with Client(mcp_server) as client: result = await client.call_tool("greet", {"name": "World"}) - assert result[0].text == "Hello, World!" + assert result.data == "Hello, World!" ``` This pattern creates a direct connection between the client and server, allowing you to test your server's functionality efficiently. diff --git a/docs/servers/composition.mdx b/docs/servers/composition.mdx index cdbe23186..3d45da37c 100644 --- a/docs/servers/composition.mdx +++ b/docs/servers/composition.mdx @@ -180,7 +180,7 @@ async def test_dynamic_mount(): async with Client(main_mcp) as client: result = await client.call_tool("dynamic_added_later") - print("Result:", result[0].text) + print("Result:", result.data) # Shows: "Tool Added Dynamically!" if __name__ == "__main__": diff --git a/docs/tutorials/rest-api.mdx b/docs/tutorials/rest-api.mdx index cb1453644..a0efeae62 100644 --- a/docs/tutorials/rest-api.mdx +++ b/docs/tutorials/rest-api.mdx @@ -114,7 +114,7 @@ async def main(): # Call one of the generated tools print("\n\nCalling tool 'get_user_by_id'...") user = await client.call_tool("get_user_by_id", {"id": 1}) - print(f"Result:\n{user[0].text}") + print(f"Result:\n{user.data}") if __name__ == "__main__": asyncio.run(main())