ts-agent-sdk
Install this skill
npx skills add jezweb/claude-skillsWorks across Claude Code, Cursor, Codex, Copilot & Antigravity
The ts-agent-sdk transforms raw MCP server tool definitions into structured, type-safe TypeScript clients. Instead of managing manual JSON-RPC requests via curl or basic network calls, this skill automates the extraction of tool metadata and Zod schemas to generate dedicated SDK modules. By parsing source files following the mcp-server pattern, it creates clean, idiomatic interface classes that provide autocomplete and type checking for your AI agent interactions. This systematic approach ensures that project communication between AI agents and web-based MCP endpoints remains synchronized, reducing boilerplate while enforcing consistent naming conventions for methods, types, and input schemas. It serves as a glue layer between backend tool definitions and front-facing execution scripts, ensuring that every tool invocation within the agent workflow is strictly typed and documented.
When to Use This Skill
- β’Synchronizing backend tool changes with client-side interface types
- β’Building interactive CLI tools for internal development tasks
- β’Creating reliable automation for Claude Code tool invocation
- β’Reducing network-related runtime errors in agentic workflows
How to Invoke This Skill
Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:
- βgenerate a typed SDK for my existing MCP servers
- βcreate typescript clients from my mcp server definitions
- βscaffold an sdk directory structure for my agent tools
- βupdate the ts-agent-sdk client with latest tool changes
- βsync my mcp tool definitions with the project sdk
Pro Tips
- π‘Ensure your MCP server definitions use Zod consistently for reliable schema extraction and TypeScript generation.
- π‘Integrate the generated SDK into your agent's tool definitions to provide structured access to backend functions.
- π‘Utilize the skill to re-generate SDKs regularly as your MCP server's API evolves, keeping your agent's interactions up-to-date.
What this skill does
- β’Parses Zod schemas to auto-generate TypeScript interfaces
- β’Creates object-oriented client classes for specific MCP modules
- β’Standardizes naming conventions from MCP snake_case to camelCase
- β’Bundles pre-configured error handling classes for API integration
- β’Generates boilerplate execution scripts for rapid prototyping
When not to use it
- βProjects not using Zod for MCP server tool validation
- βSmall projects where overhead of a full SDK outweighs manual fetch calls
Example workflow
- Verify the project contains MCP server modules in src/server/modules/
- Execute the SDK generation routine to scan tool definitions
- Review generated types and client methods in scripts/sdk/
- Create or update custom scripts in the examples folder
- Run final integration tests using the generated client and environment variables
Prerequisites
- βTypeScript project
- βExisting MCP server implementation using Zod
- βtsx installed for executing generated scripts
Pitfalls & limitations
- !Custom logic inside generated client files may be overwritten during regeneration
- !Strict dependency on specific project file paths for source scanning
- !Requires manual maintenance of environment variables for different target environments
FAQ
How it compares
This tool replaces error-prone, manual JSON-RPC payload crafting with a predictable, type-safe library that acts as a formal interface to your MCP services.
π Full skill instructions β original source: jezweb/claude-skills
## 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.tsEach 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.ts2. Update types.ts with new/changed schemas
3. Update client.ts with new/changed methods
4. Preserve any custom code in examples/
How to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/ts-agent-sdk/ - Save the file as
SKILL.md - The agent will automatically discover the skill based on its description.
Option B: Global Installation (All Agents)
Save the file to these locations to make it available across all projects:
- Claude Code:
~/.claude/skills/jezweb/claude-skills/ts-agent-sdk/SKILL.md - Cursor:
~/.cursor/skills/jezweb/claude-skills/ts-agent-sdk/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/jezweb/claude-skills/ts-agent-sdk/SKILL.md
π Install with CLI:npx skills add jezweb/claude-skills