This guide covers common issues and their solutions. If you don't find your issue here, please open an issue on GitHub.
- Authentication Issues
- Server Startup Issues
- Email Operation Issues
- Claude Desktop Integration
- Performance Issues
- Advanced Debugging
Cause: Your app is in "Testing" mode and you haven't added yourself as a test user.
Solution:
- Go to Google Cloud Console - OAuth Consent Screen
- Scroll to the "Test users" section
- Click "ADD USERS"
- Enter your Gmail address (the one you want to use with this server)
- Click "Save"
- Run authentication again:
node dist/index.js auth --force
Why this happens: Google restricts "Testing" apps to only allow specific users. You must explicitly add yourself.
Cause: The OAuth redirect URI in your credentials doesn't match what the server expects.
Solution:
- Go to Google Cloud Console - Credentials
- Click on your OAuth 2.0 Client ID
- Under "Authorized redirect URIs", ensure you have:
http://localhost:3000/oauth2callback - If it's missing or different, add/fix it
- Click "Save"
- Download the updated JSON credentials
- Replace your
gcp-oauth.keys.jsonfile - Run authentication again:
node dist/index.js auth --force
Cause: Your stored credentials are no longer valid (token expired, revoked, or corrupted).
Solution:
# Force re-authentication (clears old credentials)
node dist/index.js auth --forceThis will:
- Remove existing credentials
- Open browser for fresh authentication
- Save new, valid credentials
Cause: Credentials worked before but stopped working. Could be:
- Token naturally expired (should auto-refresh, but didn't)
- You revoked access in Google Account settings
- OAuth client was deleted/modified in Google Cloud
Solutions:
-
Try auto-refresh first (restart the server):
# Restart Claude Desktop or re-run the server node dist/index.js -
If that doesn't work, re-authenticate:
node dist/index.js auth --force
-
If still failing, check Google Cloud Console:
- Ensure OAuth client still exists
- Verify scopes haven't changed
- Check if API is still enabled
Cause: Another process is using port 3000 (needed for OAuth callback).
Solution:
macOS/Linux:
# Find and kill the process using port 3000
lsof -ti:3000 | xargs kill -9Windows:
# Find the process
netstat -ano | findstr :3000
# Kill it (replace PID with actual process ID)
taskkill /PID <PID> /FThen retry authentication.
Cause: OAuth consent screen is missing required information.
Solution:
- Go to OAuth Consent Screen
- Ensure these fields are filled:
- App name: Gmail MCP Server
- User support email: Your email
- Developer contact email: Your email
- Privacy Policy URL: (can use
https://policies.google.com/privacyas placeholder) - Terms of Service URL: Optional
- Click "Save and Continue"
- Add scopes (if not already added):
https://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.settings.basic
- Add yourself as a test user
- Retry authentication
Cause: Issue with the open package or system default browser.
Solution:
-
Manual approach:
- Look for a URL in the terminal output (starts with
https://accounts.google.com/o/oauth2/v2/auth...) - Copy and paste it into your browser manually
- Complete authentication
- The callback should work normally
- Look for a URL in the terminal output (starts with
-
Check default browser:
# macOS open https://google.com # Should open default browser # Linux xdg-open https://google.com # Windows start https://google.com
Cause: Dependencies not installed or corrupted.
Solution:
# Clean install
rm -rf node_modules package-lock.json
npm install
npm run buildCause: OAuth credentials file is missing or in wrong location.
Solution:
-
Check expected locations (in order of priority):
./gcp-oauth.keys.json(project root)~/.gmail-mcp/gcp-oauth.keys.json(home directory)
-
Verify file name (must be exact):
- ✅
gcp-oauth.keys.json - ❌
credentials.json - ❌
client_secret.json - ❌
gcp_oauth.keys.json
- ✅
-
Download from Google Cloud Console:
- Go to Credentials
- Click your OAuth 2.0 Client ID
- Click "Download JSON"
- Rename to
gcp-oauth.keys.json - Place in project root
Cause: File permission issues on credential storage.
Solution:
# Fix permissions
chmod 600 ~/.gmail-mcp/credentials.json
chmod 700 ~/.gmail-mcp/Cause: Configuration issue in Claude Desktop.
Solution:
-
Verify config path:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Check config format:
{ "mcpServers": { "gmail": { "command": "node", "args": ["/ABSOLUTE/PATH/TO/gmail-mcp-server/dist/index.js"] } } } -
Common mistakes:
- ❌ Relative path:
"./dist/index.js" - ❌ Wrong slashes on Windows:
"C:\Users\..."→ use"C:\\Users\\..." - ✅ Absolute path:
"/Users/username/projects/gmail-mcp-server/dist/index.js"
- ❌ Relative path:
-
Restart Claude Desktop completely:
- Quit application (not just close window)
- Reopen
Possible Causes & Solutions:
-
File doesn't exist:
# Verify file exists ls -lh /path/to/attachment.pdf -
File too large (Gmail limit: 25MB):
# Check file size ls -lh /path/to/attachment.pdf # If over 25MB, compress or use Google Drive link instead
-
Permission denied:
# Fix permissions chmod 644 /path/to/attachment.pdf -
Path issue:
- ✅ Absolute path:
/Users/username/Documents/file.pdf - ❌ Relative path:
./file.pdfor~/Documents/file.pdf - Use full, absolute paths
- ✅ Absolute path:
Debugging steps:
-
Check if it's in Drafts:
- You may have used
draft_emailinstead ofsend_email
- You may have used
-
Verify authentication:
# Test credentials node dist/index.js auth -
Check Gmail quota:
- Gmail limits: 500 emails/day for free accounts
- Check Google Account Activity
-
Look for validation errors:
- Invalid email addresses
- Empty subject or body
- Malformed HTML
Causes & Solutions:
-
Query syntax issue:
// ❌ Wrong { "query": "from:user@example.com AND subject:test" } // ✅ Correct (no "AND") { "query": "from:user@example.com subject:test" }
-
Date format:
// ✅ Correct formats "after:2024/11/01" "after:2024-11-01" "after:11/01/2024" // ❌ Wrong "after:Nov 1, 2024"
-
Case sensitivity:
- Gmail search is mostly case-insensitive
- But use exact case for email addresses:
from:User@Example.com
Expected behavior: Batch operations continue even if individual emails fail.
Check the response:
{
"success": true,
"totalProcessed": 10,
"successful": 8,
"failed": 2,
"results": [
{ "messageId": "id1", "success": true },
{ "messageId": "id2", "success": false, "error": "Message not found" },
// ...
]
}Common reasons for individual failures:
- Message already deleted
- Invalid message ID
- Message in different account
- Rate limit hit mid-batch
Possible Issues:
-
Label already exists:
# List existing labels first # Use list_email_labels tool
-
Invalid name:
- ❌ Empty name
- ❌ Name with leading/trailing spaces
- ✅ Use regular characters, spaces in middle are OK
-
Quota limit:
- Gmail limit: ~500 labels per account
- Delete unused labels first
Cause: MCP server not properly connected.
Solution:
-
Check Claude Desktop logs:
- macOS:
~/Library/Logs/Claude/ - Windows:
%APPDATA%/Claude/logs/ - Look for errors loading MCP server
- macOS:
-
Verify server is running:
# Test server manually node dist/index.js # Should start without errors
-
Check config syntax:
- Use JSONLint to validate JSON
- Ensure no trailing commas
- Check quotes are straight (not curly)
Debugging:
-
Check authentication status:
node dist/index.js auth # Should say "Authentication successful" or guide you to re-auth -
Look at error messages:
- Claude should display specific error from server
- Follow error guidance
-
Restart both:
# 1. Quit Claude Desktop completely # 2. Reopen Claude Desktop # 3. Try command again
Optimizations:
-
Limit results:
{ "query": "from:user@example.com", "maxResults": 10 // Instead of 100 }
-
Use specific queries:
// ❌ Slow (searches everything) "is:unread" // ✅ Faster (narrows down) "from:user@example.com is:unread after:2024/11/01"
-
Check internet connection:
- Gmail API requires internet
- Slow connection = slow operations
Cause: Processing too many emails at once.
Solution:
// ❌ Too many at once
{
"messageIds": [...1000 ids...],
"batchSize": 50
}
// ✅ Process in smaller chunks
{
"messageIds": [...100 ids...],
"batchSize": 25
}Or split into multiple batch operations.
Debugging:
-
Check CPU/Memory:
# macOS/Linux top -p $(pgrep -f "gmail-mcp-server") # Windows tasklist | findstr node
-
Restart server:
- Quit Claude Desktop
- Wait 5 seconds
- Reopen
-
Clear credentials (if persists):
rm -rf ~/.gmail-mcp/credentials.json node dist/index.js auth --force
Modify code temporarily in src/index.ts:
// Add at the top of file
const DEBUG = true;
// Add logging in problematic functions
if (DEBUG) {
console.error('Debug info:', JSON.stringify(data, null, 2));
}Then rebuild:
npm run build- Go to Google Cloud Console - APIs & Services - Dashboard
- Select your project
- Click "Gmail API"
- View quota usage
- If at limit, wait 24 hours for reset
# Navigate to project
cd gmail-mcp-server
# Run auth test
node dist/index.js auth
# Expected output:
# ✅ "Authentication successful!"
# ✅ "Credentials are valid and saved"
# If errors, follow the specific guidance shown# View credentials (for debugging only)
cat ~/.gmail-mcp/credentials.json
# Should contain:
# - access_token
# - refresh_token
# - expiry_date
# - token_type: "Bearer"Security Note: Never share this file or commit it to git!
// In Claude Desktop, try simple operations first:
// 1. List labels (simple, no parameters)
"List all my Gmail labels"
// 2. Search (simple query)
"Search for emails from gmail in the last week"
// 3. Send simple email
"Send a test email to myself with subject 'Test' and body 'Testing'"
// If these work, problem is with specific operation
// If these fail, problem is with authentication/setup- ✅ Tried re-authentication with
--force - ✅ Checked Google Cloud Console configuration
- ✅ Verified Claude Desktop config path and format
- ✅ Restarted Claude Desktop completely
- ✅ Checked this troubleshooting guide
-
Environment:
- OS (macOS/Windows/Linux) and version
- Node.js version:
node --version - Server version: Check
package.json
-
Error message: Full text, including stack trace
-
Steps to reproduce:
- What you did
- What you expected
- What actually happened
-
Config (sanitized):
{ "mcpServers": { "gmail": { "command": "node", "args": ["/ABSOLUTE/PATH/dist/index.js"] } } } -
Authentication status:
node dist/index.js auth # Copy output (redact any tokens!)
- 🐛 Open an Issue
- 💬 GitHub Discussions
- 📧 Email: taleledevdatta@gmail.com
# Re-authenticate
node dist/index.js auth --force
# Rebuild after changes
npm run build
# Check file locations
ls -la ~/.gmail-mcp/
ls -la ~/Library/Application\ Support/Claude/
# Test server manually
node dist/index.js
# View Claude Desktop logs (macOS)
tail -f ~/Library/Logs/Claude/mcp*.log| File | Location |
|---|---|
| OAuth Keys | ./gcp-oauth.keys.json or ~/.gmail-mcp/gcp-oauth.keys.json |
| Credentials | ~/.gmail-mcp/credentials.json |
| Claude Config (macOS) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Config (Windows) | %APPDATA%/Claude/claude_desktop_config.json |
| Claude Config (Linux) | ~/.config/Claude/claude_desktop_config.json |
| Claude Logs (macOS) | ~/Library/Logs/Claude/ |
Most issues are authentication-related and solved by re-authenticating with --force!