Google Calendar MCP Server

Google Calendar MCP Server

Enables management of dental appointments through Google Calendar integration. Supports booking, canceling, rescheduling appointments, checking availability, and finding next available slots through natural language.

Category
访问服务器

README

Google Calendar MCP Server

A Model Context Protocol (MCP) server for managing dental appointments through Google Calendar. Built specifically for Railway deployment with clean, production-ready code.

Features

  • Appointment Management: Book, cancel, and reschedule dental appointments
  • Availability Checking: Check available time slots for specific dates
  • Calendar Integration: Full Google Calendar API integration
  • MCP Protocol: Compatible with MCP clients and AI assistants
  • Railway Ready: Optimized for Railway deployment

Available Tools

  1. check_availability - Check available appointment slots for a specific date and time range
  2. book_appointment - Book a new dental appointment
  3. cancel_appointment - Cancel an existing appointment
  4. reschedule_appointment - Reschedule an existing appointment
  5. get_appointments - Get appointments for a specific date range
  6. find_next_available - Find the next available appointment slot

Setup

Prerequisites

  1. Google Cloud Console project with Calendar API enabled
  2. OAuth 2.0 credentials configured
  3. Python 3.11+ (for local development)

Google Cloud Setup

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable the Google Calendar API
  4. Go to "Credentials" and create OAuth 2.0 Client ID
  5. Configure OAuth consent screen
  6. Download the credentials JSON file

Environment Variables

Copy env.example to .env and fill in your credentials:

cp env.example .env

Required environment variables:

  • GOOGLE_CLIENT_ID - Your Google OAuth client ID
  • GOOGLE_CLIENT_SECRET - Your Google OAuth client secret
  • GOOGLE_ACCESS_TOKEN - OAuth access token (obtained through OAuth flow)
  • GOOGLE_REFRESH_TOKEN - OAuth refresh token (obtained through OAuth flow)
  • GOOGLE_CALENDAR_ID - Calendar ID (use 'primary' for main calendar)
  • PORT - Server port (default: 8000)

OAuth Token Generation

To get the access and refresh tokens, you'll need to run the OAuth flow. Here's a simple script to help:

from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import pickle
import os

SCOPES = ['https://www.googleapis.com/auth/calendar']

def get_credentials():
    creds = None
    if os.path.exists('token.pickle'):
        with open('token.pickle', 'rb') as token:
            creds = pickle.load(token)
    
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                'credentials.json', SCOPES)
            creds = flow.run_local_server(port=0)
        
        with open('token.pickle', 'wb') as token:
            pickle.dump(creds, token)
    
    print(f"Access Token: {creds.token}")
    print(f"Refresh Token: {creds.refresh_token}")
    print(f"Client ID: {creds.client_id}")
    print(f"Client Secret: {creds.client_secret}")

if __name__ == '__main__':
    get_credentials()

Local Development

  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables (see above)

  2. Run the server:

python main.py

The server will be available at http://localhost:8000

Railway Deployment

  1. Connect your GitHub repository to Railway
  2. Set the environment variables in Railway dashboard
  3. Railway will automatically build and deploy using the Dockerfile

Railway Environment Variables

Set these in your Railway project dashboard:

  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • GOOGLE_ACCESS_TOKEN
  • GOOGLE_REFRESH_TOKEN
  • GOOGLE_CALENDAR_ID (optional, defaults to 'primary')

API Endpoints

Health Check

  • GET /health - Simple health check
  • GET /status - Detailed status with service availability

MCP Tools

  • GET /tools - List available tools
  • POST /tools - Execute tool calls

Example Tool Call

curl -X POST "https://your-railway-app.railway.app/tools" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "check_availability",
    "params": {
      "date": "2024-01-15",
      "start_time": "09:00",
      "end_time": "17:00",
      "duration": 60
    }
  }'

Project Structure

dental-calendar-mcp-clean/
├── main.py              # Main FastAPI application
├── requirements.txt     # Python dependencies
├── Dockerfile          # Docker configuration
├── railway.json        # Railway deployment config
├── env.example         # Environment variables template
└── README.md           # This file

Error Handling

The server includes comprehensive error handling:

  • OAuth credential validation
  • Google Calendar API error handling
  • Input validation for all tool parameters
  • Proper HTTP status codes and error messages

Security Notes

  • Never commit OAuth credentials to version control
  • Use environment variables for all sensitive data
  • The server includes CORS middleware for web integration
  • All API endpoints are properly validated

License

This project is open source and available under the MIT License.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选