# MCP Server for Google Services
A Model Context Protocol (MCP) server that integrates Google services with Claude Desktop. Provides 80+ tools for Gmail, Calendar, Drive, Sheets, and Docs operations.
## Features
- **Gmail**: Search, read, send, reply, label, and organize emails
- **Google Calendar**: Create, update, delete events; find free slots
- **Google Drive**: Search, list, read files and folders
- **Google Sheets**: Read, write, append data; manage spreadsheets
- **Google Docs**: Create and read documents
- **Memory System**: Persistent storage for context and preferences
- **Database Support**: Optional PostgreSQL and MongoDB integration
## Project Structure
```
mcpwithgoogle/
├── src/
│ ├── mcp_server.py # Main MCP server (80+ tools)
│ ├── google_auth.py # OAuth authentication
│ ├── google_gmail.py # Gmail operations
│ ├── google_calendar.py # Calendar operations
│ ├── google_drive.py # Drive operations
│ ├── google_sheets.py # Sheets operations
│ ├── google_docs.py # Docs operations
│ ├── memory_system.py # Persistent memory
│ ├── local_storage.py # Local data storage
│ └── setup.py # OAuth setup script
├── config/
│ └── claude_desktop_config.json # Example Claude config
├── scripts/
│ └── setup_my_profile.py
├── config.example.json # Google OAuth config template
├── authenticate.py # Authentication script
├── requirements.txt
├── .env.example
└── README.md
```
## Prerequisites
- Python 3.8+
- Claude Desktop
- Google Cloud Project with APIs enabled:
- Gmail API
- Google Calendar API
- Google Drive API
- Google Sheets API
## Installation
### Step 1: Clone the Repository
```bash
git clone https://github.com/pbulbule13/mcpwithgoogle.git
cd mcpwithgoogle
```
### Step 2: Install Dependencies
```bash
pip install -r requirements.txt
```
### Step 3: Google Cloud Setup
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing
3. Enable the following APIs:
- Gmail API
- Google Calendar API
- Google Drive API
- Google Sheets API
4. Go to **Credentials** > **Create Credentials** > **OAuth 2.0 Client ID**
5. Select **Desktop app** as application type
6. Download the credentials and save as `credentials.json` in the project root
### Step 4: Configure
```bash
# Copy example config
cp config.example.json config.json
# Edit with your Google OAuth credentials
```
**config.json:**
```json
{
"google": {
"clientId": "YOUR_CLIENT_ID.apps.googleusercontent.com",
"clientSecret": "YOUR_CLIENT_SECRET",
"redirectUri": "http://localhost",
"calendarId": "primary"
}
}
```
### Step 5: Authenticate with Google
```bash
python authenticate.py
```
This opens a browser for Google OAuth. After authorization, tokens are saved locally.
### Step 6: Configure Claude Desktop
Edit your Claude Desktop configuration file:
| OS | Path |
|----|------|
| Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
| Linux | `~/.config/Claude/claude_desktop_config.json` |
Add:
```json
{
"mcpServers": {
"google-workspace": {
"command": "python",
"args": [
"C:\\path\\to\\mcpwithgoogle\\src\\mcp_server.py"
],
"env": {},
"cwd": "C:\\path\\to\\mcpwithgoogle"
}
}
}
```
**Important:** Replace `C:\\path\\to\\` with your actual absolute path.
### Step 7: Restart Claude Desktop
1. Completely quit Claude Desktop (check system tray)
2. Restart Claude Desktop
3. The tools will be automatically available
## Verify Installation
In Claude Desktop, type:
```
Show me available tools
```
You should see 80+ tools listed.
## Available Tools
### Email Tools
- `search_emails` - Search Gmail with queries
- `get_email` - Get email by ID
- `send_email` - Send new email
- `reply_to_email` - Reply to email
- `list_labels` - List Gmail labels
- `create_label` - Create new label
- `move_to_label` - Move email to label
### Calendar Tools
- `get_calendar_events` - List events
- `create_calendar_event` - Create event
- `update_calendar_event` - Update event
- `delete_calendar_event` - Delete event
- `find_free_slots` - Find available times
### Drive Tools
- `search_drive` - Search files
- `list_drive_files` - List files in folder
- `get_file_content` - Read file content
- `create_folder` - Create folder
### Sheets Tools
- `read_sheet` - Read spreadsheet data
- `write_sheet` - Write to spreadsheet
- `append_sheet` - Append rows
- `create_sheet` - Create new spreadsheet
### Docs Tools
- `create_doc` - Create document
- `read_doc` - Read document content
### Memory Tools
- `remember` - Store information
- `recall` - Retrieve information
- `forget` - Remove information
- `list_memories` - List all stored items
## Example Usage
In Claude Desktop:
```
"Show my unread emails from today"
"Schedule a meeting tomorrow at 2 PM with john@example.com"
"Find documents about 'project proposal' in my Drive"
"What meetings do I have this week?"
"Remember that my favorite color is blue"
```
## Troubleshooting
### MCP Server Not Appearing
1. Verify the path in `claude_desktop_config.json` is absolute and correct
2. Ensure Python is in your system PATH
3. Restart Claude Desktop completely
4. Check Claude Desktop logs for errors
### Authentication Errors
1. Delete `tokens.json` and re-run `python authenticate.py`
2. Verify `credentials.json` exists in project root
3. Check Google Cloud Console for API quota issues
### Import Errors
```bash
pip install --upgrade -r requirements.txt
```
## Security Notes
- Never commit `credentials.json`, `tokens.json`, or `config.json` to git
- The `.gitignore` file excludes sensitive files by default
- Store API keys in environment variables when possible
## License
MIT License