createTool()
This method manages AI tool definitions or agent-to-tool bindings.
Usage
The following example shows a basic usage of the backend client from @wacht/nextjs/server.
import { wachtClient } from '@wacht/nextjs/server';export async function example() { const client = await wachtClient(); const request: CreateAiToolRequest = { name: 'fetch-user-profile', kind: 'api', configuration: {}, }; return client.ai.createTool(request);}Signature
function createTool( request: CreateAiToolRequest, client?: WachtClient,): Promise<AiTool>Parameters
›request: CreateAiToolRequest;
request: CreateAiToolRequest;Request payload object sent to the backend API.
›name?: string | undefined;
name?: string | undefined;Display name for the target resource.
›kind?: string | undefined;
kind?: string | undefined;kind value used by this request.
›configuration?: object | undefined;
configuration?: object | undefined;Nested object field used by this request.
Return value
›id?: string | undefined;
id?: string | undefined;Tool id.
›name?: string | undefined;
name?: string | undefined;Tool display name.
›kind?: string | undefined;
kind?: string | undefined;Tool kind/type.
Examples
AI usage pattern
import { wachtClient } from '@wacht/nextjs/server';export async function attachTool(agentId: string) { const client = await wachtClient(); const tool = await client.ai.createTool({ name: 'fetch-user-profile', kind: 'api', configuration: {}, }); await client.ai.attachAgentTool(agentId, tool.id); return tool;}