You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Common Commands
6
+
7
+
### Development
8
+
-`uv run main.py` - Start server in stdio mode (default for MCP clients)
9
+
-`uv run main.py --transport streamable-http` - Start server in HTTP mode for debugging
10
+
-`uv run main.py --single-user` - Run in single-user mode (bypass session mapping)
11
+
-`uv run main.py --tools gmail drive calendar` - Start with specific tools only
12
+
13
+
### Installation & Setup
14
+
-`python install_claude.py` - Auto-install MCP server configuration in Claude Desktop
15
+
-`uvx workspace-mcp` - Run directly via uvx without local installation
16
+
17
+
### Docker
18
+
-`docker build -t workspace-mcp .`
19
+
-`docker run -p 8000:8000 -v $(pwd):/app workspace-mcp --transport streamable-http`
20
+
21
+
## Architecture Overview
22
+
23
+
This is a comprehensive Google Workspace MCP server built with FastMCP. The architecture follows a modular design pattern:
24
+
25
+
### Core Components
26
+
-**`main.py`** - Entry point with argument parsing and tool module loading
27
+
-**`core/server.py`** - FastMCP server configuration with OAuth callback handling
28
+
-**`core/utils.py`** - Shared utilities and credential directory management
29
+
30
+
### Authentication System (`auth/`)
31
+
-**Service Decorator Pattern**: Uses `@require_google_service()` decorators for automatic authentication
32
+
-**OAuth 2.0 Flow**: Transport-aware callback handling (stdio mode starts minimal HTTP server on port 8000)
33
+
-**Service Caching**: 30-minute TTL to reduce authentication overhead
34
+
-**Session Management**: Maps OAuth state to MCP session IDs for multi-user support
35
+
-**Scope Management**: Centralized scope definitions in `auth/scopes.py` with predefined scope groups
36
+
37
+
### Service Modules
38
+
Each Google service has its own module in `g{service}/` format:
39
+
-`gcalendar/` - Google Calendar API integration
40
+
-`gdrive/` - Google Drive API with Office format support
41
+
-`gmail/` - Gmail API for email management
42
+
-`gdocs/` - Google Docs API operations with full editing support
43
+
-`gsheets/` - Google Sheets API with cell operations
44
+
-`gforms/` - Google Forms creation and response management
45
+
-`gchat/` - Google Chat/Spaces messaging
46
+
-`gslides/` - Google Slides presentation management
47
+
48
+
### Key Patterns
49
+
-**Service Injection**: The `@require_google_service(service_name, scope_group)` decorator automatically injects authenticated Google API service objects
50
+
-**Multi-Service Support**: Use `@require_multiple_services()` for tools needing multiple Google services
51
+
-**Error Handling**: Native Python exceptions are automatically converted to MCP errors
52
+
-**Transport Modes**: Supports both stdio (for MCP clients) and streamable-http (for debugging/web interfaces)
The `gdocs/docs_helpers.py` module provides utility functions for:
86
+
- Building text style objects
87
+
- Creating API request structures
88
+
- Validating batch operations
89
+
- Extracting document text
90
+
- Calculating text indices
91
+
92
+
These tools use the Google Docs API's batchUpdate method for efficient, atomic document modifications. All editing operations require the `docs_write` scope which is already configured in the authentication system.
returnf"❌ API Error: Drive image '{file_name}' access denied despite public sharing. May need propagation time or use insert_doc_image_url with: {get_drive_image_url(file_id)}"
0 commit comments