Skip to main content
Glama
Architecture-Analysis.md5.41 kB
# MCP Server Architecture & Maintainability Analysis ## Project Structure Strategy ### ❌ Mixed Approach Problems: ``` mermaid/ (original repo) ├── src/mermaid.ts # Original Mermaid code ├── src/mcp-tools.ts # Our custom MCP code (MIXED!) └── package.json # Conflicting dependencies ``` **Issues with Mixed Approach:** - **Merge Conflicts**: Every Mermaid update could conflict with our MCP code - **Dependency Hell**: Mermaid updates might break our MCP dependencies - **Testing Complexity**: Hard to test MCP features independently - **Deployment Issues**: Can't deploy MCP server without entire Mermaid repo - **Version Lock**: Stuck with specific Mermaid version to avoid breaking changes ### ✅ Separate Project Benefits: ``` mermaid-mcp-server/ (our project) ├── package.json │ └── dependencies: │ └── "mermaid": "^11.11.0" # Import as NPM dependency └── src/ ├── index.ts # MCP server └── tools/ # Our MCP tools ``` **Advantages:** - **Clean Updates**: `npm update mermaid` to get latest features - **Independent Versioning**: MCP server versions separate from Mermaid - **Selective Integration**: Choose which Mermaid features to expose - **Easy Testing**: Test MCP functionality independently - **Flexible Deployment**: Deploy only what's needed ## Upgrade Strategy for Mermaid Improvements ### Automatic Benefits: ```javascript // Our MCP server automatically gets new features: import mermaid from 'mermaid'; // When Mermaid adds new diagram types, we get them automatically const supportedDiagrams = mermaid.getSupportedDiagrams(); // New types included! ``` ### Controlled Integration: ```javascript // We can test new features before exposing them const newFeatures = detectNewMermaidFeatures(); if (newFeatures.length > 0) { logNewFeatures(newFeatures); // Add to MCP tools after validation } ``` ### Version Management: ```json { "dependencies": { "mermaid": "~11.11.0", // Patch updates only // OR "mermaid": "^11.11.0" // Minor updates allowed } } ``` ## 2. MCP Deployment Architecture ### Local Deployment (Recommended) The MCP server runs **locally** on the user's machine, no remote calls needed: ``` ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ │ GitHub │ │ MCP Server │ │ Mermaid │ │ Copilot │◄──►│ (Local Process) │◄──►│ Library │ │ │ │ Port: 3000 │ │ (Node.js) │ └─────────────────┘ └──────────────────┘ └─────────────────┘ │ │ │ ▼ │ ┌──────────────────┐ │ │ File System │ └───────────────►│ diagrams.svg │ │ output.png │ └──────────────────┘ ``` ### How It Works: 1. **Installation**: User installs MCP server locally 2. **Configuration**: GitHub Copilot connects to local MCP server 3. **Processing**: All diagram generation happens locally 4. **Output**: Files saved directly to user's project ### No Remote Calls Required: - ✅ **Fully Local**: Everything runs on user's machine - ✅ **Fast Performance**: No network latency - ✅ **Privacy**: Code never leaves user's machine - ✅ **Offline Capable**: Works without internet (after installation) ## Deployment Options ### Option 1: Local Installation (Primary) ```bash # User installs globally npm install -g mermaid-mcp-server # Or project-specific npm install --save-dev mermaid-mcp-server ``` ### Option 2: Docker Container (Advanced) ```dockerfile FROM node:18 COPY . /app WORKDIR /app RUN npm install EXPOSE 3000 CMD ["npm", "start"] ``` ### Option 3: VS Code Extension (Future) ```json { "name": "mermaid-mcp-extension", "main": "./out/extension.js", "contributes": { "configuration": { "mermaid.mcp.enabled": true } } } ``` ## Configuration Example ### GitHub Copilot MCP Config: ```json { "mcpServers": { "mermaid": { "command": "node", "args": ["/path/to/mermaid-mcp-server/dist/index.js"], "env": {} } } } ``` ### MCP Server Startup: ```javascript import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import mermaid from 'mermaid'; const server = new Server({ name: 'mermaid-mcp-server', version: '1.0.0' }); // Initialize Mermaid locally await mermaid.initialize({ startOnLoad: false, theme: 'default' }); server.listen(); // Local process, no network required ``` ## Performance Benefits ### Local Processing: - **Speed**: Sub-second diagram generation - **Reliability**: No network dependencies - **Security**: Code stays on user's machine - **Cost**: No server hosting costs ### Resource Usage: - **Memory**: ~50MB for MCP server + Mermaid - **CPU**: Only during diagram generation - **Storage**: Generated files stay local

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Narasimhaponnada/mcp-mermiad'

If you have feedback or need assistance with the MCP directory API, please join our Discord server