Google Calendar
STDIOMCP server allowing Claude to interact with Google Calendar for managing events and meetings.
MCP server allowing Claude to interact with Google Calendar for managing events and meetings.
This MCP server allows Claude to interact with your Google Calendar, enabling capabilities like listing events, creating meetings, and finding free time slots.
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.events
getToken.js
:const { google } = require('googleapis'); const http = require('http'); const url = require('url'); // Replace these with your OAuth 2.0 credentials const CLIENT_ID = 'your-client-id'; const CLIENT_SECRET = 'your-client-secret'; const REDIRECT_URI = 'http://localhost:3000/oauth2callback'; // Configure OAuth2 client const oauth2Client = new google.auth.OAuth2( CLIENT_ID, CLIENT_SECRET, REDIRECT_URI ); // Define scopes const scopes = [ 'https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events' ]; async function getRefreshToken() { return new Promise((resolve, reject) => { try { // Create server to handle OAuth callback const server = http.createServer(async (req, res) => { try { const queryParams = url.parse(req.url, true).query; if (queryParams.code) { // Get tokens from code const { tokens } = await oauth2Client.getToken(queryParams.code); console.log('\n================='); console.log('Refresh Token:', tokens.refresh_token); console.log('=================\n'); console.log('Save this refresh token in your configuration!'); // Send success response res.end('Authentication successful! You can close this window.'); // Close server server.close(); resolve(tokens); } } catch (error) { console.error('Error getting tokens:', error); res.end('Authentication failed! Please check console for errors.'); reject(error); } }).listen(3000, () => { // Generate auth url const authUrl = oauth2Client.generateAuthUrl({ access_type: 'offline', scope: scopes, prompt: 'consent' // Force consent screen to ensure refresh token }); console.log('1. Copy this URL and paste it in your browser:'); console.log('\n', authUrl, '\n'); console.log('2. Follow the Google authentication process'); console.log('3. Wait for the refresh token to appear here'); }); } catch (error) { console.error('Server creation error:', error); reject(error); } }); } // Run the token retrieval getRefreshToken().catch(console.error);
npm install googleapis
Update the script with your OAuth credentials:
your-client-id
with your actual client IDyour-client-secret
with your actual client secretRun the script:
node getToken.js
For MacOS:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
For Windows:
code %AppData%\Claude\claude_desktop_config.json
{ "mcpServers": { "google-calendar": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/YOUR/build/index.js" ], "env": { "GOOGLE_CLIENT_ID": "your_client_id_here", "GOOGLE_CLIENT_SECRET": "your_client_secret_here", "GOOGLE_REDIRECT_URI": "http://localhost", "GOOGLE_REFRESH_TOKEN": "your_refresh_token_here" } } } }
mkdir google-calendar-mcp cd google-calendar-mcp
npm init -y
npm install @modelcontextprotocol/sdk googleapis google-auth-library zod npm install -D @types/node typescript
{ "compilerOptions": { "target": "ES2022", "module": "Node16", "moduleResolution": "Node16", "outDir": "./build", "rootDir": "./src", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true }, "include": ["src/**/*"], "exclude": ["node_modules"] }
{ "type": "module", "scripts": { "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"" } }
mkdir src
GOOGLE_CLIENT_ID=your_client_id_here GOOGLE_CLIENT_SECRET=your_client_secret_here GOOGLE_REDIRECT_URI=http://localhost GOOGLE_REFRESH_TOKEN=your_refresh_token_here
npm run build
The server provides the following tools:
list_events
: List calendar events within a specified time rangecreate_event
: Create a new calendar eventupdate_event
: Update an existing calendar eventdelete_event
: Delete a calendar eventfind_free_time
: Find available time slots in the calendarAfter setup, you can use commands like:
Tools not appearing in Claude:
tail -f ~/Library/Logs/Claude/mcp*.log
Authentication Errors:
Server Connection Issues:
node /path/to/build/index.js
To view server logs:
# For MacOS/Linux: tail -n 20 -f ~/Library/Logs/Claude/mcp*.log # For Windows: Get-Content -Path "$env:AppData\Claude\Logs\mcp*.log" -Wait -Tail 20
If you're getting environment variable errors, verify each one:
MIT License - See LICENSE file for details.
If you encounter any issues: