go

google-calendar-mcp

An MCP server to interface with the Google Calendar API. Based on TypeScript.

Publishergoogle-calendar-mcp
Submitted date4/13/2025

Google Calendar MCP Server: Seamless Integration for AI-Powered Calendar Management

Empowering LLMs with Real-Time Calendar Access via the Model Context Protocol

Version Security Tests

image

Unveiling the Google Calendar MCP Server

The Google Calendar MCP Server bridges the gap between Large Language Models (LLMs) like Claude and the ubiquitous Google Calendar, enabling sophisticated AI-driven calendar management. By adhering to the Model Context Protocol (MCP), this server provides a standardized and secure interface for LLMs to access, modify, and interpret calendar data, unlocking a new realm of possibilities for intelligent assistants and automated workflows.

This server empowers LLMs to:

  • Intelligently schedule meetings: Understand natural language requests to create events with accurate times, attendees, and descriptions.
  • Proactively manage schedules: Remind users of upcoming events, suggest optimal meeting times based on availability, and automatically reschedule conflicts.
  • Contextually analyze calendar data: Extract insights from past events, identify trends in scheduling patterns, and provide data-driven recommendations for improved time management.

Core Capabilities: A Deep Dive

The Google Calendar MCP Server offers a comprehensive suite of features, meticulously engineered for performance, security, and seamless integration:

  • Native Google Calendar Integration: Leverages the official Google Calendar API for reliable and accurate data access.
  • Model Context Protocol (MCP) Compliance: Ensures interoperability with any LLM application that supports the MCP standard.
  • Robust OAuth2 Authentication: Implements a secure and industry-standard authentication flow to protect user data.
  • Comprehensive Event Management: Supports the full spectrum of calendar operations: creating, reading, updating, and deleting events.
  • Enhanced Event Customization: Allows for precise control over event attributes, including color-coding for visual organization.
  • STDIO Transport: Facilitates efficient and reliable communication with LLM applications via standard input/output streams.

Architectural Blueprint: A Layered Approach

The server's architecture is designed for modularity, scalability, and maintainability:

  • TypeScript Foundation: Built with TypeScript for enhanced code quality, type safety, and developer productivity.
  • MCP SDK Integration: Utilizes the @modelcontextprotocol/sdk to streamline communication and adherence to the MCP standard.
  • Google API Abstraction: Employs the googleapis library to simplify interactions with the Google Calendar API.
  • Zod Schema Validation: Ensures data integrity by rigorously validating all incoming and outgoing data.
  • Environment-Driven Configuration: Leverages dotenv for flexible and secure configuration management.
  • Security Hardening: Implements Helmet.js to protect against common web vulnerabilities.
  • AES-256-GCM Encryption: Secures sensitive data, such as authentication tokens, using industry-leading encryption algorithms.
  • Automated Testing & Deployment: Employs Jest for comprehensive unit testing and GitHub Actions for continuous integration and deployment.

Key Components: The Building Blocks

  1. MCP Server Core: The central component responsible for handling communication with LLM applications and routing requests to the appropriate services.
  2. Google Calendar Tools: A collection of specialized functions for interacting with the Google Calendar API, including event retrieval, creation, updating, and deletion.
  3. Authentication Manager: Handles the OAuth2 authentication flow, ensuring secure access to user calendar data.
  4. Schema Validator: Validates all incoming and outgoing data against predefined schemas, preventing errors and ensuring data integrity.
  5. Token Vault: Securely stores and manages authentication tokens, protecting them from unauthorized access.

Toolset: Empowering LLMs with Calendar Control

The Google Calendar MCP Server exposes a powerful set of tools that enable LLMs to perform a wide range of calendar-related tasks:

1. getEvents: Intelligent Event Retrieval

Retrieves calendar events based on flexible filtering criteria.

Parameters:

  • calendarId (optional): Specifies the calendar to query. Defaults to the user's primary calendar.
  • timeMin (optional): Filters events to those starting after this date/time (ISO 8601 format, e.g., "2025-03-01T00:00:00Z").
  • timeMax (optional): Filters events to those starting before this date/time (ISO 8601 format).
  • maxResults (optional): Limits the number of events returned (default: 10).
  • orderBy (optional): Specifies the sort order of the results ("startTime" or "updated").

Example Use Case:

"Find my next 3 meetings after tomorrow."

2. createEvent: Seamless Event Creation

Creates new calendar events with detailed specifications.

Parameters:

  • calendarId (optional): Specifies the calendar to create the event in. Defaults to the user's primary calendar.
  • event: An object containing the event details:
    • summary (required): The event title.
    • description (optional): A detailed description of the event.
    • location (optional): The event location.
    • start: An object specifying the event start time:
      • dateTime (optional): ISO 8601 format (e.g., "2025-03-15T09:00:00+09:00").
      • date (optional): YYYY-MM-DD format for all-day events.
      • timeZone (optional): The time zone for the event (e.g., "Asia/Tokyo").
    • end: An object specifying the event end time (same format as start).
    • attendees (optional): An array of attendee objects, each with email and optional displayName.
    • colorId (optional): A numeric ID (1-11) representing the event color.

Example Use Case:

"Schedule a meeting with John Smith and Jane Doe next Tuesday at 2 PM to discuss the Q3 report."

3. updateEvent: Precise Event Modification

Updates existing calendar events with granular control. This function intelligently merges updates with existing event data, preserving unspecified fields.

Parameters:

  • calendarId (optional): Specifies the calendar containing the event. Defaults to the user's primary calendar.
  • eventId (required): The ID of the event to update.
  • event: An object containing the fields to update (all fields are optional). Only specified fields will be modified; unspecified fields will retain their original values.

Key Feature: Partial Updates

This function supports partial updates, allowing you to modify specific event attributes without affecting other details.

Example Use Case:

"Change the location of my meeting with John Smith to Conference Room B."

4. deleteEvent: Effortless Event Removal

Deletes a calendar event.

Parameters:

  • calendarId (optional): Specifies the calendar containing the event. Defaults to the user's primary calendar.
  • eventId (required): The ID of the event to delete.

Example Use Case:

"Cancel my meeting with John Smith tomorrow."

Development Principles: Guiding Our Approach

Our development process is guided by the following principles:

  • Semantic Versioning: Adhere to semantic versioning for all changes, ensuring clear communication of updates and potential breaking changes.
  • Object-Oriented Programming (OOP): Employ OOP principles for modularity, reusability, and maintainability.
  • Clean Code Practices: Write clear, concise, and well-documented code that adheres to industry best practices.
  • Comprehensive Testing: Implement thorough unit and integration tests to ensure code quality and prevent regressions.

Code Structure: A Logical Organization

  • src/: The root directory for all source code.
    • auth/: Contains code related to authentication and authorization.
    • config/: Contains configuration settings and environment variables.
    • mcp/: Contains the core MCP server implementation.
    • tools/: Contains the Google Calendar tool implementations.
    • utils/: Contains utility functions and helper classes.

Best Practices: Ensuring Quality and Security

  • Strict Typing: Utilize TypeScript's strong typing capabilities to prevent runtime errors and improve code maintainability.
  • Robust Error Handling: Implement comprehensive error handling to gracefully handle unexpected situations and provide informative error messages.
  • Secure Authentication: Adhere to OAuth 2.1 standards and implement best practices for secure authentication and authorization.
  • Dependency Management: Keep dependencies up-to-date to benefit from the latest security patches and performance improvements.
  • Clear Documentation: Provide clear and concise documentation for all functions and classes.
  • Input Validation: Validate all input data to prevent security vulnerabilities and ensure data integrity.

Testing Strategy: A Multi-Layered Approach

  • Unit Tests: Test individual functions and classes in isolation to ensure they behave as expected.
  • Integration Tests: Test the interaction between different components to ensure they work together seamlessly.
  • Security Tests: Identify and mitigate potential security vulnerabilities.
  • Coverage Reports: Track code coverage to ensure that all parts of the codebase are adequately tested.

Deployment Guide: Getting Started

The Google Calendar MCP Server is published on npm as @takumi0706/google-calendar-mcp.

npx @takumi0706/google-calendar-mcp@latest

Prerequisites: Setting the Stage

  1. Google Cloud Project: Create a Google Cloud Project and enable the Google Calendar API.
  2. OAuth2 Credentials: Configure OAuth2 credentials in the Google Cloud Console.
  3. Environment Variables: Set the following environment variables:
# Create a .env file with your Google OAuth credentials GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret GOOGLE_REDIRECT_URI=http://localhost:4153/oauth2callback # Optional: Token encryption key (auto-generated if not provided) TOKEN_ENCRYPTION_KEY=32-byte-hex-key # Optional: Auth server port and host (default port: 4153, host: localhost) AUTH_PORT=4153 AUTH_HOST=localhost # Optional: MCP server port and host (default port: 3000, host: localhost) PORT=3000 HOST=localhost

Claude Desktop Configuration: Connecting the Pieces

Add the server to your claude_desktop_config.json:

{ "mcpServers": { "google-calendar": { "command": "npx", "args": [ "-y", "@takumi0706/google-calendar-mcp" ], "env": { "GOOGLE_CLIENT_ID": "your_client_id", "GOOGLE_CLIENT_SECRET": "your_client_secret", "GOOGLE_REDIRECT_URI": "http://localhost:4153/oauth2callback" } } } }

Security Hardening: Protecting User Data

Security is paramount. The Google Calendar MCP Server incorporates multiple layers of security to protect user data:

  • In-Memory Token Storage: OAuth tokens are stored in memory only, minimizing the risk of persistent storage vulnerabilities.
  • Environment Variable Secrets: Sensitive credentials are provided as environment variables, preventing them from being hardcoded in the codebase.
  • AES-256-GCM Encryption: Authentication tokens are encrypted using AES-256-GCM for secure storage.
  • PKCE Implementation: The Proof Key for Code Exchange (PKCE) protocol is implemented to prevent authorization code interception attacks.
  • CSRF Protection: State parameter validation is used to protect against Cross-Site Request Forgery (CSRF) attacks.
  • Helmet.js Security Headers: Security headers are applied using Helmet.js to mitigate common web vulnerabilities.
  • API Rate Limiting: Rate limiting is implemented to protect against denial-of-service attacks.
  • Input Validation: Input data is validated using Zod schemas to prevent injection attacks and ensure data integrity.

For more detailed information, please refer to SECURITY.md.

Maintenance Strategy: Ensuring Long-Term Stability

  • Regular API Updates: The server is regularly updated to maintain compatibility with the Google Calendar API.
  • Version History Documentation: Version updates are meticulously documented in the README.md file.
  • Centralized Logging: Logs are stored in the user's home directory (~/.google-calendar-mcp/logs/) for easy troubleshooting.

Troubleshooting Guide: Resolving Common Issues

If you encounter any issues, please follow these steps:

  1. Check the Logs: Examine the logs in your home directory at ~/.google-calendar-mcp/logs/ for error messages.
  2. Verify Credentials: Ensure that your Google OAuth credentials are correctly configured.
  3. Check Permissions: Verify that you have sufficient permissions for Google Calendar API access.
  4. Review Configuration: Ensure that your Claude Desktop configuration is correct.

Common Errors and Solutions

  • JSON Parsing Errors: These errors typically indicate malformed JSON-RPC messages. Ensure you are using the latest version of the server (v0.6.7 or later).
  • Authentication Errors: Double-check your Google OAuth credentials and ensure that the redirect URI is correctly configured.
  • Connection Errors: Ensure that only one instance of the server is running.
  • Disconnection Issues: Verify that your server is properly handling MCP messages without relying on custom TCP sockets.

Development Roadmap: Contributing to the Future

To contribute to this project:

# Clone the repository git clone https://github.com/takumi0706/google-calendar-mcp.git cd google-calendar-mcp # Install dependencies npm install # Run in development mode npm run dev

Testing Procedures: Ensuring Code Quality

To run the tests:

# Run all tests npm test # Run tests with coverage report npm test -- --coverage

License: Open Source Freedom

This project is licensed under the MIT License.

Visit More

View All