getTool

View as MarkdownOpen in Claude

Look up a registered SwaigFunction on this service by name.

Parameters

name
stringRequired

The tool name to search for.

Returns

SwaigFunction | undefined — The SwaigFunction instance, or undefined if not found or not a SwaigFunction (e.g., a raw DataMap descriptor).

Example

import { SWMLService } from '@signalwire/sdk';
const service = new SWMLService({ name: 'swaig-host', route: '/' });
service.defineTool({
name: 'get_weather',
description: 'Get the current weather',
parameters: { type: 'object', properties: { city: { type: 'string' } } },
handler: async (args) => ({ response: `Weather in ${args.city}: sunny` }),
});
const tool = service.getTool('get_weather');
if (tool) {
console.log(tool.description); // "Get the current weather"
}