Back to Mastra

Reference: Agent.getTools() | Agents

docs/src/content/en/reference/agents/getTools.mdx

2025-12-181.3 KB
Original Source

Agent.getTools()

The .getTools() method retrieves the tools configured for an agent, resolving them if they're a function. These tools extend the agent's capabilities, allowing it to perform specific actions or access external systems.

Usage example

typescript
await agent.getTools()

Parameters

<PropertiesTable content={[ { name: 'options', type: '{ requestContext?: RequestContext }', isOptional: true, defaultValue: '{}', description: 'Optional configuration object containing runtime context.', properties: [ { type: '{ requestContext?: RequestContext }', parameters: [ { name: 'requestContext', type: 'RequestContext', isOptional: true, defaultValue: 'new RequestContext()', description: 'Runtime context for dependency injection and contextual information.', }, ], }, ], }, ]} />

Returns

<PropertiesTable content={[ { name: 'tools', type: 'TTools | Promise<TTools>', description: 'The tools configured for the agent, either as a direct object or a promise that resolves to the tools.', }, ]} />

Extended usage example

typescript
await agent.getTools({
  requestContext: new RequestContext(),
})