This guide provides step-by-step instructions for connecting the Gmail MCP Server with various MCP clients, including GitHub Copilot, VS Code with Claude, desktop applications, and other popular clients.
- Prerequisites
- General Connection Steps
- Client-Specific Integration
- Configuration Templates
- Testing Your Connection
- Troubleshooting
Before connecting to any MCP client, ensure your Gmail MCP Server is properly set up:
- Server Setup Complete: Follow the main README.md setup instructions
- Authentication Working: Run
npm run checkto verify Gmail API access - Server Running: The MCP server should be accessible via stdio or network
- Node.js Version: Ensure you're using Node.js 18.0.0 or higher
# Navigate to your email-mcp-server directory
cd /path/to/email-mcp-server
# Start the server
npm start
Note the absolute path to your MCP server:
pwd
# Example output: /Users/yourusername/email-mcp-server
The Gmail MCP Server supports:
- Stdio Transport: Direct process communication (recommended)
- Network Transport: TCP/WebSocket connections (for remote access)
GitHub Copilot with MCP support requires configuration through VS Code or your IDE.
-
Install GitHub Copilot Extension:
code --install-extension GitHub.copilot -
Create MCP Configuration: Create or update
.vscode/settings.jsonin your workspace:{ "github.copilot.advanced": { "mcp": { "servers": { "gmail": { "command": "node", "args": ["src/index.js"], "cwd": "/absolute/path/to/email-mcp-server", "env": {} } } } } } -
Restart VS Code and verify the connection in the Copilot panel.
# Add to your copilot configuration
gh copilot config set mcp.servers.gmail.command "node /absolute/path/to/email-mcp-server/src/index.js"
-
Install Claude for VS Code:
code --install-extension Anthropic.claude-dev -
Configure MCP in VS Code Settings: Add to your VS Code
settings.json:{ "claude.mcpServers": { "gmail": { "command": "node", "args": ["src/index.js"], "cwd": "/absolute/path/to/email-mcp-server" } } }
- Open VS Code Terminal
- Start MCP Server:
cd /path/to/email-mcp-server npm start - Connect Claude through the command palette (Ctrl/Cmd + Shift + P):
- Search for "Claude: Connect to MCP Server"
- Select "gmail" from the available servers
-
Locate Claude Desktop Config:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Add Gmail MCP Server Configuration:
{ "mcpServers": { "gmail": { "command": "node", "args": ["src/index.js"], "cwd": "/absolute/path/to/email-mcp-server", "env": {} } } } -
Restart Claude Desktop to load the new configuration.
If you prefer network-based connection:
-
Start Server with Network Transport:
# Modify src/index.js to use network transport npm run start -- --transport=network --port=3001 -
Configure Claude Desktop:
{ "mcpServers": { "gmail": { "url": "ws://localhost:3001", "transport": "websocket" } } }
Continue.dev is a popular VS Code extension for AI-powered coding.
-
Install Continue Extension:
code --install-extension Continue.continue -
Configure MCP in Continue Settings: Open Continue settings and add:
{ "mcpServers": [ { "name": "gmail", "command": "node", "args": ["src/index.js"], "cwd": "/absolute/path/to/email-mcp-server" } ] } -
Restart VS Code and access Gmail tools through Continue's interface.
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import { spawn } from 'child_process';
// Create transport
const serverProcess = spawn('node', ['src/index.js'], {
cwd: '/absolute/path/to/email-mcp-server',
stdio: ['pipe', 'pipe', 'inherit']
});
const transport = new StdioClientTransport({
reader: serverProcess.stdout,
writer: serverProcess.stdin
});
// Create client
const client = new Client({
name: "gmail-client",
version: "1.0.0"
}, {
capabilities: {}
});
// Connect and use
await client.connect(transport);
// List available tools
const tools = await client.listTools();
console.log('Available tools:', tools);
// Send an email
const result = await client.callTool('send_email', {
to: 'recipient@example.com',
subject: 'Test from MCP',
body: 'Hello from Gmail MCP Server!'
});
import asyncio
import subprocess
from mcp.client import stdio
async def main():
# Start the MCP server
proc = subprocess.Popen([
'node', 'src/index.js'
], cwd='/absolute/path/to/email-mcp-server',
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
# Connect via stdio
async with stdio.stdio_client(proc) as (read, write):
async with ClientSession(read, write) as session:
# Initialize the connection
await session.initialize()
# List available tools
tools = await session.list_tools()
print(f"Available tools: {tools}")
# Send an email
result = await session.call_tool("send_email", {
"to": "recipient@example.com",
"subject": "Test from Python MCP Client",
"body": "Hello from Python!"
})
print(f"Email sent: {result}")
asyncio.run(main())
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["src/index.js"],
"cwd": "/absolute/path/to/email-mcp-server",
"env": {
"NODE_ENV": "production"
}
}
}
}
{
"mcpServers": {
"gmail-dev": {
"command": "node",
"args": ["--watch", "src/index.js"],
"cwd": "/absolute/path/to/email-mcp-server",
"env": {
"NODE_ENV": "development",
"DEBUG": "true"
}
}
}
}
{
"mcpServers": {
"gmail-remote": {
"url": "ws://localhost:3001",
"transport": "websocket"
}
}
}
Use the built-in test client:
cd /path/to/email-mcp-server
npm run test:mcp
In your MCP client, verify available tools:
send_email- Send Gmail messagesread_emails- Read inbox messagessearch_emails- Search Gmailget_email_details- Get specific email details
Send a test email:
npm run test:email
- Open Claude Desktop
- Type: "List the available MCP tools"
- Verify Gmail tools appear
- Try: "Send a test email to myself"
- Open command palette (Ctrl/Cmd + Shift + P)
- Look for MCP-related commands
- Check if Gmail server is listed as connected
Symptoms: Client can't connect to Gmail MCP server Solutions:
- Verify the absolute path in configuration
- Check Node.js is installed and accessible
- Ensure all dependencies are installed (
npm install)
Symptoms: "Gmail API authentication failed" Solutions:
- Run
npm run checkto verify setup - Re-run authentication:
npm run reauth - Check credentials.json file exists and is valid
Symptoms: "Insufficient permissions for Gmail API" Solutions:
- Verify Gmail API is enabled in Google Cloud Console
- Check OAuth consent screen configuration
- Run
npm run check:permissions
Symptoms: Client connection times out Solutions:
- Check server starts successfully:
npm start - Verify no port conflicts (if using network transport)
- Check firewall settings
Enable debug logging:
DEBUG=* npm start
Or set environment variable in client configuration:
{
"env": {
"DEBUG": "mcp:*"
}
}
Check logs for connection issues:
# Server logs
tail -f /path/to/email-mcp-server/logs/server.log
# Client logs (varies by client)
# Claude Desktop: Check Console in developer tools
# VS Code: Check Output panel -> MCP
- Never commit
credentials.jsonortoken.jsonto version control - Use environment variables for sensitive data in production
- Regularly rotate OAuth tokens
- Use HTTPS/WSS for network connections
- Implement proper authentication for remote access
- Consider VPN for remote MCP connections
- Limit Gmail API scopes to minimum required
- Implement rate limiting in the server
- Monitor email sending patterns
If you encounter issues not covered in this guide:
- Check existing issues: GitHub Issues
- Create a new issue: Provide detailed error messages and configuration
- Community support: Join MCP community discussions
Need help? Open an issue on GitHub or refer to the main README.md for additional setup instructions.