# automation-ai-labs/mcp-link architecture

> Architecture diagram of the GitHub repository automation-ai-labs/mcp-link, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/automation-ai-labs/mcp-link
- Repository: https://github.com/automation-ai-labs/mcp-link

## Overview

##### Project Type & Purpose
- MCP Link is a Go-based server tool designed to automatically convert any API (defined via an OpenAPI specification) into an MCP-compatible interface that AI Agents can use. This makes it a middleware/conversion gateway that enables seamless integration of existing RESTful APIs into an AI-driven ecosystem.

##### Key Components
a. Client / AI Agent Interface:
- External client or AI Agent that consumes the MCP servers via provided URLs.
- Configuration where the client calls the MCP Link endpoint with parameterized URLs.

b. API Conversion Engine:
- Main Server (main.go): This is the entry point that starts the server, listens on a specified port, and handles incoming requests.
- Utility/Adapter Module (utils/adapter.go): Acts as a core bridge to convert the OpenAPI specification of an external API into an MCP-compatible server.
- OpenAPI Parser (utils/parser.go): Handles parsing of the OpenAPI specification and may perform transformations and validations. (Don’t forget to note the existence of a test file, utils/parser_test.go, which implies extensive validation/testing.)

c. Multi-Server and SSE Module:
- Multi-Server SSE (utils/multiserver_sse.go): Implements Server-Sent Events and possibly helps the server push events or maintain multiple connections simultaneously. Indicate how this module supports the communication backbone between the MCP Link server and AI Agents.

d. Configuration & Examples:

##### Relationships & Data Flow
- Within the server, indicate data flow from main.go to the adapter and parser modules. This demonstrates how incoming requests (with parameters like OpenAPI spec URL, API base URL, and authentication details) are processed.
- Role of the multi-server SSE module in maintaining real-time or streaming communication back to the clients.

##### Architectural Patterns and Design Principles
- Modularity: The separation of concerns among main.go (server initiation), adapter, parser, and SSE support highlights a modular design.
- Automation & Standardization: Emphasize how the conversion is automated based on the OpenAPI spec to align any API into a consistent MCP interface.
- Zero Code Modification Principle: Signify that the MCP Link design integrates with external APIs without the need for modifying their actual implementation.

##### Relevant Technologies
- Mention technologies like SSE for continuous event streams, which is implemented within the utils/multiserver_sse.go.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client / AI Agent Interface
    subgraph "Client / AI Agent Interface"
        CLIENT("Client / AI Agent"):::client
    end

    %% MCP Link Server Components
    subgraph "MCP Link Server - Go-Based Service"
        MAIN("Main Server (main.go)"):::server
        ADAPTER("Adapter Module (utils/adapter.go)"):::server
        PARSER("OpenAPI Parser (utils/parser.go)"):::server
        SSE("Multi-Server SSE (utils/multiserver_sse.go)"):::server
    end

    %% External APIs and Configurations
    EXTERNAL("External APIs"):::external

    subgraph "Configuration & Assets"
        CONF("Configuration & Examples (examples/)"):::config
        ASSETS("Architectural Assets (assets/)"):::config
    end

    %% Data Flow - Vertical Layout
    CLIENT -->|"HTTP_Request"| MAIN
    MAIN -->|"TriggersSpecConversion"| ADAPTER
    MAIN -->|"TriggersSpecParsing"| PARSER
    ADAPTER -->|"MapsAPI"| EXTERNAL
    PARSER -->|"ValidatesSpec"| EXTERNAL
    SSE -->|"PushesEvents"| CLIENT

    %% Additional Relationship: Client linked to external configuration info
    CLIENT ---|"Uses"| CONF

    %% Note on Automation
    NOTE1["Conversion occurs automatically using provided OpenAPI specifications."]:::note

    %% Position the note at the bottom for clarity
    EXTERNAL --- NOTE1

    %% Click Events for Components
    click MAIN "https://github.com/automation-ai-labs/mcp-link/blob/main/main.go"
    click ADAPTER "https://github.com/automation-ai-labs/mcp-link/blob/main/utils/adapter.go"
    click PARSER "https://github.com/automation-ai-labs/mcp-link/blob/main/utils/parser.go"
    click SSE "https://github.com/automation-ai-labs/mcp-link/blob/main/utils/multiserver_sse.go"
    click CONF "https://github.com/automation-ai-labs/mcp-link/tree/main/examples/"
    click ASSETS "https://github.com/automation-ai-labs/mcp-link/tree/main/assets/"

    %% Styles
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef server fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef config fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef note fill:#FFE4B5,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5;
```
