***

title: defineTools
slug: /reference/typescript/agents/agent-base/define-tools
description: Protected lifecycle hook for registering SWAIG tools in subclass constructors.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[define-tool]: /docs/server-sdks/reference/typescript/agents/agent-base/define-tool

[register-swaig-function]: /docs/server-sdks/reference/typescript/agents/agent-base/register-swaig-function

Protected lifecycle method for registering tools on the agent. Subclasses
override this method to call
[`defineTool()`][define-tool] or
[`registerSwaigFunction()`][register-swaig-function]
after all instance fields are initialized.

<Note>
  This method is **not** called automatically. Subclasses must invoke
  `this.defineTools()` explicitly at the end of their constructor.
</Note>

## **Parameters**

None.

## **Returns**

`void`

## **Example**

```typescript {7}
import { AgentBase } from '@signalwire/sdk';

class WeatherAgent extends AgentBase {
  constructor() {
    super({ name: 'weather', route: '/weather' });
    this.setPromptText('You are a weather assistant.');
    this.defineTools();
  }

  protected override defineTools(): void {
    this.defineTool({
      name: 'check_weather',
      description: 'Check the current weather',
      parameters: {
        type: 'object',
        properties: {
          city: { type: 'string', description: 'City name' },
        },
        required: ['city'],
      },
      handler: async (args) => {
        return { response: `The weather in ${args.city} is sunny and 72F.` };
      },
    });
  }
}

const agent = new WeatherAgent();
await agent.serve();
```