Mental model
Tool= one discrete action an agent or human participant can take.ToolContext= the execution context available when a tool runs.LocalRoomTool= a mixin for tools that need a boundRoomClient; room-aware tools useself.room.Toolkit= a named bundle of related tools plus optional rules and descriptions.- Hosted toolkit = a
Toolkitthat a service or room participant registers with a room so other participants can discover and call it.
Tools
Tool
A Tool defines one action that an agent or person can perform. The tool declares what it expects in input_schema and what work to perform in execute().
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | — | Unique tool name within a toolkit. |
input_schema | dict | — | JSON Schema for the tool arguments. Enforced at call time. |
title | Optional[str] | name | Human-readable display name. |
description | Optional[str] | "" | Short description of the tool. |
rules | Optional[list[str]] | None | Behavioral guidance for LLMs. |
thumbnail_url | Optional[str] | None | Icon or thumbnail shown in UIs. |
defs | Optional[dict[str, dict]] | None | Reusable JSON Schema definitions merged into the schema via $defs. |
Python
Tool return types
Tools commonly return subclasses ofContent declared in meshagent.api.messaging.
| Content type | When to use it |
|---|---|
JsonContent | Structured JSON output, such as API payloads or summarized data. |
TextContent | Plain-text answers or status messages. |
FileContent | Binary content such as generated documents, images, or archives. |
LinkContent | A URL pointing to an external resource. |
EmptyContent | No payload, usually for successful operations that do not need a response body. |
ToolContext
ToolContext carries the runtime information a tool needs.
| Property | Description |
|---|---|
caller | The participant who called the tool. |
on_behalf_of | The participant a calling agent is acting for, if any. |
caller_context | Optional caller-specific context data. Useful for chat context, handoffs, or custom workflow state. |
LocalRoomTool and use self.room inside execute(...). Toolkits and hosting helpers bind the active RoomClient before the tool runs.
Toolkits
Toolkit vs hosted toolkit
AToolkit is the definition of a group of tools plus the metadata and validation rules that go with them.
Use a plain Toolkit when the tools only need to exist inside one process, such as a single agent runtime.
Use a hosted toolkit when the tools should be registered in a room so other participants can discover and call them.
Toolkit
A Toolkit bundles related tools under a single name so callers can discover, invoke, and permission them together.
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | — | Toolkit identifier used for discovery and invocation. |
tools | list[BaseTool] | — | The tools this toolkit exposes. |
rules | list[str] | list[str] | Optional global guidance that applies to the toolkit. |
title | Optional[str] | name | Human-readable toolkit name. |
description | Optional[str] | "" | Description used for discovery and display in MeshAgent Studio. |
thumbnail_url | Optional[str] | None | Icon or thumbnail for the toolkit. |
validation_mode | ValidationMode | "full" | Validation policy used when the toolkit is invoked. |
public | bool | True | Whether the toolkit should be publicly discoverable when it is hosted in a room. |
get_tool(name): returns the named tool or raises aRoomExceptionif it is not present.execute(context, name, input): validates the input content, invokes the tool, and returns a response.
Toolkits emit OpenTelemetry spans out of the box, so MeshAgent can track who called a tool, how long it took, and what room it ran in.
Hosted toolkit lifecycle
Hosted toolkits are plainToolkit instances across the SDKs.
- In Python,
ServiceHost,connect_remote_toolkit(...), and MeshAgent’s room-hosting helpers register the toolkit and keep it available for room calls. - In TypeScript and Dart,
startHostedToolkit(...)registers the toolkit and returns aHostedToolkithandle. Higher-level helpers like React’suseClientToolkits(...)and Flutter’sClientToolkitswidget use that same hosting API internally.
Toolkit itself does not expose start() / stop(). Those lifecycle operations live on the room-hosting helper or the returned hosted-toolkit handle.
Hosted handle methods
stop():- stops listening for room tool calls,
- unregisters the toolkit from the room.
Toolkit patterns
MeshAgent supports two complementary ways to make tools available during an agent turn.Static toolkits
Static toolkits stay attached to the agent for its full lifetime.- Construct the toolkit up front and pass it in the agent’s
toolkitslist. - The toolkit is instantiated once and participates in every LLM turn.
- Use this when the agent should always have a capability available.
--web-search, --web-fetch, --storage, --shell, --advanced-shell, --document-authoring, and --discovery. --require-toolkit remains the flag for attaching an external toolkit by name.
If you need a capability available for every turn, add the corresponding toolkit directly in code or start the agent with the relevant CLI flag. If the capability should be discoverable by other participants, host the toolkit in a room and let callers invoke it over MeshAgent’s room-tool protocol.
Tool access and availability
RequiredToolkit
Agents can declare toolkit dependencies explicitly:
Python
Tool access and permissions
Tool access is controlled by the participant token’sApiScope.agents grant:
register_public_toolkit/register_private_toolkit: allow registering public or private toolkits.use_tools: required to list or inspect toolkits.call: required to invoke tools.
use_tools. Private toolkits are only listed for the participant that registered them. Use API scope grants to decide which services or users can register, inspect, and call tools.