# snick-m/auto_mcp architecture

> Architecture diagram of the GitHub repository snick-m/auto_mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/snick-m/auto_mcp
- Repository: https://github.com/snick-m/auto_mcp

## Overview

##### Project Type and Purpose
- This is a ROS2 “drop-in” package named **auto_mcp** that exposes a Model Context Protocol (MCP) server over HTTP/SSE for any ROS-based robot.
- It introspects the live ROS topic graph at startup and publishes those topics (and their message interfaces) via an SSE endpoint on port 5000 so an LLM‐based client can subscribe and act on them.

##### File Structure Analysis
- Top-level files:
- `package.xml`, `setup.py`, `setup.cfg` – ROS2 and Python packaging metadata
- `resource/auto_mcp` – marker resource for ROS2 package discovery
- `auto_mcp/` directory contains four modules:
- `introspect.py` – uses ROS2 introspection APIs to gather topic names and types
- `fast_server.py` – sets up the HTTP/SSE server (likely on `0.0.0.0:5000`) and ties in the MCP SDK
- `hello.py` – sample or placeholder module (can represent basic sanity checks)
- `__init__.py` – package initializer
- `test/` directory with linters and style checks, indicating CI and code quality gates.

##### README Insights
- Describes two logical phases:
a. **Introspection Phase:** run last, queries ROS2 for all live topics/interfaces
b. **MCP Server Phase:** spins up an SSE‐over‐HTTP transport using the MCP Python SDK
- External dependency: `mcp` Python SDK for the Model Context Protocol
- Usage: `ros2 run auto_mcp server` → introspection → SSE at `/sse`

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "ROS2 Ecosystem"
        RM["ROS Master"]:::ros
        RN["Other ROS Nodes"]:::ros
        TG["ROS2 Topic Graph"]:::ros
        RM --> TG
        RN --> TG
    end

    subgraph "auto_mcp Package"
        PM["ROS2 Package Metadata"]:::pkg
        P1["package.xml"]:::pkg
        P2["setup.py"]:::pkg
        P3["setup.cfg"]:::pkg
        P4["resource/auto_mcp"]:::pkg
        PM --> P1
        PM --> P2
        PM --> P3
        PM --> P4

        Init["__init__.py"]:::pkg
        Int["Introspection Module"]:::pkg
        HS["MCP/HTTP SSE Server Module"]:::pkg
        HP["Sample Module (hello.py)"]:::pkg

        Tests["CI/Test Suite"]:::pkg
        T1["test_copyright.py"]:::pkg
        T2["test_flake8.py"]:::pkg
        T3["test_pep257.py"]:::pkg

        PM --> Init
        Init --> Int
        Init --> HS
        Init --> HP
        PM --> Tests
        Tests --> T1
        Tests --> T2
        Tests --> T3
    end

    SDK["MCP Python SDK"]:::ext
    LLM["LLM Client"]:::ext

    TG -->|"rclpy API"| Int
    Int -->|"configuration payload"| HS
    HS -->|"SSE events (port 5000)"| LLM
    LLM -->|"HTTP POST commands"| HS
    HS -->|"imports"| SDK

    click P1 "https://github.com/snick-m/auto_mcp/blob/main/package.xml"
    click P2 "https://github.com/snick-m/auto_mcp/blob/main/setup.py"
    click P3 "https://github.com/snick-m/auto_mcp/blob/main/setup.cfg"
    click P4 "https://github.com/snick-m/auto_mcp/tree/main/resource/auto_mcp"
    click Init "https://github.com/snick-m/auto_mcp/blob/main/auto_mcp/__init__.py"
    click Int "https://github.com/snick-m/auto_mcp/blob/main/auto_mcp/introspect.py"
    click HS "https://github.com/snick-m/auto_mcp/blob/main/auto_mcp/fast_server.py"
    click HP "https://github.com/snick-m/auto_mcp/blob/main/auto_mcp/hello.py"
    click T1 "https://github.com/snick-m/auto_mcp/blob/main/test/test_copyright.py"
    click T2 "https://github.com/snick-m/auto_mcp/blob/main/test/test_flake8.py"
    click T3 "https://github.com/snick-m/auto_mcp/blob/main/test/test_pep257.py"

    classDef ros fill:#D0E8FF,stroke:#0366d6,color:#0366d6,stroke-width:1px;
    classDef pkg fill:#E6FFE6,stroke:#28A745,color:#22863A,stroke-width:1px;
    classDef ext fill:#FFF5D1,stroke:#DBAB09,color:#735C0F,stroke-width:1px;
```
