UNPKG

claude-expert-workflow-mcp

Version:

Production-ready MCP server for AI-powered product development consultation through specialized expert roles. Enterprise-grade with memory management, monitoring, and Claude Code integration.

105 lines (94 loc) 3.16 kB
#!/usr/bin/env node import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; // Global infrastructure state let infrastructureReady = false; let storage: any = null; let workflowEngine: any = null; // Minimal MCP server - connect FIRST const server = new McpServer({ name: "expert-workflow-reverse", version: "1.0.0" }); // Register tools immediately (before infrastructure) server.registerTool( "start_workflow", { title: "Start Multi-Expert Workflow", description: "Start a new multi-expert workflow analysis", inputSchema: { projectDescription: z.string().describe("Detailed description of the project to analyze"), workflowType: z.enum(['linear', 'parallel', 'custom']).default('linear').describe("Type of workflow to execute"), } }, async ({ projectDescription, workflowType }) => { if (!infrastructureReady) { return { content: [{ type: "text" as const, text: JSON.stringify({ status: "initializing", message: "Infrastructure still loading... Please try again in a moment.", progress: "Setting up storage, monitoring, and workflow engine" }, null, 2) }] }; } // TODO: Use real infrastructure when ready const mockWorkflowId = `workflow_${Date.now()}`; return { content: [{ type: "text" as const, text: JSON.stringify({ success: true, workflowId: mockWorkflowId, message: "Workflow started successfully", projectDescription: projectDescription.substring(0, 100) + "...", workflowType }, null, 2) }] }; } ); server.registerTool( "get_system_status", { title: "Get System Status", description: "Check if infrastructure is ready and get system info", inputSchema: {} }, async () => ({ content: [{ type: "text" as const, text: JSON.stringify({ infrastructureReady, uptime: process.uptime(), memoryUsage: process.memoryUsage(), nodeVersion: process.version }, null, 2) }] }) ); // Connect to MCP protocol IMMEDIATELY async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("Expert Workflow MCP Server (Reverse Architecture) running on stdio"); // Initialize infrastructure in background AFTER MCP connection setTimeout(initializeInfrastructure, 500); } // Background infrastructure initialization async function initializeInfrastructure() { try { // Simulate infrastructure setup without blocking MCP console.error("Starting background infrastructure initialization..."); // Mock infrastructure - replace with real later await new Promise(resolve => setTimeout(resolve, 2000)); // Simulate setup time infrastructureReady = true; console.error("Infrastructure ready!"); } catch (error) { console.error("Infrastructure initialization failed:", error); } } main().catch(() => process.exit(1));