| name | generate-sdk-types |
| description | Generates TypeScript type definitions for SDK from Rust tool schemas, ensuring type safety between server and client |
| user-invocable | true |
Generate SDK Types Skill
Purpose
Generates TypeScript type definitions for the SDK from Rust tool schemas, ensuring type safety between server and client.
CLAUDE.md Compliance
- ✅ Automated type generation (no manual sync)
- ✅ Validates type consistency
- ✅ Prevents type drift between Rust and TypeScript
Usage
Run this skill:
- After adding/modifying MCP tools
- After changing tool parameter schemas
- Before SDK releases
- After protocol changes
Prerequisites
- Bun runtime installed
- Pierre server must be runnable
sdk/ directory with dependencies installed
Commands
Standard Type Generation
cargo run --bin pierre-mcp-server &
SERVER_PID=$!
sleep 3
cd sdk
bun run generate-types
git diff src/types.ts
kill $SERVER_PID
cd ..
One-Command Generation
./scripts/sdk/generate-sdk-types.js
Manual Generation Process
cargo run --bin pierre-mcp-server &
SERVER_PID=$!
sleep 3
curl -X POST http://localhost:8081/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"tools/list","id":1}' \
> /tmp/tools.json
cd sdk
node scripts/generate-types.js /tmp/tools.json
bun run format
kill $SERVER_PID
cd ..
Generated Type Structure
Tool Definitions
export interface Tool {
name: string;
description: string;
inputSchema: {
type: 'object';
properties: Record<string, JsonSchema>;
required?: string[];
};
}
export interface GetActivitiesParams {
start_date?: string;
end_date?: string;
limit?: number;
provider?: 'strava' | 'garmin' | 'fitbit';
}
Tool Registry
export const TOOLS: Tool[] = [
{
name: 'get_activities',
description: 'Retrieves fitness activities...',
inputSchema: { }
},
];
Type Validation
Pre-Generation Check
cargo build --lib
rg "^pub const TOOL_" src/protocols/universal/tool_registry.rs --type rust | wc -l
Post-Generation Validation
cd sdk
bun run build
bun test -- test/unit/types.test.ts
bun run type-check
cd ..
Diff Analysis
git diff sdk/src/types.ts
Type Generation Workflow
1. Add New Tool in Rust
pub const TOOL_MY_NEW_FEATURE: ToolDefinition = ToolDefinition {
name: "my_new_feature",
description: "Does something useful",
input_schema: json!({
"type": "object",
"properties": {
"param1": { "type": "string" },
"param2": { "type": "number" }
},
"required": ["param1"]
}),
};
2. Register Tool
impl UniversalToolExecutor {
pub fn register_tools(&mut self) {
self.register(TOOL_MY_NEW_FEATURE, handle_my_new_feature);
}
}
3. Generate TypeScript Types
cd sdk
bun run generate-types
4. Verify Generated Types
export interface MyNewFeatureParams {
param1: string;
param2?: number;
}
export const TOOL_MY_NEW_FEATURE: Tool = {
name: 'my_new_feature',
description: 'Does something useful',
inputSchema: { }
};
5. Commit Changes
git add src/protocols/universal/tool_registry.rs
git add sdk/src/types.ts
git commit -m "feat: add my_new_feature tool with TypeScript types"
Success Criteria
- ✅ TypeScript types match Rust tool definitions
- ✅ All tools have corresponding TypeScript interfaces
- ✅ Generated code compiles without errors
- ✅ Type tests pass
- ✅ No manual type definitions (all auto-generated)
- ✅ Git diff shows expected changes only
Related Files
scripts/sdk/generate-sdk-types.js - Type generation script
sdk/src/types.ts - Generated TypeScript types
src/protocols/universal/tool_registry.rs - Rust tool definitions
sdk/TYPE_GENERATION.md - Type generation documentation
Related Skills
test-mcp-compliance - MCP protocol validation