by v-3
Google Calendar MCP Server is a bridge that enables Claude (an AI assistant) to interact with your Google Calendar. It allows Claude to perform various calendar-related tasks on your behalf, such as managing events and finding free time.
This project is an MCP (Model Context Protocol) server that enables Claude (an AI assistant, likely referring to the Claude Desktop App) to interact with your Google Calendar. It acts as a bridge, allowing Claude to perform various calendar-related tasks on your behalf.
Using the Google Calendar MCP Server involves several setup steps:
https://www.googleapis.com/auth/calendar
, https://www.googleapis.com/auth/calendar.events
).getToken.js
) to obtain a refresh token. This involves running the script, opening a generated URL in your browser, authenticating with Google, and copying the refresh token displayed in the console.google-calendar
MCP server entry to its configuration file (claude_desktop_config.json
). This involves setting the command, arguments, and environment variables (client ID, client secret, redirect URI, and refresh token).@modelcontextprotocol/sdk
, googleapis
, google-auth-library
, zod
, typescript
), create a tsconfig.json
file, update package.json
scripts, and create a .env
file for local development.npm run build
. The server will automatically start when you open the Claude Desktop App.Q: Tools not appearing in Claude?
A: Check Claude Desktop logs (tail -f ~/Library/Logs/Claude/mcp*.log
), verify environment variables, and ensure the absolute path to index.js
is correct.
Q: Authentication Errors? A: Verify OAuth credentials, check refresh token validity, and ensure required scopes are enabled.
Q: Server Connection Issues?
A: Check if the server built successfully, verify file permissions on build/index.js
(should be 755), and try running the server directly (node /path/to/build/index.js
).
Q: How to view server logs?
A: Use tail -n 20 -f ~/Library/Logs/Claude/mcp*.log
for MacOS/Linux or Get-Content -Path "$env:AppData\Claude\Logs\mcp*.log" -Wait -Tail 20
for Windows.
Q: What are the important environment variables?
A: GOOGLE_CLIENT_ID
, GOOGLE_CLIENT_SECRET
, GOOGLE_REDIRECT_URI
(should be http://localhost
), and GOOGLE_REFRESH_TOKEN
(a long string that doesn't expire).
Q: What are the security considerations? A: Keep OAuth credentials secure, do not commit them to version control, use environment variables for sensitive data, regularly rotate refresh tokens, and monitor API usage in Google Cloud Console.
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:
Reviews feature coming soon
Stay tuned for community discussions and feedback