Add powerful capabilities to your Magma agents
Tools are the primary way to extend your Magma agent’s capabilities. They allow your agent to interact with external systems, process data, and perform specific tasks.
Tools are asynchronous methods that return a string or object response.
Here’s a simple example of implementing a tool:
The @tool
decorator defines the tool itself and accepts the following options:
name
: The name of the tool.description
: A description of the tool.cache
: Try to cache the tool if supported by the provider.enabled
: Dynamically enable or disable the tool based on agent state. Disabled tools are not supplied to the provider. If omitted, the tool will always be enabled.The @toolparam
decorator defines parameters for your tool:
key
: The name of the parameter.type
: The type of the parameter.description
: A description of the parameter.required
: Whether the parameter is required to run the tool. Defaults to false.Primitive-specific options:
enum
: Possible values for the parameter.Object-specific options:
properties
: An array of MagmaToolParam
objects which define the properties of the object.Array-specific options:
items
: A MagmaToolParam
object which defines the type of the items in the array.You should get intellisense for what properties are available for a given parameter type.
Tools can accept complex parameter types:
Return Values
Error Handling
Type Safety
any
typeRemember that tool responses are used as context for the agent’s next action. Keep responses clear and structured to help the agent make better decisions.
For more examples and advanced usage, check out some of our Templates
A simple template for a Slack DM agent
A simple template for a Supabase DB agent
Add powerful capabilities to your Magma agents
Tools are the primary way to extend your Magma agent’s capabilities. They allow your agent to interact with external systems, process data, and perform specific tasks.
Tools are asynchronous methods that return a string or object response.
Here’s a simple example of implementing a tool:
The @tool
decorator defines the tool itself and accepts the following options:
name
: The name of the tool.description
: A description of the tool.cache
: Try to cache the tool if supported by the provider.enabled
: Dynamically enable or disable the tool based on agent state. Disabled tools are not supplied to the provider. If omitted, the tool will always be enabled.The @toolparam
decorator defines parameters for your tool:
key
: The name of the parameter.type
: The type of the parameter.description
: A description of the parameter.required
: Whether the parameter is required to run the tool. Defaults to false.Primitive-specific options:
enum
: Possible values for the parameter.Object-specific options:
properties
: An array of MagmaToolParam
objects which define the properties of the object.Array-specific options:
items
: A MagmaToolParam
object which defines the type of the items in the array.You should get intellisense for what properties are available for a given parameter type.
Tools can accept complex parameter types:
Return Values
Error Handling
Type Safety
any
typeRemember that tool responses are used as context for the agent’s next action. Keep responses clear and structured to help the agent make better decisions.
For more examples and advanced usage, check out some of our Templates
A simple template for a Slack DM agent
A simple template for a Supabase DB agent