Skip to content

Tools

Tools are typed capabilities exposed to the agent.

ts
import {
  tool,
  type Tool,
} from "duclaw-cli/sdk";

Define a Tool

ts
const lookupAccount = tool({
  name: "lookup_account",
  description: "Look up one account by id.",
  inputSchema: {
    type: "object",
    properties: {
      accountId: {
        type: "string",
        description: "Account id, for example acc_123.",
      },
    },
    required: ["accountId"],
    additionalProperties: false,
  },
  async run({ accountId }) {
    return { id: accountId, plan: "pro" };
  },
});

Schema Compatibility

inputSchema is the TypeScript-friendly field used in SDK examples. input_schema is also accepted when copying an Anthropic tool definition.

ts
const lookupAccount = tool({
  name: "lookup_account",
  description: "Look up one account by id.",
  input_schema: {
    type: "object",
    properties: {
      accountId: { type: "string" },
    },
    required: ["accountId"],
  },
  async run(input) {
    return { id: input.accountId };
  },
});

Do not pass both inputSchema and input_schema unless they reference the same schema object.

Released as part of the duclaw-cli package.