ts-agent-sdk

jezweb/claude-skills · updated Apr 8, 2026

$npx skills add https://github.com/jezweb/claude-skills --skill ts-agent-sdk
0 commentsdiscussion
summary

Generate typed TypeScript SDKs for AI agents to call MCP server tools with clean function signatures.

  • Converts MCP tool definitions (Zod schemas, descriptions, endpoints) into typed TypeScript interfaces, client methods, and example scripts
  • Scans project for MCP servers in src/server/modules/mcp*/server.ts , extracts tool metadata, and generates module-based client classes with one async method per tool
  • Includes built-in error handling (AuthError, ValidationError, RateLimitError, MCP
skill.md

ts-agent-sdk

Overview

This skill generates typed TypeScript SDKs that allow AI agents (primarily Claude Code) to interact with web applications via MCP servers. It replaces verbose JSON-RPC curl commands with clean function calls.

Template Location

The core SDK template files are bundled with this skill at: templates/

Copy these files to the target project's scripts/sdk/ directory as a starting point:

cp -r ~/.claude/skills/ts-agent-sdk/templates/* ./scripts/sdk/

SDK Generation Workflow

Step 1: Detect MCP Servers

Scan the project for MCP server modules:

src/server/modules/mcp*/server.ts

Each server.ts file contains tool definitions using the pattern:

server.tool(
  'tool_name',
  'Tool description',
  zodInputSchema,
  async (params) => { ... }
)

Step 2: Extract Tool Definitions

For each tool, extract:

  1. name: The tool identifier (e.g., 'create_document')
  2. description: Tool description for JSDoc
  3. inputSchema: Zod schema defining input parameters
  4. endpoint: The MCP endpoint path (e.g., '/api/mcp-docs/message')

Step 3: Generate TypeScript Interfaces

Convert Zod schemas to TypeScript interfaces:

// From: z.object({ name: z.string(), email: z.string().email() })
// To:
export interface CreateEnquiryInput {
  name: string;
  email: string;
}

Step 4: Generate Module Client

Create a client class with methods for each tool:

// scripts/sdk/docs/client.ts
import { MCPClient, defaultClient } from '../client';
import type { CreateDocumentInput, CreateDocumentOutput } from './types';

const ENDPOINT = '/api/mcp-docs/message';

export class DocsClient {
  private mcp: MCPClient;

  constructor(client?: MCPClient) {
    this.mcp = client || defaultClient;
  }

  async createDocument(input: CreateDocumentInput): Promise<CreateDocumentOutput> {
    return this.mcp.callTool(ENDPOINT, 'create_document', input);
  }

  async listDocuments(input: ListDocumentsInput): Promise<ListDocumentsOutput> {
    return this.mcp.callTool(ENDPOINT, 'list_documents', input);
  }

  // ... one method per tool
}

export const docs = new DocsClient();

Step 5: Generate Example Scripts

Create runnable examples in scripts/sdk/examples/:

#!/usr/bin/env npx tsx
// scripts/sdk/examples/create-doc.ts
import { docs } from '../';

async function main() {
  const result = await docs.createDocument({
    spaceId: 'wiki',
    title: 'Getting Started',
    content: '# Welcome\n\nThis is the intro.',
  });

  console.log(`Created document: ${result.document.id}`);
}

main().catch(console.error);

Step 6: Update Index Exports

Add module exports to scripts/sdk/index.ts:

export { docs } from './docs';
export { enquiries } from './enquiries';

Output Structure

project/
└── scripts/sdk/
    ├── index.ts           # Main exports
    ├── config.ts          # Environment config
    ├── errors.ts          # Error classes
    ├── client.ts          # MCP client
    ├── docs/              # Generated module
    │   ├── types.ts       # TypeScript interfaces
    │   ├── client.ts      # Typed methods
    │   └── index.ts       # Module exports
    ├── enquiries/         # Another module
    │   ├── types.ts
    │   ├── client.ts
    │   └── index.ts
    └── examples/          # Runnable scripts
        ├── create-doc.ts
        ├── list-spaces.ts
        └── create-enquiry.ts

Environment Variables

The SDK uses these environment variables:

Variable Description Default
SDK_MODE Execution mode: 'local', 'remote', 'auto' 'auto'
SDK_BASE_URL Target Worker URL http://localhost:8787
SDK_API_TOKEN Bearer token for auth (none)

Execution

Run generated scripts with:

SDK_API_TOKEN="your-token" SDK_BASE_URL="https://app.workers.dev" npx tsx scripts/sdk/examples/create-doc.ts

Naming Conventions

  • Module names: Lowercase, from MCP server name (e.g., 'mcp-docs' → 'docs')
  • Method names: camelCase from tool name (e.g., 'create_document' → 'createDocument')
  • Type names: PascalCase (e.g., 'CreateDocumentInput', 'CreateDocumentOutput')

Error Handling

The SDK provides typed errors:

  • AuthError - 401, invalid token
  • ValidationError - Invalid input
  • NotFoundError - Resource not found
  • RateLimitError - 429, too many requests
  • MCPError - MCP protocol errors
  • NetworkError - Connection failures

Regeneration

When MCP tools change, regenerate the SDK:

  1. Re-scan src/server/modules/mcp*/server.ts
  2. Update types.ts with new/changed schemas
  3. Update client.ts with new/changed methods
  4. Preserve any custom code in examples/

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.745 reviews
  • Mateo Menon· Dec 28, 2024

    ts-agent-sdk reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Pratham Ware· Dec 24, 2024

    ts-agent-sdk is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Amina Smith· Dec 16, 2024

    Registry listing for ts-agent-sdk matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Amina Tandon· Dec 8, 2024

    Solid pick for teams standardizing on skills: ts-agent-sdk is focused, and the summary matches what you get after install.

  • Xiao Zhang· Nov 19, 2024

    ts-agent-sdk has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Sakshi Patil· Nov 15, 2024

    Keeps context tight: ts-agent-sdk is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Xiao Tandon· Nov 15, 2024

    We added ts-agent-sdk from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • James Sharma· Nov 7, 2024

    ts-agent-sdk fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Nikhil Kim· Oct 26, 2024

    ts-agent-sdk is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Daniel Perez· Oct 10, 2024

    Useful defaults in ts-agent-sdk — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

showing 1-10 of 45

1 / 5