Google Workspace MCP Server

Google Workspace MCP Server

Enables AI agents to interact with Google Workspace (Gmail, Calendar, Sheets, Drive, Docs) through MCP tools, allowing natural language commands to manage emails, schedule events, and handle documents via a Telegram bot interface.

Category
Visit Server

README

🤖 Google Workspace MCP + Telegram AI Agent

A comprehensive learning project focused on exploring and applying modern AI Agent technologies, specifically integrating the Model Context Protocol (MCP) with Google Gemini API and a Telegram Bot.

This project transforms your Telegram into a smart, personal AI Assistant capable of engaging in natural language conversations and directly operating across your entire Google Workspace ecosystem (Gmail, Calendar, Sheets, Docs, Drive).


🎯 Learning Objectives

This project is meticulously designed to help you practice and understand the following core concepts:

  1. Agentic AI & Tool Calling: Understanding how a Large Language Model (Gemini) analyzes user intent and autonomously decides to invoke external tools to accomplish complex tasks.
  2. Model Context Protocol (MCP): Learning the latest open standard (from Anthropic/Google) that standardizes how AI models connect to external data sources and tools.

🏗️ Tech Stack

Built with a modern, lightweight, and type-safe technology stack:

Layer Technology Purpose
AI Brain Google Gemini (@google/generative-ai) Blazing-fast LLM Engine (gemini-3.1-flash-lite) responsible for Natural Language Understanding and Tool Calling.
Tool Protocol MCP SDK v2.0 (@modelcontextprotocol/server) Defining and registering tools adhering to industry-standard protocols.
Chat Interface grammY (grammy) A robust Telegram Bot framework secured via an ALLOWED_USER_IDS whitelist.
Integrations Google APIs (googleapis) Native interaction with Gmail, Calendar, Sheets, Drive, and Docs.
Validation Zod (zod) Type-safe schema validation ensuring valid input data for MCP tools.
Runtime Node.js + TypeScript (tsx) Executing ES Modules natively without complex build steps.

🚀 How It Works (The Concept)

  1. User Request: You send a message via Telegram (e.g., "Find my free slots next week and schedule a team sync").
  2. Bot Middleware: The Telegram bot receives the message, validates your identity against the ALLOWED_USER_IDS whitelist, and forwards it to the AI Agent.
  3. Multi-Turn Tool Calling Loop:
    • Gemini deduces the intent and issues a function call to get_calendar_events.
    • The Agent executes the tool via the MCP Server registry.
    • The MCP Server authenticates with Google via OAuth tokens and makes the respective Google API request.
    • The calendar data is returned to Gemini.
    • Gemini analyzes the data, calls find_free_slots, and subsequently calls create_calendar_event to book the meeting.
  4. Final Response: The AI Agent synthesizes the results and sends a final, human-readable response back to you on Telegram.

📦 13 Built-in MCP Tools

This project abstracts complex Google APIs into 13 LLM-friendly MCP tools:

  • 📧 Gmail: get_unread_emails, search_emails, get_email_detail, draft_email, send_email.
  • 📅 Calendar: get_calendar_events, find_free_slots, create_calendar_event, update_calendar_event.
  • 📊 Sheets: read_sheet, append_sheet_row.
  • 📁 Drive/Docs: search_drive_files, read_doc_content.

⚙️ Setup Instructions

1. Prerequisites

  • Node.js 20+
  • A Google Cloud Project (with Gmail, Calendar, Sheets, Docs, and Drive APIs enabled).
  • OAuth 2.0 Client ID (configured as a Desktop Application).
  • Telegram Bot Token (obtained from @BotFather).
  • Gemini API Key.

2. Environment Configuration

Copy the environment template and fill in your details:

cp .env.example .env

Provide your OAuth Client credentials, Bot Token, Gemini API Key, and—most importantly—your ALLOWED_USER_IDS (your Telegram User ID to prevent unauthorized access).

3. Install Dependencies

npm install

4. Run the Project

npm run dev

During the initial startup, the system will open a browser window requesting Google account authorization. Your OAuth credentials will be securely saved locally in credentials/tokens.json.


📜 License

This project was built for educational and personal use. Please keep your .env and tokens.json files strictly confidential.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured