# assafelovic/gptr-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/assafelovic/gptr-mcp
- Repository: https://github.com/assafelovic/gptr-mcp

## Overview

##### Project Overview & Type
- This project is a specialized server application that supports “deep research” for LLM-powered applications.
- It functions as a monolithic MCP (Model Context Protocol) server that integrates with external tools such as Claude and search/research APIs. It’s built with Python and containerized using Docker.
- Key functionality includes deep research, quick search, and report generation, all of which are accessible via API endpoints exposed by the server.

##### Analyzing the File Structure
- Top-Level Files & Directories:
- “server.py”: The main entry point of the MCP server.
- “run.sh”: A script likely used to start the server.
- “utils.py”: Contains helper functions or shared business logic.
- “tests/”: Contains unit tests (e.g., test_server.py) – representing the testing components.
- “.env.example”: Represents the configuration template for external API keys and settings.
- “Dockerfile” and “docker-compose.yml”: Indicate containerization and deployment scripts, highlighting how the server may be run within Docker.
- Other config files like “requirements.txt”, “LICENSE”, and “__init__.py” further support a clean, managed, and deployable project.

##### Extracting Architectural Insights from the README
- The README describes the server’s role in delivering high-quality research data via several primary tools (deep_research, quick_search, write_report, and access functions for research sources and contexts).
- It outlines integration with external services and protocols (e.g., OpenAI API, Tavily API) and provides instructions for Claude Desktop integration.
- It also provides usage examples that illustrate how the MCP server handles research inquiries, with a focus on asynchronous processing (noting a ~30–40 second response time).

##### Mapping Out the Main Components
a. Server Component:
- Represents the core of the MCP server (server.py) that handles incoming research requests, processes them, and returns results.
- “utils.py” as a supporting library within the server.
- Configuration input (from .env) which holds API keys and environment setups.
b. External Dependencies/Services:
- API providers: OpenAI for LLM interactions, Tavily (or any other supported retriever) for search operations.
c. Containerization & Deployment:
- Optionally, include “run.sh” as a helper script to bootstrap the server.
d. Testing Layer:
- Tests directory (tests/test_server.py) represents the automated testing component for ensuring server reliability.

##### Architectural Patterns & Design Principles
- Monolithic Design: The project follows a single-process service model with separate concerns (API handling, business logic, and configuration). Even though it is monolithic, its containerized setup (Docker, docker-compose) allows smooth deployment.
- Configuration Management: Externalizing configuration via the .env file ensures that API keys and external URLs are managed securely.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client/Claude Desktop"]:::external
    B["MCP Server (server.py)"]:::core
    C["Business Logic (utils.py)"]:::core
    D["Configuration (.env)"]:::core

    subgraph "External Services/APIs"
        E1["OpenAI API"]:::external
        E2["Tavily API"]:::external
        E3["Other Search Engines"]:::external
    end

    subgraph "Containerization & Deployment"
        F1["Dockerfile"]:::container
        F2["docker-compose.yml"]:::container
        F3["run.sh"]:::container
        F4["Docker Container"]:::container
    end

    G["Testing (tests/test_server.py)"]:::test

    A -->|"sends_request"| B
    B -->|"uses_business_logic"| C
    B -->|"reads_configuration"| D
    B -->|"calls"| E1
    B -->|"calls"| E2
    B -->|"calls"| E3
    F4 -->|"encapsulates"| B
    B -->|"tested_by"| G

    click B "https://github.com/assafelovic/gptr-mcp/blob/master/server.py"
    click C "https://github.com/assafelovic/gptr-mcp/blob/master/utils.py"
    click D "https://github.com/assafelovic/gptr-mcp/blob/master/.env.example"
    click F1 "https://github.com/assafelovic/gptr-mcp/tree/master/Dockerfile"
    click F2 "https://github.com/assafelovic/gptr-mcp/blob/master/docker-compose.yml"
    click F3 "https://github.com/assafelovic/gptr-mcp/blob/master/run.sh"
    click G "https://github.com/assafelovic/gptr-mcp/blob/master/tests/test_server.py"

    classDef core fill:#B3CDE0,stroke:#000,stroke-width:1px;
    classDef external fill:#CDEBBC,stroke:#000,stroke-width:1px;
    classDef container fill:#FDD7E4,stroke:#000,stroke-width:1px;
    classDef test fill:#FEE3D2,stroke:#000,stroke-width:1px;
```
