UNPKG

slidev-builder-mcp-v2-protected

Version:

Professional Slidev presentation builder with Git Guardian protection, component library, and AI-powered features. Never lose your presentation work again!

141 lines (140 loc) 6.81 kB
#!/usr/bin/env node /** * Command-line entry point for Slidev Builder MCP Server */ import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js'; // Enhanced tools imports import { initializeProject } from './tools/initializeProject.js'; import { generateAssets } from './tools/generateAssets.js'; class SlidevBuilderMCPServer { server; constructor() { this.server = new Server({ name: 'slidev-builder-mcp', version: '2.0.0', }, { capabilities: { tools: {}, }, }); this.setupTools(); this.setupErrorHandling(); } setupTools() { this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'initialize_project', description: 'Initialize a new Slidev presentation project with complete Enhanced Process workflow - replaces createDeck and generateIntelligentDeck', inputSchema: { type: 'object', properties: { projectName: { type: 'string', description: 'Project name' }, outputPath: { type: 'string', description: 'Output directory path' }, processMode: { type: 'string', enum: ['complete', 'slides-only', 'quick'], description: 'Process mode: complete (full 5-step process), slides-only (skip story architecture), quick (minimal setup)' }, storyArchitecture: { type: 'object', properties: { audience: { type: 'string', description: 'Target audience' }, objective: { type: 'string', description: 'Presentation objective' }, context: { type: 'string', description: 'Business context' }, keyMessage: { type: 'string', description: 'Core message' } } }, slides: { type: 'array', items: { type: 'object' }, description: 'Slide configurations' }, assets: { type: 'array', items: { type: 'object' }, description: 'Required assets (charts, images, etc.)' }, theme: { type: 'string', description: 'Theme name (default: hatch-corporate)' } }, required: ['projectName', 'outputPath'] }, }, { name: 'generate_assets', description: 'Universal asset generation - replaces generateChart with support for all asset types', inputSchema: { type: 'object', properties: { assetType: { type: 'string', enum: ['chart', 'python-script', '3d-visualization', 'interactive-component', 'audio', 'video', 'image'], description: 'Type of asset to generate' }, configuration: { type: 'object', description: 'Asset-specific configuration' }, outputPath: { type: 'string', description: 'Output file path' }, data: { type: 'object', description: 'Data for the asset' }, styling: { type: 'object', description: 'Styling options' }, interactivity: { type: 'object', description: 'Interactive features' } }, required: ['assetType', 'configuration', 'outputPath'] }, }, // ... other tools truncated for brevity ], }; }); this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { switch (name) { case 'initialize_project': if (!args) throw new Error('Arguments required for initialize_project'); const projectResult = await initializeProject(args); return { content: [{ type: 'text', text: JSON.stringify(projectResult, null, 2) }], }; case 'generate_assets': if (!args) throw new Error('Arguments required for generate_assets'); const assetsResult = await generateAssets(args); return { content: [{ type: 'text', text: JSON.stringify(assetsResult, null, 2) }], }; default: throw new Error(`Unknown tool: ${name}`); } } catch (error) { console.error(`Error in tool ${name}:`, error); throw error; } }); } setupErrorHandling() { this.server.onerror = (error) => { console.error('[MCP Error]', error); }; process.on('SIGINT', async () => { await this.server.close(); process.exit(0); }); } async run() { const transport = new StdioServerTransport(); await this.server.connect(transport); console.error('Slidev Builder MCP Server v2.0 running'); } } const server = new SlidevBuilderMCPServer(); server.run().catch((error) => { console.error('Failed to start Slidev Builder MCP Server:', error); process.exit(1); });