Route a tools/call request by tool name. The optional ``task`` parameter (per MCP Tasks protocol) is passed through to providers that support background callbacks.
(
tool_name: str, arguments: dict[str, Any], task: dict | None = None
)
| 31 | |
| 32 | |
| 33 | def call_tool( |
| 34 | tool_name: str, arguments: dict[str, Any], task: dict | None = None |
| 35 | ) -> CallToolResult | CreateTaskResult: |
| 36 | """Route a tools/call request by tool name. |
| 37 | |
| 38 | The optional ``task`` parameter (per MCP Tasks protocol) is passed |
| 39 | through to providers that support background callbacks. |
| 40 | """ |
| 41 | for provider in _TOOL_PROVIDERS: |
| 42 | if tool_name in provider.get_tool_names(): |
| 43 | return provider.call_tool(tool_name, arguments, task=task) |
| 44 | raise ToolNotFoundError( |
| 45 | f"Tool not found: {tool_name}." |
| 46 | " The app's callbacks may have changed." |
| 47 | " Please call tools/list to refresh your tool list." |
| 48 | ) |
searching dependent graphs…