claude-agent-ts-sdk

Build TypeScript Claude agents with Zod-validated tools and MCP servers.

2|2|Updated Nov 6, 2025
One-click install
npx skills add https://github.com/szweibel/claude-skills --skill claude-agent-ts-sdk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-agent-ts-sdk
Source: https://github.com/szweibel/claude-skills/tree/main/claude-agent-ts-sdk
Command: npx skills add https://github.com/szweibel/claude-skills --skill claude-agent-ts-sdk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @anthropic-ai/claude-agent-sdk, zod, and includes references (resource) and assets (resource) components.

What problem does it solve?

Provides patterns and scaffolding to build Claude agents using TypeScript with the claude-agent-sdk, including tool wrapping, streaming responses, and modular agent design.

Core Features & Use Cases

  • Tool wrapping patterns: create modular, reusable tools for agents.
  • MCP server integration: wrap tools into MCP servers when needed for queries.
  • Streaming & debugging: handle streaming responses, tool calls, and tool results with telemetry hooks.
  • Use Case: implement a CLI agent that reads a file, processes it with a tool, and streams the result to the terminal.

Quick Start

Initialize a new TypeScript project, install @anthropic-ai/claude-agent-sdk, and build a sample agent that wraps a basic tool.

Frequently Asked Questions about claude-agent-ts-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a Claude agent in TypeScript?

Build Claude agents in TypeScript using the claude-agent-sdk by defining tools with Zod schemas, initializing an agent instance, and processing queries with streaming support. The SDK handles tool invocation, MCP server wrapping, and response streaming across CLI, web, and plugin architectures.

What's the best way to structure tools for Claude agents?

Structure tools as modular, reusable functions with Zod-validated schemas that define input shape and constraints. Each tool follows the tool() schema shape, enabling the agent to invoke them, parse results, and stream responses without manual serialization.

Can I use MCP servers with Claude agents in TypeScript?

Yes. The claude-agent-sdk wraps tools into MCP servers at query time, letting you integrate modular tool servers into your agent without separate infrastructure. This pattern works across CLI, web server, and monorepo setups.

How do I handle streaming responses in a Claude agent?

The claude-agent-sdk processes streaming queries natively, exposing telemetry hooks to track tool calls and results. Handle streaming by consuming events as the agent processes, enabling real-time feedback in terminal, web, or plugin interfaces.

What are the requirements for running a TypeScript Claude agent?

Require Node 18+, TypeScript strict mode, ESModule syntax, @anthropic-ai/claude-agent-sdk, and Zod for schema validation. These enforce type safety and compatibility across project structures from single CLI tools to monorepos.

Do I need to manually wrap tools into MCP servers?

No. The claude-agent-sdk wraps tools into MCP servers automatically at query time based on your tool definitions. You define tools with Zod schemas; the SDK handles server creation and lifecycle management.