Back to Cline

Tools API

docs/sdk/reference/tools-api.mdx

3.83.01.5 KB
Original Source

createTool(config)

typescript
import { createTool } from "@cline/sdk"

Creates a typed tool. Also re-exported from @cline/agents and @cline/core.

typescript
const tool = createTool({
  name: "get_current_time",
  description: "Return the current time as ISO string.",
  inputSchema: { type: "object", properties: {} },
  execute: async (_input, context) => {
    return { now: new Date().toISOString() }
  },
})

inputSchema can be either JSON Schema or a Zod schema.

AgentTool

typescript
interface AgentTool<TInput = unknown, TOutput = unknown> {
  name: string
  description: string
  inputSchema: Record<string, unknown>
  execute: (input: TInput, context: AgentToolContext, onChange?: (update: unknown) => void) => Promise<TOutput>
  timeoutMs?: number
  retryable?: boolean
  maxRetries?: number
}

Defaults from createTool:

FieldDefault
timeoutMs30000
retryabletrue
maxRetries3

AgentToolContext

typescript
interface AgentToolContext {
  agentId: string
  conversationId: string
  iteration: number
  abortSignal?: AbortSignal
  metadata?: Record<string, unknown>
}

ToolPolicy

typescript
interface ToolPolicy {
  enabled?: boolean
  autoApprove?: boolean
}

Tool names not listed in a policy map default to enabled and auto-approved.

ToolCallRecord

typescript
interface ToolCallRecord {
  id: string
  name: string
  input: unknown
  output: unknown
  error?: string
  durationMs: number
  startedAt: Date
  endedAt: Date
}