Invoke Tools from Code
Call a server tool and read its result.
From Listing to Doing
Discovery told you what exists. Now you actually invoke a tool, sending arguments and reading back the result from your own code.
Call by Name
Use session.call_tool() with the tool name and a dictionary of arguments. The names must match the inputSchema you discovered.
result = await session.call_tool(
"add",
{"a": 2, "b": 3},
)All lessons in this course
- Open a Client Session
- Discover Tools & Resources
- Invoke Tools from Code
- Route Tool Calls Through an LLM