A Model Context Protocol server for Google Workspace services. This server provides tools to interact with Gmail and Google Calendar through the MCP protocol.
Multiple Google Account Support
Gmail Integration
Calendar Integration
Try these example prompts with your AI assistant:
Clone the repository:
git clone https://github.com/j3k0/mcp-google-workspace.git
cd mcp-google-workspace
Install dependencies:
npm install
Build the TypeScript code:
npm run build
Google Workspace (G Suite) APIs require OAuth2 authorization. Follow these steps to set up authentication:
Create OAuth2 Credentials:
http://localhost:4100/code
for local development)Required OAuth2 Scopes:
[
"openid",
"https://mail.google.com/",
"https://www.googleapis.com/auth/calendar",
"https://www.googleapis.com/auth/userinfo.email"
]
Create a .gauth.json
file in the project root with your Google OAuth 2.0 credentials:
{
"installed": {
"client_id": "your_client_id",
"project_id": "your_project_id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "your_client_secret",
"redirect_uris": ["http://localhost:4100/code"]
}
}
Create a .accounts.json
file to specify which Google accounts can use the server:
{
"accounts": [
{
"email": "your.email@gmail.com",
"account_type": "personal",
"extra_info": "Primary account with Family Calendar"
}
]
}
You can specify multiple accounts. Make sure they have access in your Google Auth app. The extra_info
field is especially useful as you can add information here that you want to tell the AI about the account (e.g., whether it has a specific calendar).
Configure Claude Desktop to use the mcp-google-workspace server:
On MacOS: Edit ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: Edit %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-google-workspace": {
"command": "<dir_to>/mcp-google-workspace/launch"
}
}
}
{
"mcpServers": {
"mcp-google-workspace": {
"command": "npx",
"args": [
"mcp-google-workspace"
]
}
}
}
Start the server:
npm start
Optional arguments:
--gauth-file
: Path to the OAuth2 credentials file (default: ./.gauth.json)--accounts-file
: Path to the accounts configuration file (default: ./.accounts.json)--credentials-dir
: Directory to store OAuth credentials (default: current directory)The server will start and listen for MCP commands via stdin/stdout.
On first run for each account, it will:
.oauth2.{email}.json
gmail_list_accounts
/ calendar_list_accounts
gmail_query_emails
gmail_get_email
gmail_bulk_get_emails
gmail_create_draft
gmail_delete_draft
gmail_reply
gmail_get_attachment
gmail_bulk_save_attachments
gmail_archive
/ gmail_bulk_archive
calendar_list
calendar_get_events
calendar_create_event
calendar_delete_event
src/
directorydist/
directorymcp-google-workspace/
├── src/
│ ├── server.ts # Main server implementation
│ ├── services/
│ │ └── gauth.ts # Google authentication service
│ ├── tools/
│ │ ├── gmail.ts # Gmail tools implementation
│ │ └── calendar.ts # Calendar tools implementation
│ └── types/
│ └── tool-handler.ts # Common types and interfaces
├── .gauth.json # OAuth2 credentials
├── .accounts.json # Account configuration
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
npm run build
: Build TypeScript codenpm start
: Start the servernpm run dev
: Start in development mode with auto-reloadMIT License - see LICENSE file for details
{
"mcpServers": {
"mcp-google-workspace": {
"env": {},
"args": [],
"command": "npx"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.