Loading...
Loading...
Generate typed TypeScript SDKs for AI agents to interact with MCP servers. Converts JSON-RPC curl commands to clean function calls. Auto-generates types, client methods, and example scripts from MCP tool definitions. Use when building MCP-enabled applications, need typed programmatic access to MCP tools, or creating reusable agent automation scripts.
npx skill4agent add jezweb/claude-skills ts-agent-sdktemplates/scripts/sdk/cp -r ~/.claude/skills/ts-agent-sdk/templates/* ./scripts/sdk/src/server/modules/mcp*/server.tsserver.tool(
'tool_name',
'Tool description',
zodInputSchema,
async (params) => { ... }
)// From: z.object({ name: z.string(), email: z.string().email() })
// To:
export interface CreateEnquiryInput {
name: string;
email: string;
}// 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();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);scripts/sdk/index.tsexport { docs } from './docs';
export { enquiries } from './enquiries';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| Variable | Description | Default |
|---|---|---|
| Execution mode: 'local', 'remote', 'auto' | 'auto' |
| Target Worker URL | http://localhost:8787 |
| Bearer token for auth | (none) |
SDK_API_TOKEN="your-token" SDK_BASE_URL="https://app.workers.dev" npx tsx scripts/sdk/examples/create-doc.tsAuthErrorValidationErrorNotFoundErrorRateLimitErrorMCPErrorNetworkErrorsrc/server/modules/mcp*/server.ts