Classes
ToolDef
4
▼
A frozen tool definition.
Created during app setup, compiled into the registry at freeze time.
ToolDef
4
▼
A frozen tool definition.
Created during app setup, compiled into the registry at freeze time.
Attributes
| Name | Type | Description |
|---|---|---|
name |
str
|
— |
description |
str
|
— |
handler |
Callable[..., Any]
|
— |
schema |
dict[str, Any]
|
— |
ToolRegistry
6
▼
Compiled tool table. Created at freeze time, immutable at runtime.
Provides ``list_tools()`` for M…
ToolRegistry
6
▼
Compiled tool table. Created at freeze time, immutable at runtime.
Provideslist_tools() for MCP tools/list and call_tool()
for MCPtools/calldispatch.
Methods
list_tools
0
list[dict[str, Any]]
▼
Return MCP-formatted tool list for ``tools/list`` response.
list_tools
0
list[dict[str, Any]]
▼
def list_tools(self) -> list[dict[str, Any]]
Returns
list[dict[str, Any]]
call_tool
2
Any
▼
Dispatch a tool call by name.
Calls the handler with the provided arguments, e…
async
call_tool
2
Any
▼
async def call_tool(self, name: str, arguments: dict[str, Any]) -> Any
Dispatch a tool call by name.
Calls the handler with the provided arguments, emits a
ToolCallEventon success, and returns the result.
RaisesKeyErrorif the tool name is not registered.
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
|
arguments |
— |
Returns
Any
get
1
ToolDef | None
▼
Look up a tool by name. Returns ``None`` if not found.
get
1
ToolDef | None
▼
def get(self, name: str) -> ToolDef | None
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
Returns
ToolDef | None
Internal Methods 3 ▼
__init__
2
▼
__init__
2
▼
def __init__(self, tools: list[ToolDef], event_bus: ToolEventBus) -> None
Parameters
| Name | Type | Description |
|---|---|---|
tools |
— |
|
event_bus |
— |
__len__
0
int
▼
__len__
0
int
▼
def __len__(self) -> int
Returns
int
__contains__
1
bool
▼
__contains__
1
bool
▼
def __contains__(self, name: str) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
Returns
bool
Functions
compile_tools
2
ToolRegistry
▼
Compile pending tool registrations into a frozen ToolRegistry.
Called during `…
compile_tools
2
ToolRegistry
▼
def compile_tools(pending: list[tuple[str, str, Callable[..., Any]]], event_bus: ToolEventBus) -> ToolRegistry
Compile pending tool registrations into a frozen ToolRegistry.
Called duringApp._freeze(). Each tuple is (name, description, handler).
Schema generation happens here so errors surface at startup, not at runtime.
Parameters
| Name | Type | Description |
|---|---|---|
pending |
list[tuple[str, str, Callable[..., Any]]] |
|
event_bus |
ToolEventBus |
Returns
ToolRegistry