mcp-google-workspace-agent

mcp-google-workspace-agent

This MCP server enables natural language management of Google Calendar and Google Sheets, exposing tools for scheduling, updating, searching events, managing spreadsheets, and more. It uses an LLM to automatically select and chain tool calls based on user requests.

Category
访问服务器

README

Google Calendar-Sheet Assistant — Full Edition (MCP + LLM)

A complete Google Calendar assistant. Not just "create a meeting" — every common calendar task, exposed as an MCP tool, chosen automatically by an LLM based on what you type.

        User
         │
         ▼
"Move my 3 PM meeting to 5 PM"
         │
         ▼
   OpenAI / GPT-OSS-120B
         │
(Decides which tool(s) to call — can chain more than one)
         │
         ▼
   MCP Client (Python)          ← client.py
         │
 Calls tool(s) through MCP protocol
         │
         ▼
Google Calendar MCP Server       ← server.py  (14 tools)
         │
 Executes Google Calendar API    ← calendar_utils.py
         │
         ▼
     Google Calendar
         │
         ▼
Success / Event Details
         │
         ▼
        User

All supported tasks

Task Example prompt Tool used
Create event "Schedule a meeting tomorrow at 3 PM." schedule_event
Update event "Move my 3 PM meeting to 5 PM." search_events/list_events → update_event
Delete event "Cancel tomorrow's interview." search_events → cancel_event
List events "What are my meetings today?" daily_agenda
Search events "Find all AI meetings this month." search_events
Get event details "Show details of my client meeting." search_events → get_event
Check free/busy "Am I free between 2 PM and 4 PM?" check_freebusy
Daily agenda "What's on my schedule today?" daily_agenda
Weekly agenda "Show this week's calendar." weekly_agenda
Monthly agenda "Show my August meetings." monthly_agenda
Recurring events "Every Monday 10 AM team standup." schedule_event (with recurrence)
Invite attendees "Create meeting and invite abc@gmail.com." schedule_event (with attendees)
Add Google Meet link "Create an online meeting." schedule_event (with add_meet_link)
Set reminders "Remind me 30 minutes before." schedule_event/update_event (with reminder_minutes_before)
Add location "Meeting at Baner Office." schedule_event (with location)
Add description "Agenda: Sprint Planning." schedule_event (with description)
List calendars "Show all my calendars." list_calendars
Move event "Move this event to my Work calendar." move_event
Import events Bringing in an event from another system import_event
Watch calendar changes Trigger the agent on new events watch_calendar (needs a public webhook URL — see note below)

Project structure

google-calendar-sheet-mcp-/
├── server.py            # MCP server — 15 Calendar tools + 8 Sheets tools
├── client.py            # MCP client — LLM picks tool(s), can chain multiple calls
├── calendar_utils.py     # All Google Calendar API logic + OAuth (token.json)
├── sheets_utils.py        # All Google Sheets API logic + OAuth (token_sheets.json)
├── requirements.txt
├── .env.example
└── README.md

Setup

1. Google Cloud (one-time)

  1. Google Cloud Console → create/select a project.
  2. APIs & Services → Library → enable Google Calendar API AND Google Sheets API (search + enable both, same project).
  3. OAuth consent screen → External → add your email as a test user.
  4. Credentials → Create Credentials → OAuth client ID → Desktop app.
  5. Download JSON → rename to credentials.json → place next to server.py. (This one file is reused by both calendar_utils.py and sheets_utils.py.)

2. Install

cd AI-AGENT
python3 -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Configure

cp .env.example .env
# add GROQ_API_KEY (https://console.groq.com/keys)

4. Run

python3 client.py

First run opens a browser to authorize Calendar access (saves token.json). The first time you ask it to do anything with Sheets, a second browser prompt appears — authorizing Sheets access separately (saves token_sheets.json). This is expected: Calendar and Sheets are different permissions, so they get separate consent + separate token files, even though both use the same credentials.json app identity.

Google Sheets — setup notes & example prompts

Every Sheets tool needs a spreadsheet_id — the long string in a sheet's URL, between /d/ and /edit:

https://docs.google.com/spreadsheets/d/1AbCdEfGhIjKlMnOpQrStUvWxYz/edit
                                        └──────── this part ────────┘

Example prompts:

  • "Create a new spreadsheet called 'Q3 Leads'." → create_spreadsheet
  • "In spreadsheet [id], what's in Sheet1 rows 1 to 10?" → read_sheet
  • "Add a row to spreadsheet [id]: Priya, priya@email.com, Contacted" → append_sheet_row
  • "Overwrite A1:B2 in [id] with these values..." → write_sheet
  • "What tabs does spreadsheet [id] have?" → list_sheet_tabs
  • "Add a new tab called 'August' to [id]." → add_sheet_tab
  • "Clear rows 2 to 50 in Sheet1 of [id]." → clear_sheet_range
  • "Give me the title and link for spreadsheet [id]." → get_spreadsheet_info

Sharing note: the Google account you authorized with (whichever one created token_sheets.json) needs edit access to any spreadsheet you ask it to read/write — either it owns the sheet, or someone shared it with that account.

How multi-step requests work

Some tasks need more than one tool call — e.g. "Move my 3 PM meeting to 5 PM" requires first finding the event (no id was given), then updating it. client.py handles this with a loop: it keeps letting the LLM call tools back-to-back (find → then act) until the LLM has enough information to give you a final plain-language answer. You'll see each intermediate tool call printed, e.g.:

You: Move my 3 PM meeting to 5 PM
[client] LLM chose tool: search_events({'query': '3 PM'})
[client] LLM chose tool: update_event({'event_id': 'abc123', 'start_time': '...', 'end_time': '...'})

Assistant: Done — moved your meeting to 5:00–5:30 PM today.

Recurring events — how RRULE works

schedule_event's recurrence argument takes standard iCalendar RRULE strings. The LLM constructs these automatically, but for reference:

  • Every Monday: RRULE:FREQ=WEEKLY;BYDAY=MO
  • Every weekday: RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
  • Every day for 10 occurrences: RRULE:FREQ=DAILY;COUNT=10
  • Every month on the 1st: RRULE:FREQ=MONTHLY;BYMONTHDAY=1

Watch calendar changes — important note

watch_calendar sets up Google push notifications, but Google will only send them to a public HTTPS URL you control — not localhost. For local development:

  1. Run a tiny webhook receiver (Flask/FastAPI) that logs/handles the POST Google sends on changes.
  2. Expose it publicly with a tunnel tool (e.g. ngrok http 8000).
  3. Call watch_calendar with that public https://...ngrok.../webhook URL.
  4. The subscription expires (Google enforces a max TTL, typically up to ~7 days) — re-run watch_calendar periodically (e.g. a daily cron job) to keep it alive.

This part is the most "production infrastructure"-heavy feature here — the other 13 tools work immediately with no extra hosting required.

Testing the server alone (no LLM)

npx @modelcontextprotocol/inspector python3 server.py

Lets you call any of the 14 tools directly from a browser UI to confirm the Calendar integration works before wiring up chat.

Troubleshooting

Problem Fix
FileNotFoundError: credentials.json not found Complete Google Cloud setup step 1–5
invalid_grant / token errors Delete token.json, re-run to re-authorize
LLM never calls a tool Check OPENAI_API_KEY in .env
Update/cancel says "event not found" The LLM needs the real event_id — make sure it searched/listed first
Wrong timezone on events Set CALENDAR_TIMEZONE in .env
Recurring event didn't repeat as expected Double check the RRULE the LLM generated — ask it to explain the rule if unsure

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选