Google Workspace MCP Server
Provides 84 specialized tools for comprehensive Google Workspace automation including Gmail, Calendar, and Drive operations. Features persistent background service with centralized OAuth authentication through Composio for secure enterprise integration.
README
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
📋 Prerequisites
- Node.js 18+ with npm
- Composio API Key
- 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 install
2. 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_here
3. 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 insights
Meeting 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-feature - Make your changes and add tests
- Run quality checks:
npm run lint && npm run typecheck - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open 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 status
TypeScript Errors
# Run type checking
npm run typecheck
# Check for missing dependencies
npm install
Build Issues
# Clear cache and rebuild
rm -rf dist node_modules
npm install
npm run build
Getting 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。