# markuspfundstein/mcp-gsuite architecture

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

- Interactive diagram: https://gitdiagram.com/markuspfundstein/mcp-gsuite
- Repository: https://github.com/markuspfundstein/mcp-gsuite

## Overview

##### Main Components

a) Client Layer:
- Claude Desktop AI Assistant
- MCP Inspector (for debugging)

b) MCP Server Core:
- Main server component (server.py)
- Authentication handler (gauth.py)
- Tool handlers (toolhandler.py)

c) Service-Specific Components:
- Gmail Module (gmail.py, tools_gmail.py)
- Calendar Module (calendar.py, tools_calendar.py)

d) External Services:
- Google OAuth 2.0
- Gmail API
- Google Calendar API

##### Specific Implementation Details

Use these visual elements:

a) Components:
- Rectangles for main services
- Rounded rectangles for APIs
- Hexagons for tool handlers

- Blue: Core MCP components
- Green: Google services
- Yellow: Authentication components
- Gray: Storage/Configuration files

##### Key Relationships to Highlight

- Bidirectional communication between Claude and MCP server
- How toolhandler.py orchestrates different tools
- Demonstrate the authentication flow from client through OAuth2 to Google services
- How multiple Google accounts are managed

##### Configuration Elements

Critical config components:
- .gauth.json location and purpose
- .accounts.json management
- Credential storage structure
- API specifications (reference the OpenAPI specs)

##### Configuration management

This system design should clearly show how the MCP server acts as a bridge between Claude Desktop and Google services while handling authentication, multiple accounts, and various API operations for both Gmail and Calendar services.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Claude["Claude Desktop AI Assistant"]
        Inspector["MCP Inspector"]
    end

    subgraph MCP_Server["MCP Server Layer"]
        Server["MCP Server Core"]:::core
        Auth["Authentication Handler"]:::auth
        ToolHandler["Tool Handler"]:::core
        click Server "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/server.py"
        click Auth "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/gauth.py"
        click ToolHandler "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/toolhandler.py"
    end

    subgraph Service_Modules["Service Modules"]
        Gmail["Gmail Module"]:::service
        GmailTools["Gmail Tools"]:::tools
        Calendar["Calendar Module"]:::service
        CalendarTools["Calendar Tools"]:::tools
        click Gmail "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/gmail.py"
        click GmailTools "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/tools_gmail.py"
        click Calendar "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/calendar.py"
        click CalendarTools "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/src/mcp_gsuite/tools_calendar.py"
    end

    subgraph Config["Configuration"]
        GAuthConfig[".gauth.json"]:::config
        AccountsConfig[".accounts.json"]:::config
        OAuthCreds[".oauth.{email}.json"]:::config
        APISpecs["API Specifications"]:::config
        click APISpecs "https://github.com/MarkusPfundstein/mcp-gsuite/blob/main/gmail-api-openapi-spec.yaml"
    end

    subgraph Google_Services["Google Services"]
        OAuth["Google OAuth 2.0"]:::google
        GmailAPI["Gmail API"]:::google
        CalendarAPI["Calendar API"]:::google
    end

    %% Connections
    Claude --> Server
    Inspector --> Server
    Server --> Auth
    Server --> ToolHandler
    Auth --> OAuth
    ToolHandler --> Gmail
    ToolHandler --> Calendar
    Gmail --> GmailTools
    Calendar --> CalendarTools
    GmailTools --> GmailAPI
    CalendarTools --> CalendarAPI
    Auth --> GAuthConfig
    Auth --> AccountsConfig
    Auth --> OAuthCreds
    Gmail --> APISpecs
    Calendar --> APISpecs

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef auth fill:#FFC107,stroke:#FFA000,color:black
    classDef service fill:#4CAF50,stroke:#388E3C,color:white
    classDef tools fill:#81C784,stroke:#388E3C,color:black
    classDef config fill:#9E9E9E,stroke:#616161,color:white
    classDef google fill:#FF5722,stroke:#E64A19,color:white

    %% Legend
    subgraph Legend
        CoreL["Core Components"]:::core
        AuthL["Authentication Components"]:::auth
        ServiceL["Service Modules"]:::service
        ToolsL["Tool Components"]:::tools
        ConfigL["Configuration"]:::config
        GoogleL["Google Services"]:::google
    end
```
