Skip to main content
Glama

Simple MCP Server

by banique15
ARCHITECTURE.md•8.69 kB
# šŸ—ļø MCP Orchestration Architecture ## šŸ“‹ Project Overview This project demonstrates **advanced MCP (Model Context Protocol) orchestration** where a primary server intelligently coordinates multiple specialized servers based on natural language queries and AI analysis. ## 🧠 Core Concept Instead of having users manually choose which server to call, the system: 1. **Accepts natural language queries** from users 2. **Uses AI to analyze** the intent and category 3. **Dynamically starts** the appropriate specialized server 4. **Calls the right tool** via proper MCP protocol 5. **Enhances responses** with AI for natural conversation ## šŸ—ļø Architecture Diagram ``` ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ │ │ │ │ │ │ Claude │ │ People-Info │ │ Developer-Info │ │ Desktop │◄──►│ Orchestrator │◄──►│ Server │ │ │ │ │ │ │ │ (User Query) │ │ • AI Analysis │ │ • Name: "Neick" │ │ │ │ • MCP Client │ │ • Tool: get_dev... │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │ • Response Enhance │ │ │ │ │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │ │ │ │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ │ │ │ │ │◄──►│ Designer-Info │ │ │ │ Server │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ │ │ │ • Name: "Jesse" │ │ • Tool: get_des... │ │ │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜ ``` ## šŸ”„ Interaction Flow ### Example: "What is the developer's name?" ``` 1. User Query ↓ 2. People-Info Orchestrator receives query ↓ 3. Claude AI Analysis: { "category": "DEVELOPER", "action": "GET_NAME", "reasoning": "User wants developer name" } ↓ 4. Orchestrator starts developer-info server ↓ 5. MCP Client calls get_developer_name tool ↓ 6. Developer server responds: "Neick" ↓ 7. Claude enhances response: "The developer's name is Neick." ↓ 8. User receives natural language answer ``` ## šŸ“ Component Breakdown ### 🧠 People-Info Orchestrator (`people-info-server/`) **Role**: Primary coordinator and AI brain **Responsibilities**: - Receive natural language queries - Analyze queries using Claude AI - Determine which specialized server to call - Start MCP servers dynamically - Act as MCP client to call tools - Enhance responses with AI **Key Technologies**: - MCP Server SDK (for receiving queries) - MCP Client SDK (for calling other servers) - Anthropic Claude API (for analysis and enhancement) - Process management (for starting servers) ### šŸ‘Øā€šŸ’» Developer-Info Server (`developer-info-server/`) **Role**: Developer data specialist **Responsibilities**: - Store developer information - Provide `get_developer_name` tool - Return developer data when called **Data**: - Name: "Neick" - (Can be extended with more developer info) ### šŸŽØ Designer-Info Server (`designer-info-server/`) **Role**: Designer data specialist **Responsibilities**: - Store designer information - Provide `get_designer_name` tool - Return designer data when called **Data**: - Name: "Jesse" - (Can be extended with more designer info) ## šŸ”§ Technical Implementation ### MCP Protocol Communication The orchestrator uses **real MCP protocol** to communicate with specialized servers: ```javascript // Start server process const serverProcess = spawn('node', ['index.js'], { cwd: serverDir, stdio: ['pipe', 'pipe', 'pipe'] }); // Create MCP client const transport = new StdioClientTransport({ command: 'node', args: ['index.js'], options: { cwd: serverDir } }); const client = new Client({ name: "people-info-client", version: "1.0.0" }, { capabilities: {} }); // Connect and call tools await client.connect(transport); const result = await client.callTool({ name: toolName, arguments: args }); ``` ### AI-Powered Query Analysis ```javascript const analysisSystemPrompt = `Analyze user queries and respond with JSON: - "category": "DEVELOPER" | "DESIGNER" | "OTHER" - "action": "GET_NAME" | "GET_INFO" | "OTHER" - "reasoning": Brief explanation`; const analysis = await anthropic.messages.create({ model: "claude-3-5-sonnet-20241022", system: analysisSystemPrompt, messages: [{ role: "user", content: query }] }); ``` ### Dynamic Server Management ```javascript const mcpClients = new Map(); // Connection pool async function startMcpServerAndConnect(serverType) { if (mcpClients.has(serverType)) { return mcpClients.get(serverType); // Reuse connection } // Start new server and create connection const connection = await createMcpConnection(serverType); mcpClients.set(serverType, connection); return connection; } ``` ## šŸŽÆ Benefits of This Architecture ### 1. **Separation of Concerns** - Each server has a single, focused responsibility - Data is stored where it logically belongs - Orchestration logic is centralized ### 2. **Natural Language Interface** - Users don't need to know which server to call - Questions can be asked in plain English - AI handles the complexity of routing ### 3. **Dynamic Resource Management** - Servers only start when needed - Connections are reused for efficiency - Proper cleanup prevents resource leaks ### 4. **Scalability** - Easy to add new specialized servers - Orchestrator can be extended with new categories - Each component can be developed independently ### 5. **Real MCP Protocol** - Demonstrates proper MCP client-server communication - Uses official MCP SDK - Follows MCP best practices ## šŸš€ Extension Possibilities ### Adding New Servers 1. **Create new specialized server** (e.g., `manager-info-server`) 2. **Update orchestrator analysis** to recognize new categories 3. **Add MCP client logic** for the new server 4. **Test with natural language queries** ### Enhanced Data Models ```javascript // Developer server could return: { name: "Neick", skills: ["JavaScript", "React", "Node.js"], experience: "5 years", projects: ["E-commerce Platform", "Mobile App"] } // Designer server could return: { name: "Jesse", specialties: ["UI/UX", "Branding", "Prototyping"], tools: ["Figma", "Adobe Creative Suite"], portfolio: ["Website Redesign", "Mobile App UI"] } ``` ### Advanced Query Types - *"What skills does the developer have?"* - *"Show me the designer's portfolio"* - *"Who worked on the mobile app project?"* - *"Compare the developer and designer experience"* ## šŸ† Advanced MCP Patterns Demonstrated 1. **Multi-Server Orchestration**: Coordinating multiple MCP servers 2. **Dynamic Server Lifecycle**: Starting servers on-demand 3. **MCP Client Implementation**: Acting as both server and client 4. **AI-Powered Routing**: Using LLMs for intelligent request routing 5. **Natural Language Processing**: Converting queries to structured actions 6. **Response Enhancement**: Improving raw data with AI 7. **Connection Management**: Efficient resource usage and cleanup ## šŸ“š Learning Outcomes This project teaches: - **MCP Protocol Fundamentals**: Server and client implementation - **AI Integration**: Using LLMs for analysis and enhancement - **Process Management**: Spawning and managing child processes - **Distributed Architecture**: Coordinating multiple services - **Natural Language Interfaces**: Building conversational APIs - **Resource Management**: Efficient connection pooling and cleanup --- **This architecture serves as a reference implementation for building intelligent, AI-powered MCP orchestration systems.** šŸš€

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/banique15/MCP-Server'

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