Skip to main content
Community Maintained - This SDK is functional but receives limited maintenance. For production use, we recommend the TypeScript SDK or Python SDK.

Tools

Define custom tools that Claude can use during conversations. Tools can execute locally in your Go application (client-side) or on the server.

Creating Tools

Tool()

Create a tool with a handler for client-side execution.

Example


ServerTool()

Create a tool for server-side execution (no local handler).

BrowserTool()

Create a tool marked for browser/client-side execution.

Schema Builder

Use the fluent schema builder to define tool input schemas.

NewSchema()

Create a new schema builder.

Schema Methods

Tool Results

TextResult()

Create a text result.

ErrorResult()

Create an error result.

ImageResult()

Create an image result.

ResourceResult()

Create a resource result.

MCP Servers

Client-Side MCP Server

Create an MCP server with tools that execute locally.

Stdio MCP Server

Connect to an external MCP server via stdio.

SSE MCP Server

Connect to an MCP server via Server-Sent Events.

HTTP MCP Server

Connect to an MCP server via HTTP.

Complete Example

Tool Handler Signature

The handler receives:
  • ctx: Context for cancellation and deadlines
  • input: Parsed input matching your schema
Return:
  • *ToolResult: The result to send back to Claude
  • error: Any error that occurred (will be sent as error result)

SimpleHandler()

Wrap a simple function as a tool handler.