mcp_execution_server/lib.rs
1//! MCP server library for progressive loading generation.
2//!
3//! This crate provides an MCP server that helps generate progressive loading
4//! TypeScript files for other MCP servers. It leverages Claude's natural
5//! language understanding for tool categorization - no separate LLM API needed.
6//!
7//! # Architecture
8//!
9//! The server implements three main tools:
10//!
11//! 1. **`introspect_server`** - Connect to a target MCP server and discover its tools
12//! 2. **`save_categorized_tools`** - Generate TypeScript files with Claude's categorization
13//! 3. **`list_generated_servers`** - List all servers with generated files
14//!
15//! # Workflow
16//!
17//! 1. User asks Claude to generate progressive loading for an MCP server
18//! 2. Claude calls `introspect_server` to discover tools
19//! 3. Claude analyzes tool metadata and assigns categories, keywords, descriptions
20//! 4. Claude calls `save_categorized_tools` with categorization
21//! 5. Server generates TypeScript files with discovery headers
22//!
23//! # Examples
24//!
25//! ```no_run
26//! use mcp_execution_server::service::GeneratorService;
27//! use rmcp::transport::stdio;
28//! use rmcp::ServiceExt;
29//!
30//! # async fn example() -> anyhow::Result<()> {
31//! // Create and run the service
32//! let service = GeneratorService::new().serve(stdio()).await?;
33//! service.waiting().await?;
34//! # Ok(())
35//! # }
36//! ```
37//!
38//! # State Management
39//!
40//! The server maintains temporary session state between `introspect_server` and
41//! `save_categorized_tools` calls. Sessions expire after 30 minutes and are
42//! cleaned up lazily.
43//!
44//! # Key Benefits
45//!
46//! - **No LLM API**: Claude (the conversation LLM) does categorization
47//! - **Human-in-the-loop**: User can review and adjust categories
48//! - **Progressive loading**: 98% token savings (30,000 → 500-1,500 tokens)
49//! - **Type-safe**: Full TypeScript types from MCP schemas
50//! - **Discoverable**: grep-friendly headers for tool discovery
51
52pub mod service;
53pub mod state;
54pub mod types;
55
56pub use service::GeneratorService;
57pub use state::StateManager;
58pub use types::{
59 CategorizedTool, GeneratedServerInfo, IntrospectServerParams, IntrospectServerResult,
60 ListGeneratedServersParams, ListGeneratedServersResult, PendingGeneration,
61 SaveCategorizedToolsParams, SaveCategorizedToolsResult, ToolGenerationError, ToolMetadata,
62};
63
64// Re-export skill types from mcp-skill crate
65pub use mcp_execution_skill::{
66 GenerateSkillParams, GenerateSkillResult, SaveSkillParams, SaveSkillResult, SkillCategory,
67 SkillMetadata, SkillTool, ToolExample,
68};