Skip to Content
How-To GuidesTypeScriptDefine a Golem tool in TypeScript

Define a Golem tool in TypeScript

Build a definition with toolDefinition(...).body(...), then register one implementation object:

import { ok, toolDefinition } from '@golemcloud/golem-ts-sdk'; import { z } from 'zod/v4'; export const echo = toolDefinition('echo') .version('1.0.0') .body((body) => body.positional('value', z.string()).returns(z.string()), ); echo.implement({ echo: async ({ value }) => ok(value), });

The implementation key is the generated command name. Use the body builder for positional, option, flag, tail, stdin/stdout/stderr, result, and declared-error metadata; use Standard Schema values such as Zod schemas for typed data. Provider handlers return ok(result) or a declared err(...). Call .implement(...) only once per definition.