|
| 1 | +# 🧭 MCP Hybrid AI Wizard – Flow & Module Architecture |
| 2 | + |
| 3 | +This document shows how user-driven input and AI-driven automation combine within the MCP system. |
| 4 | +The goal: users still interact with forms, while the AI Wizard orchestrates MCP tools to build pipelines and deploy them automatically. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 🧩 High-Level Flow |
| 9 | + |
| 10 | +```mermaid |
| 11 | +flowchart TD |
| 12 | +
|
| 13 | +A[User UI / Wizard Form] -->|Form Data| B[AI Wizard Agent] |
| 14 | +B -->|Decides Which Tool(s) to Use| C[MCP API Layer] |
| 15 | +C -->|REST Call| D[Tool Endpoint] |
| 16 | +D -->|Calls Integration Stub| E[Integration Layer] |
| 17 | +E -->|Returns Mock/Real Data| C |
| 18 | +C -->|Response| B |
| 19 | +B -->|Summarized Result / Next Step| A |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## ⚙️ Module Breakdown |
| 25 | + |
| 26 | +### 1️⃣ Frontend (Wizard UI) |
| 27 | +- Presents form fields (repo, branch, provider, template). |
| 28 | +- Sends collected inputs to the **AI Wizard Agent**. |
| 29 | +- Renders conversation steps or results returned by the agent. |
| 30 | + |
| 31 | +**Tech stack:** React + Zustand + shadcn/ui |
| 32 | +**Responsibility:** UX and data capture. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +### 2️⃣ AI Wizard Agent |
| 37 | +- Acts as the **intelligent middle layer** between the user and the MCP tools. |
| 38 | +- Determines which tool(s) to invoke based on the user’s form data and conversation context. |
| 39 | +- Parses MCP responses, summarizes, and sends human-readable updates back to UI. |
| 40 | + |
| 41 | +**Example logic:** |
| 42 | +```js |
| 43 | +if (user.provider === "aws") useTool("oidc_adapter"); |
| 44 | +useTool("pipeline_generator", user); |
| 45 | +``` |
| 46 | + |
| 47 | +**Responsibility:** Reasoning, orchestration, and dynamic flow. |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +### 3️⃣ MCP API Layer |
| 52 | +- Express server exposing endpoints under `/mcp/v1`. |
| 53 | +- Validates input with Zod. |
| 54 | +- Routes requests to internal tool modules (repo_reader, pipeline_generator, oidc_adapter). |
| 55 | + |
| 56 | +**Responsibility:** Standardize all backend access through predictable JSON schemas. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### 4️⃣ MCP Tools (under `/server/tools/`) |
| 61 | +Each tool = single responsibility function with metadata and schema. |
| 62 | + |
| 63 | +Example structure: |
| 64 | +```js |
| 65 | +export const pipeline_generator = { |
| 66 | + name: "pipeline_generator", |
| 67 | + description: "Generate CI/CD YAML for a given repo and provider", |
| 68 | + input_schema: z.object({ |
| 69 | + repo: z.string(), |
| 70 | + provider: z.enum(["aws", "jenkins"]), |
| 71 | + template: z.string() |
| 72 | + }), |
| 73 | + handler: async (params) => { ... } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +**Responsibility:** Encapsulate logic for each automation unit. |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +### 5️⃣ Integrations Layer |
| 82 | +- Mock or real API wrappers for external systems. |
| 83 | +- Organized by provider type. |
| 84 | + |
| 85 | +Structure: |
| 86 | +``` |
| 87 | +server/integrations/ |
| 88 | +├── github/ |
| 89 | +│ └── index.js |
| 90 | +├── aws/ |
| 91 | +│ └── index.js |
| 92 | +└── jenkins/ |
| 93 | + └── index.js |
| 94 | +``` |
| 95 | + |
| 96 | +**Responsibility:** Handle API auth, SDK calls, and return normalized data. |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +### 6️⃣ Database (Supabase / Postgres) |
| 101 | +- Stores users, connections, and tokens (encrypted). |
| 102 | +- Provides audit logs of which tools ran under which user. |
| 103 | + |
| 104 | +**Responsibility:** Persistence and security layer. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## ✅ Summary |
| 109 | + |
| 110 | +| Layer | Role | Example Interaction | |
| 111 | +|-------|------|----------------------| |
| 112 | +| Frontend | Collects user input | Form submits data | |
| 113 | +| AI Wizard | Decides which MCP tool to use | “I’ll generate your AWS pipeline.” | |
| 114 | +| MCP Server | Hosts tools and APIs | `/mcp/v1/pipeline_generator` | |
| 115 | +| Tools | Do one job well | Return YAML or list of roles | |
| 116 | +| Integrations | Communicate externally | AWS IAM, GitHub, Jenkins | |
| 117 | +| Database | Persist context | Users, connections, logs | |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## 🧠 Next Steps for Implementation |
| 122 | +1. Create `/server/routes/mcp.js` to modularize endpoints. |
| 123 | +2. Move endpoint logic into `/server/tools/`. |
| 124 | +3. Register each tool in an MCP registry. |
| 125 | +4. Integrate the AI Wizard (OpenAI, LangChain, or custom agent). |
| 126 | +5. Have the agent call MCP tools dynamically based on user input. |
0 commit comments