pub struct ProgressiveGenerator<'a> { /* private fields */ }Expand description
Generator for progressive loading TypeScript files.
Creates one file per tool plus an index file and runtime bridge, enabling progressive loading where only needed tools are loaded.
§Thread Safety
This type is Send and Sync, allowing safe use across threads.
§Examples
use mcp_execution_codegen::progressive::ProgressiveGenerator;
let generator = ProgressiveGenerator::new().unwrap();Implementations§
Source§impl<'a> ProgressiveGenerator<'a>
impl<'a> ProgressiveGenerator<'a>
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new progressive generator.
Initializes the template engine and registers all progressive loading templates.
§Errors
Returns error if template registration fails (should not happen with valid built-in templates).
§Examples
use mcp_execution_codegen::progressive::ProgressiveGenerator;
let generator = ProgressiveGenerator::new().unwrap();Sourcepub fn generate(&self, server_info: &ServerInfo) -> Result<GeneratedCode>
pub fn generate(&self, server_info: &ServerInfo) -> Result<GeneratedCode>
Generates progressive loading files for a server.
Creates one TypeScript file per tool, plus:
index.ts: Re-exports all tools_runtime/mcp-bridge.ts: Runtime bridge for calling MCP tools
§Arguments
server_info- MCP server introspection data
§Returns
Generated code with one file per tool plus index and runtime bridge.
§Errors
Returns error if:
- Template rendering fails
- Type conversion fails
§Examples
use mcp_execution_codegen::progressive::ProgressiveGenerator;
use mcp_execution_introspector::{ServerInfo, ServerCapabilities};
use mcp_execution_core::ServerId;
let generator = ProgressiveGenerator::new()?;
let info = ServerInfo {
id: ServerId::new("github"),
name: "GitHub".to_string(),
version: "1.0.0".to_string(),
tools: vec![],
capabilities: ServerCapabilities {
supports_tools: true,
supports_resources: false,
supports_prompts: false,
},
};
let code = generator.generate(&info)?;
// Files generated:
// - index.ts
// - _runtime/mcp-bridge.ts
// - one file per tool
println!("Generated {} files", code.file_count());Sourcepub fn generate_with_categories(
&self,
server_info: &ServerInfo,
categorizations: &HashMap<String, ToolCategorization>,
) -> Result<GeneratedCode>
pub fn generate_with_categories( &self, server_info: &ServerInfo, categorizations: &HashMap<String, ToolCategorization>, ) -> Result<GeneratedCode>
Generates progressive loading files with categorization metadata.
Like generate, but includes full categorization information from Claude’s
analysis. Categories, keywords, and short descriptions are displayed in
the index file and included in individual tool file headers.
§Arguments
server_info- MCP server introspection datacategorizations- Map of tool name to categorization metadata
§Returns
Generated code with categorization metadata included.
§Errors
Returns error if template rendering fails.
§Examples
use mcp_execution_codegen::progressive::{ProgressiveGenerator, ToolCategorization};
use mcp_execution_introspector::{ServerInfo, ServerCapabilities};
use mcp_execution_core::ServerId;
use std::collections::HashMap;
let generator = ProgressiveGenerator::new()?;
let info = ServerInfo {
id: ServerId::new("github"),
name: "GitHub".to_string(),
version: "1.0.0".to_string(),
tools: vec![],
capabilities: ServerCapabilities {
supports_tools: true,
supports_resources: false,
supports_prompts: false,
},
};
let mut categorizations = HashMap::new();
categorizations.insert("create_issue".to_string(), ToolCategorization {
category: "issues".to_string(),
keywords: "create,issue,new,bug".to_string(),
short_description: "Create a new issue".to_string(),
});
let code = generator.generate_with_categories(&info, &categorizations)?;