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.
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:
- 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.
- 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)
- User Request: You send a message via Telegram (e.g., "Find my free slots next week and schedule a team sync").
- Bot Middleware: The Telegram bot receives the message, validates your identity against the
ALLOWED_USER_IDSwhitelist, and forwards it to the AI Agent. - 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 callscreate_calendar_eventto book the meeting.
- Gemini deduces the intent and issues a function call to
- 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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。