Expand description
Progressive loading code generation for MCP tools.
This crate generates TypeScript files for progressive loading pattern, where each MCP tool is a separate file. This enables Claude Code to discover and load tools on-demand, achieving 98% token savings.
§Architecture
The progressive loading pattern works as follows:
- Tool Discovery: Claude Code lists files in
~/.claude/servers/{server-id}/ - Selective Loading: Claude Code reads only the tools it needs
- Execution: Generated TypeScript code calls MCP tools via bridge
§Example
use mcp_execution_codegen::progressive::ProgressiveGenerator;
use mcp_execution_introspector::ServerInfo;
let generator = ProgressiveGenerator::new()?;
// generator.generate(&server_info)?;§Generated Structure
For a server with 3 tools, generates:
~/.claude/servers/github/
├── index.ts # Re-exports all tools
├── createIssue.ts # Individual tool file
├── updateIssue.ts # Individual tool file
└── _runtime/
└── mcp-bridge.ts # Runtime helper§Token Savings
- Traditional: Load all 30 tools upfront = 30,000 tokens
- Progressive: Load on-demand = ~2,000 tokens per tool
- Savings: 93-98%
Re-exports§
pub use common::types::GeneratedCode;pub use common::types::GeneratedFile;pub use common::types::TemplateContext;pub use common::types::ToolDefinition;pub use progressive::ProgressiveGenerator;pub use template_engine::TemplateEngine;
Modules§
- common
- Common code shared between all feature modes.
- progressive
- Progressive loading code generation module.
- template_
engine - Template engine for code generation using Handlebars.