mail-mcp-custom

mail-mcp-custom

Custom MCP server for Gmail integration, enabling email listing, reading, searching, and sending via natural language.

Category
访问服务器

README

mail-mcp-custom

Custom mail MCP server for local use with opencode, without Composio. The current provider is Gmail.

Project Map

  • src/server.ts: MCP stdio entry point for OpenCode and MCP tool registration
  • src/web.ts: local Express server for the browser UI and local /api/* routes
  • src/config.ts: environment configuration, OAuth settings, token path, UI path, and Gmail scopes
  • src/providers/gmail/oauth.ts: local Google OAuth browser flow
  • src/providers/gmail/token-store.ts: local OAuth token persistence
  • src/providers/gmail/gmail.ts: Gmail API client helpers
  • src/providers/llm/openai-compatible.ts: local OpenAI-compatible LLM client for email summaries
  • ui/: static browser UI served by src/web.ts
  • doc/: architecture notes and OpenCode configuration

Entry Points

  • MCP server for OpenCode: npm run dev
  • Local browser UI: npm run web
  • Type-check: npm run check
  • Build: npm run build

Documentation Maintenance

When code changes affect behavior, setup, commands, environment variables, MCP tools, web routes, security assumptions, or limitations, update the relevant docs in the same change. Check README.md, AGENTS.md, doc/architecture-diagram.md, doc/opencode-configuration.md, and .env.example before finishing.

Included Features

  • Local Google OAuth for a single user
  • Token persistence in data/gmail-token.json
  • Basic MCP tools:
    • list_emails
    • read_email
    • search_emails
    • send_email
  • Optional local web UI for listing, searching, reading, sending, and moving messages to Gmail Trash
  • Local AI summary for emails received today through an OpenAI-compatible endpoint

Capability Matrix

Capability MCP Tool Web UI/API
List messages list_emails GET /api/emails
Search messages search_emails GET /api/emails?query=
Read message read_email GET /api/emails/:id
Send message send_email POST /api/send
Move to trash Not exposed POST /api/emails/:id/trash
Summarize today's inbox Not exposed POST /api/summaries/today

Google Cloud Setup

  1. Create a project in Google Cloud.
  2. Enable the Gmail API.
  3. Configure the OAuth consent screen.
  4. Create an OAuth Client ID of type Web application.
  5. Add this redirect URI:
http://127.0.0.1:4010/oauth/callback

Local Setup

  1. Copy .env.example to .env.
  2. Fill in the Google OAuth values.
  3. Run:
npm install
npm run dev

On the first run, your browser opens for Google authentication.

Local Web UI

Run the browser UI with:

npm run web

Then open:

http://127.0.0.1:4020

The UI serves files from ui/ and exposes local-only API routes from src/web.ts.

Optional environment settings:

WEB_HOST=127.0.0.1
WEB_PORT=4020
UI_PATH=./ui

Trash actions move messages to Gmail Trash. They do not permanently delete mail.

Local AI Summaries

The web UI can summarize emails received today with a local OpenAI-compatible LLM. The browser calls src/web.ts, and the server calls the configured local LLM endpoint.

Default local LLM settings:

LOCAL_LLM_BASE_URL=http://127.0.0.1:1234/v1
LOCAL_LLM_API_KEY=local
LOCAL_LLM_MODEL=qwen/qwen3.5-9b
LOCAL_LLM_TIMEOUT_MS=180000
LOCAL_LLM_MAX_TOKENS=4096

The summary flow searches Gmail for today's inbox messages, reads each message, truncates long bodies, sends the summary prompt to the local LLM, and filters the visible message list to the summarized messages.

Initial Scopes

  • gmail.readonly
  • gmail.send
  • gmail.modify

gmail.modify is required for moving messages to Trash from the local web UI.

OpenCode Config

The OpenCode configuration for this project is documented separately in doc/opencode-configuration.md.

Current Limitations

  • Single local user only
  • Plain text email sending only
  • No attachments
  • Trash support only moves messages to Gmail Trash; permanent delete is not implemented
  • AI summaries currently support only the local_llm provider; OpenCode provider switching is planned but not wired yet
  • No custom refresh-token logic outside the Google client

推荐服务器

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

官方
精选