# acomagu/vscode-as-mcp-server architecture

> Architecture diagram of the GitHub repository acomagu/vscode-as-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acomagu/vscode-as-mcp-server
- Repository: https://github.com/acomagu/vscode-as-mcp-server

## Overview

##### Main Components
- VSCode Extension Core: This is the primary component that initializes the MCP server inside VSCode. It contains the extension entry point (packages/extension/src/extension.ts) along with several submodules.
- Built-in MCP Server & Tools: These include the various tools for code editing, diagnostics, terminal operations, preview URL, and other commands (e.g., execute_command, code_checker, list_directory) located in packages/extension/src/tools and packages/extension/src/integrations.
- Transport Layers: Modules such as bidi-http-transport, sock-transport, and sse-transport that likely handle the communication between the extension and the client (e.g., LLM or Claude Desktop) should be shown as separate components.
- Terminal Integration: Detail the integration modules (in packages/extension/src/integrations/terminal) which manage terminal processes, output extraction, and the terminal registry for command execution.
- Relay Module: Represent the relay package (packages/relay) that functions to expose or integrate other MCP servers and acts as an experimental bridge to external tools.

##### Relationships and Interactions
- The Extension Core initializes the MCP server and registers the different tools.
- The MCP server interacts with the Transport Layers to handle external communications with MCP clients.
- The Core then forwards requests to dedicated modules:
– Code operations and diagnostics are handled via the code editing support tools.
– Terminal-related requests are channeled to the Terminal Integration component.
– URL preview and file operations are managed by their designated tools under packages/extension/src/tools.
- The Relay package stands as an optional branch that receives inputs either directly or via the extension core to expose built-in MCP services externally.

##### Architectural Patterns & Design Principles
- Modularity: The project is split into multiple packages (extension and relay) and clearly divided between integration, transport, and utility modules.
- Command Pattern: The way tool commands (execute_command, code_checker, etc.) are designed and invoked hints at an MVC or command pattern architecture.
- Separation of Concerns: Each module (e.g., transport, terminal, tools) handles a particular aspect of the extension’s functionality.

##### Incorporating Technologies & Frameworks
- VSCode Extension API – the integration point that ties all the components together.
- TypeScript is used throughout with associated configuration (tsconfig.json files).
- Build tools including webpack (webpack.config.js) and build scripts (build.js in the extension package).
- Testing frameworks indicated by the presence of test directories and files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% VSCode Extension Core
    A["VSCode Extension Core"]:::core
    click A "https://github.com/acomagu/vscode-as-mcp-server/blob/main/packages/extension/src/extension.ts"
    
    %% Built-in MCP Server & Tools Subgraph
    subgraph "Built-in MCP Server & Tools"
        B["MCP Server"]:::server
        click B "https://github.com/acomagu/vscode-as-mcp-server/blob/main/packages/extension/src/mcp-server.ts"
        C["Tools"]:::tools
        click C "https://github.com/acomagu/vscode-as-mcp-server/tree/main/packages/extension/src/tools"
    end
    
    %% Transport Layers Subgraph
    subgraph "Transport Layers"
        D["bidi-http-transport"]:::transport
        click D "https://github.com/acomagu/vscode-as-mcp-server/blob/main/packages/extension/src/bidi-http-transport.ts"
        E["sock-transport"]:::transport
        click E "https://github.com/acomagu/vscode-as-mcp-server/blob/main/packages/extension/src/sock-transport.ts"
        F["sse-transport"]:::transport
        click F "https://github.com/acomagu/vscode-as-mcp-server/blob/main/packages/extension/src/sse-transport.ts"
    end

    %% Terminal Integration Component
    G["Terminal Integration"]:::terminal
    click G "https://github.com/acomagu/vscode-as-mcp-server/tree/main/packages/extension/src/integrations/terminal"
    
    %% Relay Module Component
    H["Relay Module"]:::relay
    click H "https://github.com/acomagu/vscode-as-mcp-server/tree/main/packages/relay"
    
    %% Supporting Modules Subgraph
    subgraph "Supporting Modules"
        I["Testing"]:::support
        click I "https://github.com/acomagu/vscode-as-mcp-server/tree/main/packages/extension/src/test"
        J["Utilities"]:::support
        click J "https://github.com/acomagu/vscode-as-mcp-server/tree/main/packages/extension/src/utils"
    end
    
    %% Relationships and Data Flows
    A -->|"initializes"| B
    A -->|"registers"| C
    B -->|"communicates_with"| D
    B -->|"communicates_with"| E
    B -->|"communicates_with"| F
    C -->|"invokes"| G
    A -->|"forwards_terminal_cmds"| G
    A -->|"triggers"| H
    
    %% Styles
    classDef core fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef server fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef tools fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef transport fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef terminal fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef relay fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef support fill:#fefefe,stroke:#6c757d,stroke-width:2px;
```
