# piotr-agier/google-drive-mcp architecture

> Architecture diagram of the GitHub repository piotr-agier/google-drive-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/piotr-agier/google-drive-mcp
- Repository: https://github.com/piotr-agier/google-drive-mcp

## Overview

Google Drive MCP Server exposes Drive, Docs, Sheets, Slides, Calendar, and account-management operations to MCP clients. The principal flow is a client request entering the MCP server, being dispatched to a Workspace tool, and reaching Google APIs; authentication supplies the identity and credentials used for calls. The README documents local OAuth, service accounts, external tokens, team mode, and an optional resource interface. Some subsystem links rely on the SOURCE INDEX or README rather than inspected implementation excerpts.

Main entry points: [`src/index.ts`](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/index.ts) (MCP server), [`src/auth.ts`](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth.ts) (Auth orchestration), [`src/auth/team/runtime.ts`](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/runtime.ts) (Team runtime), [`src/tools/drive.ts`](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/drive.ts) (Drive operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["MCP runtime"]
  node_server["MCP server<br/>[index.ts]"]
  node_resources["Drive resources<br/>[index.ts]"]
end

subgraph group_workspace["Workspace tools"]
  node_drive["Drive operations<br/>[drive.ts]"]
  node_docs["Docs editing<br/>[docs.ts]"]
  node_sheets["Sheets operations<br/>[sheets.ts]"]
  node_slides["Slides authoring<br/>[slides.ts]"]
  node_calendar["Calendar events<br/>[calendar.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Auth orchestration<br/>[auth.ts]"]
  node_oauth["Local OAuth flow<br/>[server.ts]"]
  node_accounts["Account resolution<br/>[accountResolver.ts]"]
  node_account_store[("Account storage<br/>[accountStore.ts]")]
  node_account_clients["Account clients"]
end

subgraph group_team["Team authentication"]
  node_team_runtime["Team runtime<br/>[runtime.ts]"]
  node_team_provider["Team identity provider<br/>[provider.ts]"]
  node_team_config["Team configuration<br/>[config.ts]"]
  node_team_store[("Team token store<br/>[fileStore.ts]")]
end

node_client(("MCP client"))
node_google["Google APIs"]

node_client -->|"sends requests"| node_server
node_server -->|"dispatches tools"| node_drive
node_server -->|"dispatches tools"| node_docs
node_server -->|"dispatches tools"| node_sheets
node_server -->|"dispatches tools"| node_slides
node_server -->|"dispatches tools"| node_calendar
node_server -->|"initializes identity"| node_auth
node_server -->|"offers interface"| node_resources
node_drive -->|"calls APIs"| node_google
node_docs -->|"calls APIs"| node_google
node_sheets -.->|"calls APIs"| node_google
node_slides -.->|"calls APIs"| node_google
node_calendar -.->|"calls APIs"| node_google
node_auth -->|"uses OAuth flow"| node_oauth
node_auth -->|"resolves accounts"| node_accounts
node_auth -->|"loads accounts"| node_account_store
node_auth -->|"creates clients"| node_account_clients
node_server -->|"configures team mode"| node_team_runtime
node_team_runtime -->|"loads settings"| node_team_config
node_team_runtime -->|"uses provider"| node_team_provider
node_team_runtime -->|"uses token store"| node_team_store

click node_server "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/index.ts"
click node_resources "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/index.ts"
click node_drive "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/drive.ts"
click node_docs "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/docs.ts"
click node_sheets "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/sheets.ts"
click node_slides "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/slides.ts"
click node_calendar "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/calendar.ts"
click node_auth "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth.ts"
click node_oauth "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/server.ts"
click node_accounts "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/accountResolver.ts"
click node_account_store "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/accountStore.ts"
click node_account_clients "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/accountClientFactory.ts"
click node_team_runtime "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/runtime.ts"
click node_team_provider "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/provider.ts"
click node_team_config "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/config.ts"
click node_team_store "https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/fileStore.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_resources,node_client toneBlue
class node_drive,node_docs,node_sheets,node_slides,node_calendar toneAmber
class node_auth,node_oauth,node_accounts,node_account_store,node_account_clients,node_google toneMint
class node_team_runtime,node_team_provider,node_team_config,node_team_store toneRose
```

## Components

### MCP runtime

- [MCP server](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/index.ts): `src/index.ts`
- [Drive resources](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/index.ts): `src/index.ts`

### Workspace tools

- [Drive operations](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/drive.ts): `src/tools/drive.ts`
- [Docs editing](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/docs.ts): `src/tools/docs.ts`
- [Sheets operations](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/sheets.ts): `src/tools/sheets.ts`
- [Slides authoring](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/slides.ts): `src/tools/slides.ts`
- [Calendar events](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/tools/calendar.ts): `src/tools/calendar.ts`

### Identity and access

- [Auth orchestration](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth.ts): `src/auth.ts`
- [Local OAuth flow](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/server.ts): `src/auth/server.ts`
- [Account resolution](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/accountResolver.ts): `src/auth/accountResolver.ts`
- [Account storage](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/accountStore.ts): `src/auth/accountStore.ts`
- [Account clients](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/accountClientFactory.ts): `src/auth/accountClientFactory.ts`

### Team authentication

- [Team runtime](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/runtime.ts): `src/auth/team/runtime.ts`
- [Team identity provider](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/provider.ts): `src/auth/team/provider.ts`
- [Team configuration](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/config.ts): `src/auth/team/config.ts`
- [Team token store](https://github.com/piotr-agier/google-drive-mcp/blob/master/src/auth/team/fileStore.ts): `src/auth/team/fileStore.ts`

### Other components

- **MCP client**
- **Google APIs**

## Connections

- MCP client → MCP server: sends requests (evidence: `README.md`)
- MCP server → Drive operations: dispatches tools (evidence: `src/index.ts`)
- MCP server → Docs editing: dispatches tools (evidence: `src/index.ts`)
- MCP server → Sheets operations: dispatches tools (evidence: `src/index.ts`)
- MCP server → Slides authoring: dispatches tools (evidence: `src/index.ts`)
- MCP server → Calendar events: dispatches tools (evidence: `src/index.ts`)
- MCP server → Auth orchestration: initializes identity (evidence: `src/index.ts`)
- MCP server → Drive resources: offers interface (evidence: `README.md`)
- Drive operations → Google APIs: calls APIs (evidence: `src/tools/drive.ts`)
- Docs editing → Google APIs: calls APIs (evidence: `src/tools/docs.ts`)
- Sheets operations → Google APIs: calls APIs
- Slides authoring → Google APIs: calls APIs
- Calendar events → Google APIs: calls APIs
- Auth orchestration → Local OAuth flow: uses OAuth flow (evidence: `src/auth.ts`)
- Auth orchestration → Account resolution: resolves accounts (evidence: `src/auth.ts`)
- Auth orchestration → Account storage: loads accounts (evidence: `src/auth.ts`)
- Auth orchestration → Account clients: creates clients (evidence: `src/auth.ts`)
- MCP server → Team runtime: configures team mode (evidence: `src/index.ts`)
- Team runtime → Team configuration: loads settings (evidence: `src/auth/team/runtime.ts`)
- Team runtime → Team identity provider: uses provider (evidence: `src/auth/team/runtime.ts`)
- Team runtime → Team token store: uses token store (evidence: `src/auth/team/runtime.ts`)
