MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / call_tool

Function call_tool

tests/interaction/lowlevel/test_roots.py:31–35  ·  view source on GitHub ↗
(ctx: ServerRequestContext, params: types.CallToolRequestParams)

Source from the content-addressed store, hash-verified

29 return types.ListToolsResult(tools=[types.Tool(name="show_roots", input_schema={"type": "object"})])
30
31 async def call_tool(ctx: ServerRequestContext, params: types.CallToolRequestParams) -> CallToolResult:
32 assert params.name == "show_roots"
33 result = await ctx.session.list_roots() # pyright: ignore[reportDeprecated]
34 lines = [f"{root.uri} name={root.name}" for root in result.roots]
35 return CallToolResult(content=[TextContent(text="\n".join(lines))])
36
37 server = Server("rooted", on_list_tools=list_tools, on_call_tool=call_tool)
38

Callers

nothing calls this directly

Calls 3

CallToolResultClass · 0.90
TextContentClass · 0.90
list_rootsMethod · 0.45

Tested by

no test coverage detected