Skip to content
Docs menu

Describe and register tools

Write a tool with Tool and Param, register it for a session, and handle tools the API refuses.

Describe a tool

A tool has a name (what the agent calls it), a description (when to use it: write it for the agent, not for a person) and its arguments. The SDK turns that into the JSON the API takes, {name, description, input_schema}, when it sends it. You never have to write JSON Schema yourself, but you can.

from falcore import Param, Tool

place_clip = Tool(
    name="place_clip",
    description="Place an audio file on the timeline",
    params=[
        Param("file_id", "string", "The file to place", required=True),
        Param("start", "number", "Start time in seconds", required=True),
        Param("track", "integer", "Track number (default 1)"),
    ],
)
print(place_clip.to_definition())          # exactly what will be sent
Output
{'name': 'place_clip', 'description': 'Place an audio file on the timeline', 'input_schema': {'type': 'object', 'properties': {'file_id': {'type': 'string', 'description': 'The file to place'}, 'start': {'type': 'number', 'description': 'Start time in seconds'}, 'track': {'type': 'integer', 'description': 'Track number (default 1)'}}, 'required': ['file_id', 'start']}}

Python's output is shown. The content is the same in every language, but each prints it its own way: TypeScript prints a JavaScript object (wrap it in JSON.stringify(..) to see it all on one line), and Rust prints compact JSON with the keys in alphabetical order.

Why a tool is built this way

  • **name** must be unique inside one registration. The API refuses a tool that would shadow one of the server's own tools (see refused tools below).
  • **description** is the only thing the agent knows about your tool. "Place an audio file on the timeline" lets it decide; "place_clip" does not.
  • Arguments are typed (string, number, integer, boolean, array, object) so the agent fills them in correctly. Mark an argument required only when the tool cannot work without it. The agent supplies required arguments every time; for optional ones it decides.
  • Other settings on an argument: enum limits a value to a list, items is the element type of an array, default documents the default for the agent (the API does not fill it in).

A tool with no arguments is fine: Tool("ping", "Check the editor is alive") takes none.

Other ways to give arguments

Tool("mark", "Add a marker", params={"at": "number", "label": {"type": "string", "description": "Text", "required": True}})   # a dict
Tool("x", "Ready-made JSON Schema", input_schema={"type": "object", "properties": {"q": {"type": "string"}}})              # your own schema
Tool("y", "Python types work too", params=[Param("count", int), Param("ratio", float), Param("on", bool)])

Plain objects in the API's own shape ({name, description, input_schema}) are accepted everywhere a Tool is.

Register

Registration belongs to your account and a tool set: by default the client's current session. It is safe to repeat; registering the same tool again updates it.

result = catalyst.tools.register([place_clip])                  # for catalyst.session_id
print(result.accepted, result.client_id)
Output
registered: ['place_clip'] as sdk:sdk-4cdc7c245bf54c0ab066

In the cURL form you write the tool set name yourself, client_id, in the shape <client>:<session>. The SDK does that for you; see Sessions and tool scope.

Output of the cURL call above against the local mock server (the real API's wording for a refusal may differ; see the note below):

Output
{"success": true, "accepted": ["place_clip"], "rejected": []}

The three modes

`mode`What happensUse it to
upsert (default)Adds the tools you send, updates ones that exist, leaves the rest alone.Add or change a tool.
replaceThe tools you send become the whole set; anything else is removed.Start a session with exactly your current tools.
deleteRemoves the tools named (only name is needed).Remove tools.
catalyst.tools.register([place_clip], mode="replace")

Tools the API refuses

The API checks every tool when it is registered, and refuses one that would shadow a tool the Falcore server itself offers (so the agent can never confuse your wave with the server's). A refused tool is not stored. The answer lists what was accepted and what was rejected with a reason for each.

By default the SDK raises if any tool is rejected, so a mistake cannot pass silently. Pass strict=False (strict: false in TypeScript, .lenient() in Rust) to get the result instead and decide yourself.

from falcore import InvalidRequestError

try:
    catalyst.tools.register([{"name": "ok", "description": "fine"}, {"name": "wave", "description": "clashes"}])
except InvalidRequestError as err:
    print(err)                                      # names each refused tool and why

result = catalyst.tools.register([{"name": "ok", "description": "fine"}, {"name": "wave", "description": "clashes"}], strict=False)
print(result.accepted, result.rejected, result.ok)
Note

Which names the real server refuses is decided by the server. The wave example above is what the local mock server refuses; on the live API check the rejected list rather than assuming a name is free.

Mistakes caught before anything is sent

The SDK checks a tool locally, so a typo is a clear error instead of a round trip: an empty name, an unknown argument type, a repeated argument name, items on something that is not an array, or both params and input_schema. Duplicate tool names in one call are caught too.

Tool("x", "d", params=[Param("a", "colour")]).to_definition()
Output
falcore._exceptions.InvalidRequestError: 422 INVALID_REQUEST params.a.type: unknown type 'colour'. Use one of: string, number, integer, boolean, array, object, null (or str, int, float, bool, list, dict).