{"type":"mcp_server","name":"google-calendar","description":"This repository provides an MCP server enabling Claude to interact with Google Calendar. It allows listing events, creating meetings, and finding free time slots by utilizing the Google Calendar API.","category":"Productivity","language":"TypeScript","stars":72,"forks":9,"owner":"v-3","github_url":"https://github.com/v-3/google-calendar","homepage":null,"setup":"## Setup\n\n### 1. Create a Google Cloud Project\n\n1. Go to the [Google Cloud Console](https://console.cloud.google.com/)\n2. Create a new project or select an existing one\n3. Enable the Google Calendar API:\n   - Go to \"APIs & Services\" > \"Library\"\n   - Search for \"Google Calendar API\"\n   - Click \"Enable\"\n\n### 2. Configure OAuth Consent Screen\n\n1. Go to \"APIs & Services\" > \"OAuth consent screen\"\n2. Select \"External\" user type (unless you have a Google Workspace organization)\n3. Fill in the required information:\n   - App name\n   - User support email\n   - Developer contact information\n4. Add the following scopes:\n   - `https://www.googleapis.com/auth/calendar`\n   - `https://www.googleapis.com/auth/calendar.events`\n5. Add your email address as a test user\n\n### 3. Create OAuth 2.0 Credentials\n\n1. Go to \"APIs & Services\" > \"Credentials\"\n2. Click \"Create Credentials\" > \"OAuth client ID\"\n3. Select \"Desktop app\" as the application type\n4. Name your client (e.g., \"MCP Calendar Client\")\n5. Click \"Create\"\n6. Download the client configuration file (you'll need the client ID and client secret)\n\n### 4. Get Refresh Token\n\n1. Create a new file named `getToken.js`:\n\n```javascript\nconst { google } = require('googleapis');\nconst http = require('http');\nconst url = require('url');\n\n// Replace these with your OAuth 2.0 credentials\nconst CLIENT_ID = 'your-client-id';\nconst CLIENT_SECRET = 'your-client-secret';\nconst REDIRECT_URI = 'http://localhost:3000/oauth2callback';\n\n// Configure OAuth2 client\nconst oauth2Client = new google.auth.OAuth2(\n  CLIENT_ID,\n  CLIENT_SECRET,\n  REDIRECT_URI\n);\n\n// Define scopes\nconst scopes = [\n  'https://www.googleapis.com/auth/calendar',\n  'https://www.googleapis.com/auth/calendar.events'\n];\n\nasync function getRefreshToken() {\n  return new Promise((resolve, reject) => {\n    try {\n      // Create server to handle OAuth callback\n      const server = http.createServer(async (req, res) => {\n        try {\n          const queryParams = url.parse(req.url, true).query;\n          \n          if (queryParams.code) {\n            // Get tokens from code\n            const { tokens } = await oauth2Client.getToken(queryParams.code);\n            console.log('\\n=================');\n            console.log('Refresh Token:', tokens.refresh_token);\n            console.log('=================\\n');\n            console.log('Save this refresh token in your configuration!');\n            \n            // Send success response\n            res.end('Authentication successful! You can close this window.');\n            \n            // Close server\n            server.close();\n            resolve(tokens);\n          }\n        } catch (error) {\n          console.error('Error getting tokens:', error);\n          res.end('Authentication failed! Please check console for errors.');\n          reject(error);\n        }\n      }).listen(3000, () => {\n        // Generate auth url\n        const authUrl = oauth2Client.generateAuthUrl({\n          access_type: 'offline',\n          scope: scopes,\n          prompt: 'consent'  // Force consent screen to ensure refresh token\n        });\n\n        console.log('1. Copy this URL and paste it in your browser:');\n        console.log('\\n', authUrl, '\\n');\n        console.log('2. Follow the Google authentication process');\n        console.log('3. Wait for the refresh token to appear here');\n      });\n\n    } catch (error) {\n      console.error('Server creation error:', error);\n      reject(error);\n    }\n  });\n}\n\n// Run the token retrieval\ngetRefreshToken().catch(console.error);\n```\n\n2. Install required dependency:\n```bash\nnpm install googleapis\n```\n\n3. Update the script with your OAuth credentials:\n   - Replace `your-client-id` with your actual client ID\n   - Replace `your-client-secret` with your actual client secret\n\n4. Run the script:\n```bash\nnode getToken.js\n```\n\n5. Follow the instructions in the console:\n   - Copy the provided URL\n   - Paste it into your browser\n   - Complete the Google authentication process\n   - Copy the refresh token that appears in the console\n\n### 5. Configure Claude Desktop\n\n1. Open your Claude Desktop configuration file:\n\n**For MacOS:**\n```bash\ncode ~/Library/Application\\ Support/Claude/claude_desktop_config.json\n```\n\n**For Windows:**\n```bash\ncode %AppData%\\Claude\\claude_desktop_config.json\n```\n\n2. Add or update the configuration:\n```json\n{\n    \"mcpServers\": {\n        \"google-calendar\": {\n            \"command\": \"node\",\n            \"args\": [\n                \"/ABSOLUTE/PATH/TO/YOUR/build/index.js\"\n            ],\n            \"env\": {\n                \"GOOGLE_CLIENT_ID\": \"your_client_id_here\",\n                \"GOOGLE_CLIENT_SECRET\": \"your_client_secret_here\",\n                \"GOOGLE_REDIRECT_URI\": \"http://localhost\",\n                \"GOOGLE_REFRESH_TOKEN\": \"your_refresh_token_here\"\n            }\n        }\n    }\n}\n```\n\n3. Save the file and restart Claude Desktop\n\n## Initial Project Setup\n\n1. Create a new directory for your project:\n```bash\nmkdir google-calendar-mcp\ncd google-calendar-mcp\n```\n\n2. Initialize a new npm project:\n```bash\nnpm init -y\n```\n\n3. Install dependencies:\n```bash\nnpm install @modelcontextprotocol/sdk googleapis google-auth-library zod\nnpm install -D @types/node typescript\n```\n\n4. Create a tsconfig.json file:\n```json\n{\n  \"compilerOptions\": {\n    \"target\": \"ES2022\",\n    \"module\": \"Node16\",\n    \"moduleResolution\": \"Node16\",\n    \"outDir\": \"./build\",\n    \"rootDir\": \"./src\",\n    \"strict\": true,\n    \"esModuleInterop\": true,\n    \"skipLibCheck\": true,\n    \"forceConsistentCasingInFileNames\": true\n  },\n  \"include\": [\"src/**/*\"],\n  \"exclude\": [\"node_modules\"]\n}\n```\n\n5. Update package.json:\n```json\n{\n  \"type\": \"module\",\n  \"scripts\": {\n    \"build\": \"tsc && node -e \\\"require('fs').chmodSync('build/index.js', '755')\\\"\"\n  }\n}\n```\n\n6. Create your source directory:\n```bash\nmkdir src\n```\n\n7. Create a .env file for local development (don't commit this file):\n```bash\nGOOGLE_CLIENT_ID=your_client_id_here\nGOOGLE_CLIENT_SECRET=your_client_secret_here\nGOOGLE_REDIRECT_URI=http://localhost\nGOOGLE_REFRESH_TOKEN=your_refresh_token_here\n```","tools":"## Available Tools\n\n1.  `list_events` (List calendar events within a specified time range)\n2.  `create_event` (Create a new calendar event)\n3.  `update_event` (Update an existing calendar event)\n4.  `delete_event` (Delete a calendar event)\n5.  `find_free_time` (Find available time slots in the calendar)","faq":null,"created_at":"2024-12-22T10:11:12+00:00","updated_at":"2025-03-27T01:33:01+00:00","source_url":"https://model-context-protocol.com/servers/google-calendar-api-meeting-event-management","related_articles":[]}