Enables sending emails with attachments, fetching and filtering emails, and analyzing email patterns for comprehensive email management and automation
Comprehensive Google Workspace integration providing 84 specialized tools covering Gmail, Calendar, Drive, and other Google services with centralized OAuth authentication
Provides file upload, search, and document management capabilities for organizing and accessing files stored in Google Drive
Offers data processing capabilities for Google Sheets as part of the comprehensive Google Workspace automation suite
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Google Workspace MCP Serverschedule a team meeting for tomorrow at 2pm"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Google Workspace MCP Service
A production-ready Google Workspace MCP service providing 84 specialized tools for comprehensive Google Workspace automation. Designed to run as a persistent background service integrating with Rube MCP for centralized OAuth authentication.
๐ Features
84 Custom Tools: Complete Google Workspace API coverage (83 tools + 1 auth via Composio)
MCP Service: Persistent background service with PM2 process management
Centralized Auth: OAuth handled by Composio/Rube (no client secrets on desktops)
TypeScript: Full type safety with modern ES2022 features
ES Modules: Native ES module support throughout
Auto-startup: Configurable boot-time service activation
Health Monitoring: Built-in health endpoints for service monitoring
PKCE Compliant: Solves security compliance for remote workforce
Related MCP server: MCP G Suite Integration
๐ Prerequisites
Node.js 18+ with npm
Anthropic API Key (optional, for AI features)
Google Workspace account for testing
๐ ๏ธ Quick Start
1. Installation
# Clone or download the project
git clone <repository-url>
cd composio-google-workspace
# Install dependencies
npm install2. Environment Setup
# Copy environment template
cp .env.example .env
# Edit .env with your API keys
COMPOSIO_API_KEY=your_composio_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here3. Development
# Run in development mode
npm run dev
# Or build and run
npm run build
npm start๐๏ธ Project Structure
src/
โโโ agents/ # AI agent implementations
โ โโโ google-workspace-agent.ts
โโโ tools/ # Custom tool definitions
โ โโโ custom-tools.ts
โโโ composio-client.ts # Composio SDK initialization
โโโ index.ts # Main application entry๐ค Google Workspace Agent
The GoogleWorkspaceAgent class provides high-level methods for common workspace tasks:
import { GoogleWorkspaceAgent } from './src/agents/google-workspace-agent.js'
const agent = new GoogleWorkspaceAgent('user-123')
await agent.initialize(['gmail', 'googlecalendar'])
// Send emails
await agent.sendEmail('colleague@company.com', 'Project Update', 'Here is the status...')
// Create calendar events
await agent.createCalendarEvent({
title: 'Team Standup',
start: '2024-01-15T09:00:00Z',
end: '2024-01-15T09:30:00Z',
attendees: ['team@company.com']
})
// Complex workflows
await agent.scheduleMeetingWithInvites({
title: 'Q1 Planning',
start: '2024-01-20T14:00:00Z',
end: '2024-01-20T15:00:00Z',
attendees: ['stakeholder1@company.com', 'stakeholder2@company.com'],
agenda: 'Q1 objectives and resource allocation'
})๐ง Custom Tools
Create specialized tools for your workspace needs:
import { initializeCustomTools } from './src/tools/custom-tools.js'
// Initialize all custom tools
const tools = await initializeCustomTools()
// Available custom tools:
// - EMAIL_ANALYTICS: Analyze email patterns
// - MEETING_OPTIMIZER: Find optimal meeting times
// - DOCUMENT_INTELLIGENCE: Extract insights from documents
// - WORKSPACE_WORKFLOW: Automate cross-app workflows๐ Authentication Flow
Option 1: Interactive Setup
import { setupAuthentication, waitForAuthentication } from './src/composio-client.js'
// Setup Gmail authentication
const connectionRequest = await setupAuthentication('user-123', 'gmail')
console.log('Visit this URL:', connectionRequest.redirectUrl)
// Wait for user to complete OAuth flow
const connectedAccount = await waitForAuthentication(connectionRequest.id)
console.log('Gmail connected:', connectedAccount.id)Option 2: Pre-configured Connections
Configure connections via the Composio Dashboard and reference them by ID.
๐ Available Scripts
# Development
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm start # Run built application
# Code Quality
npm run typecheck # TypeScript type checking
npm run lint # ESLint code linting
npm run lint:fix # Fix ESLint issues automatically
npm run format # Format code with Prettier
npm run format:check # Check code formatting๐ Integration Examples
Gmail Integration
// Fetch recent emails
const emails = await agent.getRecentEmails(10, 'is:unread')
// Send email with attachments
await agent.sendEmail('client@company.com', 'Proposal', 'Please find attached...', {
attachments: ['path/to/proposal.pdf']
})Calendar Integration
// Get upcoming events
const events = await agent.getUpcomingEvents(5)
// Create recurring meeting
await agent.createCalendarEvent({
title: 'Weekly Sync',
start: '2024-01-15T10:00:00Z',
end: '2024-01-15T10:30:00Z',
recurrence: ['RRULE:FREQ=WEEKLY;BYDAY=MO']
})Google Drive Integration
// Upload documents
await agent.uploadToDrive('report.md', reportContent)
// Search files
const files = await agent.searchDriveFiles('type:document modified:2024')๐ Advanced Workflows
Daily Summary Generation
// Generate comprehensive daily summary
const summary = await agent.generateDailySummary('2024-01-15')
console.log(summary)
// Includes email activity, calendar events, and insightsMeeting Orchestration
// Complete meeting workflow: schedule + invites + follow-up
await agent.scheduleMeetingWithInvites({
title: 'Product Review',
start: '2024-01-20T15:00:00Z',
end: '2024-01-20T16:00:00Z',
attendees: ['product@company.com', 'engineering@company.com'],
agenda: 'Q1 product roadmap review and prioritization',
location: 'Conference Room A'
})๐ก๏ธ Error Handling
The project includes comprehensive error handling:
try {
await agent.sendEmail('invalid-email', 'Test', 'Body')
} catch (error) {
console.error('Email failed:', error.message)
// Handle specific error cases
}๐ API Reference
Composio Client
initializeComposio()- Initialize SDK connectiongetAvailableTools(toolkits, userId)- List available toolssetupAuthentication(userId, toolkit)- Start OAuth flowwaitForAuthentication(requestId)- Wait for auth completionexecuteTool(toolSlug, userId, arguments)- Execute any tool
Google Workspace Agent
initialize(services)- Setup agent with required servicessendEmail()- Send emails with attachmentsgetRecentEmails()- Fetch and filter emailscreateCalendarEvent()- Create calendar eventsgetUpcomingEvents()- List upcoming eventsuploadToDrive()- Upload files to DrivesearchDriveFiles()- Search Drive contentgenerateDailySummary()- Generate daily activity summary
๐ง Configuration
TypeScript Configuration
The project uses modern TypeScript settings in tsconfig.json:
Target: ES2022
Module: ESNext
Strict mode enabled
Path aliases supported (
@/โsrc/)
Vite Configuration
Optimized for Node.js development:
ES modules output
Source maps enabled
Proper external handling
Path alias resolution
Code Quality
ESLint: TypeScript-aware linting with recommended rules
Prettier: Consistent code formatting
Pre-commit hooks: Automated formatting and linting
๐ค Contributing
Fork the repository
Create a feature branch:
git checkout -b feature/amazing-featureMake your changes and add tests
Run quality checks:
npm run lint && npm run typecheckCommit your changes:
git commit -m 'Add amazing feature'Push to the branch:
git push origin feature/amazing-featureOpen a Pull Request
๐ License
This project is licensed under the ISC License. See the LICENSE file for details.
๐ Troubleshooting
Common Issues
Authentication Errors
# Verify API keys are set
npm run dev
# Check console for authentication statusTypeScript Errors
# Run type checking
npm run typecheck
# Check for missing dependencies
npm installBuild Issues
# Clear cache and rebuild
rm -rf dist node_modules
npm install
npm run buildGetting Help
๐ฎ What's Next?
Add Anthropic Claude integration for AI-powered email responses
Implement workflow scheduling and automation
Add support for Google Sheets data processing
Create dashboard for monitoring agent activities
Add unit tests and CI/CD pipeline
Built with โค๏ธ using Composio.dev - The platform for AI agents to take actions in the real world.