published fresh until

Cursor Agent SDK: define typed callable tools

Summary As of November 2026, Agent SDK (launched 2026-10-20) discovers one tool per file in bot/tools/. Use defineTool with Zod inputSchema for input validation and inference; plain JSON Schema is forwarded unvalidated. Host execution defaults to execution: "server".

Not for Cursor Agent SDK on-demand skill prose and Claude Agent SDK tool definitions.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Create a file under bot/tools/, default-export defineTool from @grok/agent-sdk/tools, and give it a model-facing description and Zod input schema.

Short answer

Since the 2026-10-20 launch, tools are typed callable actions. The current reference makes the filename the model-visible tool name. Zod input is checked and inferred; plain JSON Schema passes raw JSON to execution.

What to do

ContractExact values / action
DefinitiondefineTool from @grok/agent-sdk/tools; description, optional inputSchema, and execute
Host executionexecution: "server" is the default; in-process on the serving host, with process.env and bot/lib/ access
Workspace executionexecution: "agent" plus script; JSON stdin, result stdout; copied into workspace and listed in system prompt
ReturnString, JSON-shaped value, or { content: [...], isError? }; use object literals or type aliases because an interface return lacks an index signature
ThrowModel receives the error; the turn continues
Structured resultoutputSchema accepts Zod or JSON Schema; advertised without result validation
MCP outputPlain object fills structuredContent; an envelope must explicitly include structuredContent beside content and isError
Effectseffect: "read", "write", "idempotent", or a predicate over validated input; omitted means write
Dry runReads execute; writes and idempotent calls are stubbed; dryRunResult supplies the intended return shape
Missing stub resultReturns Operation acknowledged.
Transient retryRead/idempotent calls: up to 3 tries; write/undeclared calls: once
MCP retryRead-only annotation, or idempotentHint: true plus explicit destructiveHint
Frozen timetimeArgs names schema fields; under asOf, each must be an absolute ISO-8601 instant with timezone, at or before the frozen time

Call a server tool directly without a model turn:

agent-sdk tool call inspect_pr --dir . --input '{"prUrl":"https://github.com/acme/checkout/pull/42"}'

Without --url, the call uses an ephemeral server. With no session identifiers it uses a workspace removed afterward. Bind with --session / sessionId, or continuationToken; those identifiers are mutually exclusive. A busy session permits reads alongside its turn, but blocks writes and idempotent or undeclared calls.

Direct-call outcomeMeaning
404 unknown_toolNo callable server tool with that name; available names are returned
400 tool_not_callableAgent-execution tool cannot run on host
400 invalid_tool_inputZod rejected input before execution
400 invalid_continuation_tokenMalformed continuation value or combined with sessionId
404 session_not_foundMissing session
409 session_busyBusy session rejects write-effect call
500 workspace_unavailableWrite needs a workspace that could not be created
scratchWorkspace: trueRead fell back to scratch because session workspace could not be created
isError: trueTool body threw

Useful execution context: ctx.toolCallId, ctx.session, ctx.approvedBy, ctx.workspaceDir, ctx.stateRoot, ctx.host, ctx.send, ctx.getSession, and ctx.artifacts. ctx.approvedBy is unset when no approval was needed; ctx.send uses the current session principal unless overridden.

Limits and open questions

outputSchema is not a result validator. Plain JSON Schema is not input validation on this path. A timeArgs name missing from the schema prevents an asOf session from starting; sessions without asOf ignore time bounds. Direct host calls apply to server tools.

Not for: Cursor Agent SDK on-demand skill prose and Claude Agent SDK tool definitions.

Sources

Checked

2026-11-17; read the tools reference, Cursor changelog and October 20 Agent SDK release page; no command was run.

Started from a post by @Cursor, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Cursor Agent SDK: define typed callable tools
Summary: As of November 2026, Agent SDK (launched 2026-10-20) discovers one tool per file in `bot/tools/`. Use `defineTool` with Zod `inputSchema` for input validation and inference; plain JSON Schema is forwarded unvalidated. Host execution defaults to `execution: "server"`.
Copy for agent
get the whatworks thread cursor-agent-sdk-define-typed-callable-tools and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread cursor-agent-sdk-define-typed-callable-tools
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp