Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
skill/ts-agent-sdk: Add typed SDK generation for MCP servers
Jeza396c052a2ef
diff --git a/skills/ts-agent-sdk/.claude-plugin/plugin.json b/skills/ts-agent-sdk/.claude-plugin/plugin.jsonnew file mode 100644index 00000000..8b90f78a--- /dev/null+++ b/skills/ts-agent-sdk/.claude-plugin/plugin.json@@ -0,0 +1,5 @@+{+ "name": "ts-agent-sdk",+ "version": "1.0.0",+ "description": "Generate typed TypeScript SDKs for AI agents to interact with MCP servers"+}diff --git a/skills/ts-agent-sdk/README.md b/skills/ts-agent-sdk/README.mdnew file mode 100644index 00000000..0ec3f557--- /dev/null+++ b/skills/ts-agent-sdk/README.md@@ -0,0 +1,44 @@+# ts-agent-sdk Skill++Generate typed TypeScript SDKs for AI agents to interact with web applications via MCP servers.++## What This Skill Does++Replaces verbose MCP JSON-RPC curl commands with clean, typed TypeScript function calls.++**Before (fragile curl):**+```bash+curl -X POST https://app.workers.dev/api/mcp-docs/message \+ -H "Authorization: Bearer $TOKEN" \+ -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"create_document",...}}'+```++**After (typed SDK):**+```typescript+await docs.createDocument({ spaceId: 'wiki', title: 'Guide', content: '...' })+```++## When to Use++- Project has MCP servers with tools you want to call programmatically+- You need Claude Code to manage/maintain an app via scripts+- You want typed, validated access to MCP operations++## Auto-trigger Keywords++- "generate sdk for mcp"+- "create agent sdk"+- "typed mcp client"+- "ts-agent-sdk"++## Usage++1. Invoke the skill when working on a project with MCP servers+2. Skill will detect MCP servers in `src/server/modules/mcp*/`+3. Generate typed clients for each server's tools+4. Create example scripts in `scripts/sdk/`++## Template Repository++Full pattern documentation and examples at:+`/home/jez/Documents/ts-agent-sdk/`diff --git a/skills/ts-agent-sdk/SKILL.md b/skills/ts-agent-sdk/SKILL.mdnew file mode 100644index 00000000..ac7c0128--- /dev/null+++ b/skills/ts-agent-sdk/SKILL.md@@ -0,0 +1,223 @@+---+name: ts-agent-sdk+description: |+ Generate typed TypeScript SDKs for AI agents to interact with MCP servers. Converts verbose JSON-RPC curl commands to clean function calls (docs.createDocument() vs curl). Auto-detects MCP tools from server modules, generates TypeScript types and client methods, creates runnable example scripts.++ Use when: building MCP-enabled applications, need typed programmatic access to MCP tools, want Claude Code to manage apps via scripts, eliminating manual JSON-RPC curl commands, validating MCP inputs/outputs, or creating reusable agent automation.+license: MIT+metadata:+ category: tooling+ stack:+ - TypeScript+ - MCP+ - SDK Generation+ keywords:+ - mcp sdk+ - typescript sdk+ - agent sdk+ - typed mcp client+ - json-rpc+ - mcp tools+ - sdk generation+ - ai agents+ - claude code+ - runnable examples+ - zod schemas+ - type safety+ - mcp server+ - tool definitions+ - client generation+ errors_prevented:+ - Verbose JSON-RPC curl commands requiring manual construction+ - Untyped MCP tool calls with runtime validation errors+ - Manual SDK maintenance when MCP tools change+ - Parameter validation errors from incorrect JSON structures+ - Auth header management duplication across scripts+ - Environment config scattered across multiple files+ last_verified: 2025-11-27+ template_location: /home/jez/Documents/ts-agent-sdk/template/scripts/sdk/+---++# 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 at:+`/home/jez/Documents/ts-agent-sdk/template/scripts/sdk/`++Copy these files to the target project's `scripts/sdk/` directory as a starting point.++## 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:+```typescript+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:++```typescript+// 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:++```typescript+// 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/`:++```typescript+#!/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`:++```typescript+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:+```bash+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/