# wong2/mcp-cli architecture

> Architecture diagram of the GitHub repository wong2/mcp-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wong2/mcp-cli
- Repository: https://github.com/wong2/mcp-cli

## Overview

##### Main Components Identification
The project is a CLI tool with these key components:

a) CLI Interface Layer
- Entry point through cli.js
- Handles command parsing and user interactions

b) MCP Core Layer (mcp.js)
- Main protocol implementation
- Handles communication with MCP servers

c) Utilities Layer (utils.js)
- Supporting functions
- Should be represented as a helper component

##### External Interactions
Important external components:

a) MCP Servers
- Claude Desktop config
- Custom config servers
- NPM package servers
- Local development servers

b) MCP Resources
- Tools
- Resources
- Prompts

**[User Terminal] → [CLI Layer] → [MCP Core] ↔ [MCP Servers]**
- ↑             ↑
- [Utils] ─┘

##### Specific Details

a) CLI Layer:
- Command parsing
- Config file handling
- NPX execution capability
- Server launching functionality

b) MCP Core:
- Server communication
- Protocol implementation
- Resource management
- Tool execution

c) External Connections:
- Claude Desktop integration
- Custom config file support
- NPM package execution
- Local server support

##### Data Flow Indicators

Key interactions:
- User input → CLI
- CLI → MCP Core
- MCP Core ↔ Servers
- Tools/Resources/Prompts access patterns

##### Important Notes

- Keep the focus on the MCP protocol interaction
- Flexibility in server sources
- Resource types (Tools, Resources, Prompts)
- Config file integration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#1976D2,stroke:#0D47A1,color:white
    classDef utils fill:#9E9E9E,stroke:#616161,color:white
    classDef server fill:#4CAF50,stroke:#2E7D32,color:white
    classDef resource fill:#FF9800,stroke:#F57C00,color:white
    classDef user fill:#E91E63,stroke:#C2185B,color:white
    classDef config fill:#673AB7,stroke:#512DA8,color:white

    %% User Entry Point
    User[User Terminal]:::user

    %% Main Application Components
    CLI[CLI Interface]:::cli
    MCP[MCP Core]:::core
    Utils[Utilities]:::utils
    Config[Package Config]:::config

    %% External Servers
    subgraph Servers
        ClaudeServer[Claude Desktop Server]:::server
        CustomServer[Custom Config Server]:::server
        NPMServer[NPM Package Server]:::server
        LocalServer[Local Dev Server]:::server
    end

    %% MCP Resources
    subgraph Resources
        Tools[Tools]:::resource
        Prompts[Prompts]:::resource
        MCPResources[Resources]:::resource
    end

    %% Relationships
    User --> CLI
    CLI --> MCP
    Utils --> CLI
    Utils --> MCP
    Config --> CLI
    MCP --> ClaudeServer
    MCP --> CustomServer
    MCP --> NPMServer
    MCP --> LocalServer
    MCP --> Tools
    MCP --> Prompts
    MCP --> MCPResources

    %% Click Events
    click CLI "https://github.com/wong2/mcp-cli/blob/main/src/cli.js"
    click MCP "https://github.com/wong2/mcp-cli/blob/main/src/mcp.js"
    click Utils "https://github.com/wong2/mcp-cli/blob/main/src/utils.js"
    click Config "https://github.com/wong2/mcp-cli/blob/main/package.json"

    %% Legend
    subgraph Legend
        L1[User Interface]:::user
        L2[Core Components]:::core
        L3[Utility Components]:::utils
        L4[External Servers]:::server
        L5[MCP Resources]:::resource
        L6[Configuration]:::config
    end
```
