ripolissimogit/google-workspace-mcp-server
If you are the rightful owner of google-workspace-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This document provides a comprehensive overview of a custom MCP server designed for integration with Google Workspace, compatible with Smithery.
Google Workspace MCP Server v2.0.0
Enterprise-grade Model Context Protocol (MCP) server for seamless Google Workspace integration with advanced features including connection pooling, intelligent retry logic, comprehensive logging, and multi-transport support.
Features
š Core Capabilities
- Document Management: Create, search, and manage Google Docs with advanced content handling
- Email Operations: Read and search Gmail messages with intelligent filtering
- Calendar Integration: List and analyze calendar events with comprehensive statistics
- Drive Operations: Advanced file search with content analysis and metadata extraction
- Health Monitoring: Built-in health checks and performance metrics
šļø Enterprise Architecture
- Multi-Transport Support: Both STDIO and HTTP/SSE transports
- Connection Pooling: Optimized HTTP agent with keep-alive
- Intelligent Retry Logic: Exponential backoff with circuit breaker pattern
- Comprehensive Logging: Structured logging with Winston
- Configuration Management: Zod-based validation and environment handling
- Caching System: JWT client caching with automatic refresh
š Security & Performance
- Domain-Wide Delegation: Service account impersonation for admin operations
- Input Validation: Comprehensive schema validation for all operations
- Error Handling: Graceful error handling with detailed logging
- Resource Management: Automatic cleanup and connection management
- Production Ready: Docker support with security hardening
Quick Start
Prerequisites
- Node.js 18+
- Google Workspace domain with admin access
- Service account with Domain-wide Delegation configured
Installation
- Clone and install dependencies:
git clone https://github.com/ripolissimogit/google-workspace-mcp-server
cd google-workspace-mcp-server
npm install
- Configure environment:
cp .env.example .env
# Edit .env with your Google Service Account credentials
- Run the server:
# Development mode
npm run dev
# Production mode
npm run build
npm start
# HTTP transport mode
MCP_TRANSPORT=http PORT=3000 npm start
Configuration
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
SERVICE_ACCOUNT_KEY | ā | - | Google Service Account JSON key |
DOMAIN_ADMIN | ā | - | Domain admin email for impersonation |
MCP_TRANSPORT | ā | stdio | Transport type (stdio or http) |
PORT | ā | 3000 | HTTP server port |
LOG_LEVEL | ā | info | Logging level |
MAX_RETRIES | ā | 3 | API retry attempts |
TIMEOUT | ā | 30000 | Request timeout (ms) |
MAX_SOCKETS | ā | 10 | Connection pool size |
Google Workspace Setup
-
Create Service Account:
- Go to Google Cloud Console ā IAM & Admin ā Service Accounts
- Create new service account with Drive, Docs, Gmail, Calendar APIs enabled
- Download JSON key file
-
Enable Domain-Wide Delegation:
- In Service Account settings, enable Domain-wide Delegation
- Note the Client ID
-
Configure Admin Console:
- Go to Google Admin Console ā Security ā API Controls
- Add OAuth App with Client ID and required scopes:
https://www.googleapis.com/auth/drivehttps://www.googleapis.com/auth/documentshttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/calendar
Available Tools
š create_document
Create Google Documents with content and sharing options.
Parameters:
title(required): Document titlecontent(optional): Initial contentparentFolderId(optional): Parent folder IDshare(optional): Sharing configuration
Example:
{
"title": "Project Report",
"content": "This is the project report content...",
"share": {
"users": ["user@domain.com"],
"permissions": "edit"
}
}
š search_files
Search Google Drive files with advanced filtering.
Parameters:
query(required): Search querytype(optional): File type filterlimit(optional): Result limit (default: 20)includeContent(optional): Include file content (default: false)
š§ read_emails
Read Gmail messages with intelligent filtering.
Parameters:
query(optional): Gmail search querymaxResults(optional): Result limit (default: 10)labelIds(optional): Label filters (default: ["INBOX"])includeSpamTrash(optional): Include spam/trash (default: false)
š
list_calendar_events
List calendar events with comprehensive analysis.
Parameters:
calendarId(optional): Calendar ID (default: "primary")timeMin(optional): Start time (ISO 8601)timeMax(optional): End time (ISO 8601)maxResults(optional): Result limit (default: 50)
š„ health_check
Comprehensive server health monitoring.
Parameters:
includeApiTests(optional): Test API connectivity (default: true)detailed(optional): Include detailed diagnostics (default: false)
Deployment
Docker Deployment
# Build image
docker build -t google-workspace-mcp .
# Run container
docker run -e SERVICE_ACCOUNT_KEY="$(cat service-account.json)" \
-e DOMAIN_ADMIN="admin@yourdomain.com" \
google-workspace-mcp
Smithery Platform
# Deploy to Smithery
smithery deploy
# Configure with your credentials in the Smithery dashboard
Development
Project Structure
src/
āāā auth/ # Google authentication & caching
āāā config/ # Configuration management
āāā server/ # MCP server implementation
āāā tools/ # Google Workspace tools
ā āāā google-drive/ # Drive operations
ā āāā gmail/ # Gmail operations
ā āāā calendar/ # Calendar operations
ā āāā system/ # Health checks
āāā utils/ # Logging & retry utilities
Scripts
npm run dev # Development with auto-reload
npm run build # Production build
npm run lint # ESLint checks
npm run test # Run tests
npm run type-check # TypeScript validation
API Reference
Health Endpoints (HTTP Transport)
GET /health- Server health statusGET /metrics- Performance metricsGET /api/info- API informationGET /sse- MCP SSE endpoint
Resources (MCP Protocol)
server://status- Current server statusserver://metrics- Usage metricsserver://config- Configuration info
Troubleshooting
Common Issues
Authentication Errors:
- Verify service account JSON key format
- Check Domain-wide Delegation is enabled
- Ensure admin email has proper permissions
- Verify OAuth scopes in Admin Console
API Rate Limits:
- Server implements exponential backoff automatically
- Adjust
MAX_RETRIESandTIMEOUTas needed - Monitor
/metricsendpoint for rate limit info
Connection Issues:
- Check
MAX_SOCKETSconfiguration - Verify network connectivity to Google APIs
- Review server logs for detailed error info
Debug Mode
LOG_LEVEL=debug npm run dev
Contributing
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push branch:
git push origin feature/amazing-feature - Open Pull Request
License
MIT License - see file for details.
Support
- š Documentation
- š Issue Tracker
- š¬ Discussions
Made with ā¤ļø using Claude Code