邮件日历优化服务器

VibeMCP是一款针对Gmail和Microsoft 365的令牌优化统一MCP服务器,通过TOON格式显著减少令牌使用量,提供邮件、日历和联系人的统一管理。

  • by VibeTensor
  • TypeScript
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 VibeTensor/vibemcp

使用说明

VibeMCP

Token-Optimized Unified MCP Server for Gmail & Microsoft 365

One server. Two ecosystems. Half the tokens.

Documentation · Getting Started · Tools Reference


问题

大多数电子邮件和日历MCP服务器返回冗长的JSON,浪费令牌:

[
  {"id": "abc123", "subject": "Meeting Tomorrow", "from": "john@example.com", "date": "2025-12-18", "snippet": "Let's meet at 3pm..."},
  {"id": "def456", "subject": "Q4 Report", "from": "jane@example.com", "date": "2025-12-17", "snippet": "Please review the..."}
]

约85个代币 2条消息。重复按键("id", "subject", "from", "date")吃每一排的代币。

解决方案

VibeMCP使用 TOON(面向令牌的对象表示法),一种开放格式,声明一次模式,然后将数据作为制表符分隔的行流式传输:

messages[2]{id,subject,from,date,snippet}
abc123	Meeting Tomorrow	john@example.com	2025-12-18	Let's meet at 3pm...
def456	Q4 Report	jane@example.com	2025-12-17	Please review the...

约38个代币 对于相同的数据。没有重复的键,没有括号,没有引号。

每个工具都支持这两种功能 toon 和 json 通过输出 format 参数。


基准测试

2026年2月,在实时Gmail和Outlook帐户上测量:

数据集 TOON JSON 节省
Gmail-10条消息 591 961 38%
Outlook-10封邮件 872 1480 41%
谷歌日历-11个活动 441 1462 70%
组合的 1,904 3,903 51%

日历事件显示节省了70%,因为原始的Google日历API响应具有深度嵌套的对象(start.dateTime, attendees[].email, organizer.email)VibeMCP的服务层在TOON编码之前变平为原始值。

Cost impact at Claude Opus pricing ($15/M input tokens)
使用情况 年度代币节省 年度成本节省
10次通话/天 730万代币 $109
50次通话/天 3650万代币 $547
200次通话/天 1.46亿代币 $2,190

快速开始

1.添加到您的MCP客户端

克劳德代码 (~/.claude.json):

{
  "mcpServers": {
    "vibemcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "vibemcp"]
    }
  }
}

2.配置凭据

通过您的MCP客户端传递凭据 env 块:

{
  "mcpServers": {
    "vibemcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "vibemcp"],
      "env": {
        "GOOGLE_CLIENT_ID": "your-google-client-id",
        "GOOGLE_CLIENT_SECRET": "your-google-client-secret",
        "MICROSOFT_CLIENT_ID": "your-azure-client-id",
        "MICROSOFT_TENANT_ID": "common"
      }
    }
  }
}

或者创建一个 .env 文件在您的工作目录或 ~/.vibemcp/.env.

请参阅 配置指南 用于Google Cloud和Azure设置。

3.身份验证

通过您的AI助手:

> Add my Google account     → opens browser for OAuth
> Add my Microsoft account  → prints device code for microsoft.com/devicelogin

或者通过CLI:

npx vibemcp auth google your@gmail.com
npx vibemcp auth microsoft your@outlook.com

4.使用

> Show my latest emails
messages[10]{id,subject,from,date,snippet}
19485abc  Team standup notes  alice@company.com  2026-02-16  Here are the notes...
28ef9d01  Invoice #4521       billing@vendor.com 2026-02-15  Your invoice for...

每个工具都支持 format: "json" 用于标准JSON输出。


工具

51工具 跨越7个模块:

账户管理(7)

工具 说明
list_accounts 列出所有具有身份验证状态的已连接帐户
add_google_account 启动Google OAuth流(基于浏览器)
complete_google_auth 完成谷歌身份验证
add_microsoft_account 启动Microsoft设备代码流
complete_microsoft_auth 完成Microsoft身份验证
remove_account 删除已连接的帐户
accounts_status 检查身份验证状态和服务器配置

Gmail(16)

工具 说明
gmail_list_messages 使用Gmail搜索运营商列出/搜索邮件
gmail_get_message 获取包含正文和附件的完整邮件内容
gmail_send_message 发送符合RFC 2822标准的电子邮件
gmail_reply_to_message 使用正确的螺纹进行回复(回复/参考)
gmail_create_draft 创建电子邮件草稿
gmail_list_labels 列出所有Gmail标签
gmail_list_threads 列出电子邮件线程
gmail_get_thread 获取包含所有消息的完整帖子
gmail_create_label 创建新的Gmail标签
gmail_update_label 更新标签名称或可见性设置
gmail_delete_label 删除用户创建的标签
gmail_modify_labels 在特定邮件中添加或删除标签
gmail_download_attachment 下载包含元数据的附件
gmail_batch_modify 批量存档、已读、未读、垃圾或未跟踪邮件
gmail_get_vacation 获取当前外出自动回复设置
gmail_set_vacation 启用或禁用带日期范围的外出

展望(16)

工具 说明
outlook_list_messages 使用文件夹筛选列出邮件
outlook_get_message 获取完整消息内容
outlook_send_message 通过Microsoft Graph发送电子邮件
outlook_reply_to_message 回复消息
outlook_forward_message 转发消息
outlook_list_folders 列出邮件文件夹
outlook_move_message 在文件夹之间移动邮件
outlook_search 通过Microsoft Graph搜索邮件
outlook_list_categories 列出可用的Outlook类别
outlook_set_categories 在邮件上设置类别
outlook_set_flag 在消息上设置跟进标志
outlook_batch_update 批量标记已读/未读、存档或移动邮件
outlook_download_attachment 按ID下载附件
outlook_list_attachments 列出邮件中的附件
outlook_get_auto_reply 获取当前自动回复(OOO)设置
outlook_set_auto_reply 配置自动回复计划

日历(6)

工具 说明
calendar_list_calendars 列出日历(谷歌或Outlook,自动检测)
calendar_list_events 列出时间范围内的事件
calendar_create_event 创建具有可选重复性的事件(RRULE)
calendar_update_event 更新事件(谷歌和微软)
calendar_delete_event 删除事件
calendar_free_busy 查看日历的忙/闲可用性

联系人(3)

工具 说明
contact_search 按姓名或电子邮件搜索联系人
resolve_contacts 解析电子邮件地址以显示姓名
contact_list 列出来自Google或Microsoft帐户的联系人

统一/跨账户(3)

工具 说明
unified_search 同时搜索所有电子邮件帐户
unified_inbox 聚合来自所有帐户的未读邮件
unified_calendar 跨所有提供程序的合并日历视图

与其他MCP服务器的比较

功能 VibeMCP gmail mcp ms-365-mcp服务器 google_workspace_mcp
Gmail 16个工具 60多个工具 - 80多个工具
Outlook Mail 16个工具 - 90+个工具 -
谷歌日历 包括6个工具 - -
Outlook日历 6个工具 - 包括 -
联系人 包括3个工具 - -
统一(两个提供商) 是 否 否 否
TOON输出 是 否 否 否
多账户 本土的 否 否 手册
跨账户搜索 是 否 否 否
令牌优化 平均51% 无 无 无

现有的TOON MCP服务器(如 toon-mcp)是通用的JSON到TOON转换器。VibeMCP在源代码级别进行编码,为每种数据类型选择最佳字段。


TOON格式

TOON(面向令牌的对象表示法)将结构化数据编码为标题+制表符分隔的行:

typeName[count]{field1,field2,field3}
value1a	value1b	value1c
value2a	value2b	value2c
  • 头球 typeName[count]{fields} 声明一次架构
  • 行 是制表符分隔的值,每行一个,没有重复的键

对于单个对象,TOON使用键值格式:

message:
  id: msg001
  subject: Meeting Tomorrow
  from: john@example.com

为什么TOON比JSON更适合LLM:

  1. 没有重复的按键 -JSON重复 "subject", "from", "date" 对于每一件物品。TOON在标头中声明一次字段。
  2. 无语法噪声 -没有 {, }, [, ], ", , 使用令牌的字符。
  3. 自描述模式 -The [count]{fields} 头告诉LLM期望什么,从而提高解析的准确性。
  4. JSON回退 -每个工具都接受 format: "json" 用于调试或下游处理。

看 TOON.md 有关嵌套对象处理、模式演化和MCP客户端兼容性的详细文档。


建筑

src/
  index.ts                # MCP server entry point (StdioServerTransport)
  cli.ts                  # CLI for auth management
  config.ts               # Environment, account registry, scopes
  auth/
    google.ts             # Google OAuth2 with local callback server (port 4100)
    microsoft.ts          # Microsoft MSAL Device Code Flow
    store.ts              # Token file I/O helpers
  services/
    gmail.ts              # Gmail API service (googleapis)
    ms-mail.ts            # Microsoft Graph Mail (native fetch)
    google-calendar.ts    # Google Calendar API service
    ms-calendar.ts        # Microsoft Graph Calendar (native fetch)
    google-contacts.ts    # Google People API for contact resolution
    ms-contacts.ts        # Microsoft Graph People/Contacts
    cache.ts              # Service instance cache (10-min TTL)
  tools/
    admin.ts              # Account management tools (7)
    gmail.ts              # Gmail tool handlers (16)
    outlook.ts            # Outlook tool handlers (16)
    calendar.ts           # Unified calendar tools (6)
    contacts.ts           # Contact search and resolution (3)
    unified.ts            # Cross-account aggregation (3)
  toon/
    encoder.ts            # TOON serialization (encodeToon, formatOutput)
    types.ts              # ToonOptions interface
  utils/
    logger.ts             # stderr-safe logging (protects JSON-RPC stdout)
    errors.ts             # Error categories and formatting

关键设计决策:

  • ~/.vibemcp/ 配置目录 -存储在持久用户目录中的令牌、帐户和STROCACH(~/.vibemcp/),与软件包安装位置无关。可通过 VIBEMCP_CONFIG_DIR 有人是。
  • 默认值=MCP服务器 -跑步 vibemcp (或 npx vibemcp)无参数启动MCP stdio服务器。CLI子命令(auth, accounts)手柄设置。
  • stderr安全日志记录 - console.log 重定向到 console.error 在导入时,保持MCP JSON-RPC的stdout干净
  • 静态工厂模式 -服务使用 ServiceClass.create(email) 因为身份验证初始化是异步的
  • 提供商自动检测 -日历工具检查帐户注册表以路由到正确的服务
  • 服务缓存(10分钟TTL) -缓存经过身份验证的实例,以避免重复获取令牌

身份验证设置

Google OAuth Setup
  1. 首选 谷歌云控制台
  2. 创建新的OAuth 2.0客户端ID(桌面应用程序)
  3. 添加 http://localhost:4100/code 作为授权重定向URI
  4. 启用Gmail API和Google日历API
  5. 将客户端ID和客户端密码复制到您的 .env

要求的范围:

  • openid + userinfo.email (身份)
  • https://mail.google.com/ (完全访问Gmail)
  • https://www.googleapis.com/auth/calendar (日历读/写)
Microsoft Auth Setup
  1. 首选 Azure门户>应用程序注册
  2. 注册新应用程序(任何名称)
  3. 将“支持的帐户类型”设置为“仅限Microsoft个人帐户”或“所有帐户类型”
  4. 在身份验证下,启用“允许公共客户端流”(设备代码所需)
  5. 将应用程序(客户端)ID复制到您的 .env

要求的范围:

  • Mail.ReadWrite, Mail.Send (电子邮件)
  • Calendars.ReadWrite (日历)
  • User.Read (个人资料)

个人帐户(hotmail/outlook/live)会自动排除Teams范围。


发展

npm install          # Install dependencies
npx tsc --noEmit     # Type check
npm run build        # Build
npm run dev          # Dev mode (auto-reload)
npm test             # Run tests (149 tests)
npm run lint         # ESLint check
npm run format       # Prettier format
node dist/index.js   # Run directly

码头工人

docker build -t vibemcp .
docker run --env-file .env vibemcp

路线图

v0.1-基础

  • [x] 带有TOON输出的Gmail(8个工具)
  • [x] 带有TOON输出的Outlook Mail(8个工具)
  • [x] 谷歌日历(4个工具)
  • [x] Outlook日历(5个工具)
  • [x] 多帐户身份验证(谷歌OAuth+微软设备代码)
  • [x] 统一的跨帐户工具(搜索、收件箱、日历)
  • [x] 用于帐户管理的CLI
  • [x] 发表于 npm

v0.2-波兰语(当前)

  • [x] 附件处理(Gmail和Outlook下载)
  • [x] 谷歌日历事件更新
  • [x] Gmail标签管理(创建、更新、删除、应用于邮件)
  • [x] 电子邮件批处理操作(存档、标记已读/未读、Gmail垃圾桶;标记已读或未读、存档、Outlook移动)
  • [x] Outlook类别和后续标记
  • [x] 测试套件(8个套件中的149个测试)
  • [x] ESLint+预处理配置
  • [x] Docker支持

v0.3-扩展(当前)

  • [x] 通过Google People API和Microsoft Graph解析联系人姓名
  • [x] 日历忙/闲查找(谷歌 freebusy.query,图形 getSchedule)
  • [x] 重复事件支持(RRULE模式用于创建)
  • [x] 外出和自动回复状态(Gmail假期、Outlook自动回复)
  • []Slack集成
  • []Todoist集成
  • []语义缓存层
  • []速率限制

v1.0-生产

  • []托管OAuth(无需用户GCP/Azure设置)
  • []团队聊天集成
  • []谷歌云端硬盘/OneDrive
  • []企业SSO

贡献

我们欢迎捐款!看 贡献.md 作为指导方针。

高优先级领域:

  • 单元和集成测试
  • 新的服务模块(Slack、Todoist、Discord)
  • TOON编码器改进
  • 文档和使用示例

隐私和安全

VibeMCP是 完全自托管你的数据永远不会离开你的机器。

保证 详细信息
无遥测 没有分析,没有电话回家,没有数据发送给VibeTensor或第三方
没有托管OAuth 您可以创建自己的Google Cloud项目和Azure应用程序注册
本地令牌存储 OAuth令牌存储为本地JSON文件,从不传输
无数据保留 仅通过-按需从API获取,不存储任何内容
你拥有一切 您的凭据、数据、基础设施

看 隐私.md 了解完整细节和 安全.md 安全政策。


故障排除

问题 解决方案
“未连接帐户” 运行 list_accounts 检查。验证至少一个帐户。
Google OAuth失败 确保 http://localhost:4100/code 是一个授权的重定向URI。启用Gmail+日历API。
Microsoft设备代码过期 代码持续约15分钟。跑 add_microsoft_account 再次需要一个新的代码。
AADSTS错误 在Azure门户>应用程序注册>身份验证中启用“允许公共客户端流”。
令牌文件问题 删除 ~/.vibemcp/.oauth2.{email}.json 并重新进行身份验证。

完整的故障排除指南: vibemcp.vibetensor.com/guide/getting-started


参考文献


免责声明

这个项目是 与谷歌或微软没有关联、没有谷歌或微软的认可或赞助.

Gmail、Google日历和Google Cloud是Google LLC的商标。Microsoft 365、Outlook、Azure和Microsoft Graph是Microsoft Corporation的商标。VibeMCP根据各自的服务条款使用这些服务的公共API。

用户有责任创建自己的API证书并遵守 谷歌API ToS, 谷歌API用户数据政策,以及 微软API ToU.


赞助商

VibeMCP可供个人免费使用。如果您或您的组织从中受益,请考虑赞助以支持持续发展。


许可证

PolyForm非商业版1.0.0 - VibeTensor私人有限公司

免费供个人使用、研究、教育、爱好项目和非商业组织使用。商业使用需要VibeTensor的单独许可证。


Built by VibeTensor, a DPIIT-recognized AI startup from India
Website · GitHub · LinkedIn