@BindTool
The @BindTool(ToolClass, options?) method decorator ("@agboss/core") binds a method on a workflow provider class to a @Tool or @McpTool (optionally scoped to a specific @Agent via { agent: MyAgent }).
@BindTool example
Section titled “@BindTool example”import { Agent, BindTool, Injectable, Tool, type ToolHandler } from "@agboss/core";import { ListOf, Text } from "@agboss/core/dto";
export class RegionalSearchInputDto { @Text({ prompt: "Role keywords, e.g. Staff TypeScript" }) query!: string;}
export class RegionalSearchOutputDto { @ListOf(Text, { prompt: "Matching role titles" }) openings!: string[];}
@Tool({ name: "search_regional_jobs", description: "Searches openings in a target region", input: RegionalSearchInputDto, output: RegionalSearchOutputDto,})export class SearchRegionalJobsTool implements ToolHandler<RegionalSearchInputDto, RegionalSearchOutputDto>{ run(input: RegionalSearchInputDto): Promise<RegionalSearchOutputDto> { return Promise.resolve({ openings: [`Global: ${input.query}`] }); }}
@Agent({ name: "eu-scout-agent", description: "Finds EU roles using SearchRegionalJobsTool", model: "moonshotai/kimi-k2.6", prompt: "Call search_regional_jobs to find matching roles in Europe.", tools: [SearchRegionalJobsTool],})export class EuScoutAgent {}
@Injectable()export class EuJobSearchBindings { @BindTool(SearchRegionalJobsTool, { agent: EuScoutAgent }) searchForEuAgent(input: RegionalSearchInputDto): Promise<RegionalSearchOutputDto> { return Promise.resolve({ openings: [`EU: ${input.query}`] }); }}import { expect, it } from "vitest";import { testTool } from "@agboss/core/testing";import { EuJobSearchBindings, SearchRegionalJobsTool,} from "../src/tools/bound-search.service.js";
it("executes default tool handler and bound EU override method", async () => { const runTool = testTool(SearchRegionalJobsTool); const { output: globalOut } = await runTool({ query: "Staff TypeScript" }); expect(globalOut.openings).toEqual(["Global: Staff TypeScript"]);
const bindings = new EuJobSearchBindings(); const euOut = await bindings.searchForEuAgent({ query: "Staff TypeScript" }); expect(euOut.openings).toEqual(["EU: Staff TypeScript"]);});How to configure @BindTool options and signatures
Section titled “How to configure @BindTool options and signatures”| Parameter | Type | Required | Description |
|---|---|---|---|
tool |
Class | string |
Yes | The @Tool / @McpTool class (or snake_case tool name string) handled or intercepted by this method. |
options.agent |
Class | string |
No | Optional @Agent class (or kebab-case agent name) restricting the binding to calls made by that specific agent. |