ProgressiveGenerator

Struct ProgressiveGenerator 

Source
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>

Source

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();
Source

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());
Source

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 data
  • categorizations - 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)?;

Trait Implementations§

Source§

impl<'a> Debug for ProgressiveGenerator<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more