
Google Calendar
Contribute to v-3/google-calendar development by creating an account on GitHub.
README
Google Calendar MCP Server
This MCP server allows Claude to interact with your Google Calendar, enabling capabilities like listing events, creating meetings, and finding free time slots.
Prerequisites
- Node.js (v16 or higher)
- Claude Desktop App
- A Google Cloud Project
- Google Calendar API enabled
- OAuth 2.0 credentials
Setup Instructions
1. Create a Google Cloud Project
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Calendar API:
- Go to "APIs & Services" > "Library"
- Search for "Google Calendar API"
- Click "Enable"
2. Configure OAuth Consent Screen
- Go to "APIs & Services" > "OAuth consent screen"
- Select "External" user type (unless you have a Google Workspace organization)
- Fill in the required information:
- App name
- User support email
- Developer contact information
- Add the following scopes:
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.events
- Add your email address as a test user
3. Create OAuth 2.0 Credentials
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Select "Desktop app" as the application type
- Name your client (e.g., "MCP Calendar Client")
- Click "Create"
- Download the client configuration file (you'll need the client ID and client secret)
4. Get Refresh Token
- Create a new file named
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);
- Install required dependency:
npm install googleapis
-
Update the script with your OAuth credentials:
- Replace
your-client-id
with your actual client ID - Replace
your-client-secret
with your actual client secret
- Replace
-
Run the script:
node getToken.js
- Follow the instructions in the console:
- Copy the provided URL
- Paste it into your browser
- Complete the Google authentication process
- Copy the refresh token that appears in the console
5. Configure Claude Desktop
- Open your Claude Desktop configuration file:
For MacOS:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
For Windows:
code %AppData%\Claude\claude_desktop_config.json
- Add or update the configuration:
{
"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"
}
}
}
}
- Save the file and restart Claude Desktop
Initial Project Setup
- Create a new directory for your project:
mkdir google-calendar-mcp
cd google-calendar-mcp
- Initialize a new npm project:
npm init -y
- Install dependencies:
npm install @modelcontextprotocol/sdk googleapis google-auth-library zod
npm install -D @types/node typescript
- Create a tsconfig.json file:
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"outDir": "./build",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
- Update package.json:
{
"type": "module",
"scripts": {
"build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\""
}
}
- Create your source directory:
mkdir src
- Create a .env file for local development (don't commit this file):
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
Building and Running
- Build the server:
npm run build
- The server will automatically start when you open Claude Desktop
Available Tools
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 calendar
Example Usage in Claude
After setup, you can use commands like:
- "Show me my calendar events for next week"
- "Schedule a meeting with [email_id] tomorrow at 2 PM for 1 hour"
- "Find a free 30-minute slot this afternoon"
- "Update my 3 PM meeting to 4 PM"
- "Cancel my meeting with ID [event_id]"
Troubleshooting
Common Issues
-
Tools not appearing in Claude:
- Check Claude Desktop logs:
tail -f ~/Library/Logs/Claude/mcp*.log
- Verify all environment variables are set correctly
- Ensure the path to index.js is absolute and correct
- Check Claude Desktop logs:
-
Authentication Errors:
- Verify your OAuth credentials are correct
- Check if refresh token is valid
- Ensure required scopes are enabled
-
Server Connection Issues:
- Check if the server built successfully
- Verify file permissions on build/index.js (should be 755)
- Try running the server directly:
node /path/to/build/index.js
Viewing Logs
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
Environment Variables
If you're getting environment variable errors, verify each one:
- GOOGLE_CLIENT_ID: Should start with something like "123456789-..."
- GOOGLE_CLIENT_SECRET: Usually ends in ".apps.googleusercontent.com"
- GOOGLE_REDIRECT_URI: Should be "http://localhost"
- GOOGLE_REFRESH_TOKEN: A long string that doesn't expire
Security Considerations
- Keep your OAuth credentials secure
- Don't commit credentials to version control
- Use environment variables for sensitive data
- Regularly rotate refresh tokens
- Monitor API usage in Google Cloud Console
License
MIT License - See LICENSE file for details.
Support
If you encounter any issues:
- Check the troubleshooting section above
- Review Claude Desktop logs
- Open an issue on GitHub
- Contact the maintainer
推荐服务器

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
AIO-MCP Server
🚀 All-in-one MCP server with AI search, RAG, and multi-service integrations (GitLab/Jira/Confluence/YouTube) for AI-enhanced development workflows. Folk from
Hyperbrowser
欢迎来到 Hyperbrowser,人工智能的互联网。Hyperbrowser 是下一代平台,旨在增强人工智能代理的能力,并实现轻松、可扩展的浏览器自动化。它专为人工智能开发者打造,消除了本地基础设施和性能瓶颈带来的麻烦,让您能够:
BigQuery MCP Server
这是一个服务器,可以让你的大型语言模型(LLM,比如Claude)直接与你的BigQuery数据对话!可以把它想象成一个友好的翻译器,它位于你的AI助手和数据库之间,确保它们可以安全高效地进行交流。
mcp-perplexity
Perplexity API 的 MCP 服务器。
MCP Web Research Server
一个模型上下文协议服务器,使 Claude 能够通过集成 Google 搜索、提取网页内容和捕获屏幕截图来进行网络研究。
MySQL MCP Server
允许人工智能助手通过受控界面列出表格、读取数据和执行 SQL 查询,从而使数据库探索和分析更安全、更有条理。
mcp-codex-keeper
作为开发知识的守护者,为 AI 助手提供精心策划的最新文档和最佳实践访问权限。
MCP Etherscan Server
通过 Etherscan 的 API 促进与以太坊区块链数据的交互,提供对余额、交易、代币转移、合约 ABI、gas 价格和 ENS 名称解析的实时访问。
Perplexity Deep Research MCP
一个服务器,它允许 AI 助手使用 Perplexity 的 sonar-deep-research 模型进行网络搜索,并提供引用支持。