Skip to main content
Glama
davsdevelop

DAVS Gmail MCP Server

by davsdevelop

📧 Gmail AI 助手与模型上下文协议(MCP)

本项目实现了一个能够直接与 Gmail 账户交互的智能助手,利用模型上下文协议(Model Context Protocol,MCP)

它展示了本地 LLM(Ollama)与外部 API(Google Workspace)的安全集成,使模型能够读取、摘要和发送邮件,并通过动态模板消费静态资源(PDF),全部在标准化的客户端-服务器架构下运行。

🏗️ 系统架构

  • MCP 服务器(gmail_mcp_server.py): 向客户端暴露工具(Tools)、静态和动态资源(Resources / Resource Templates)以及预定义提示词。处理与 Google Cloud 的 OAuth2 认证。

  • MCP 客户端(client.py): 连接到 MCP 服务器,发现可用能力,并动态格式化,使语言模型(Llama 3.1)能够将其用作函数调用(Function Calling)

  • 图形界面(app.py): 使用 Streamlit 构建的交互式应用程序,管理对话历史,根据服务器响应渲染动态 UI 组件,并支持快速提示词的使用。

  • 安全性: 严格的凭据管理。认证在本地完成,会话令牌保持在运行时环境中,不对外暴露。

✨ 代理能力

  • 工具(Tools): list_emails(搜索和过滤)和 send_email(撰写和发送)。

  • 资源(Resources): 访问用户的 Gmail 个人资料。

  • 模板(Resource Templates): 从本地 PDF 手册中读取并注入上下文(例如 docs://setup-manual/{version})直接进入 LLM 上下文。

  • 提示词(Prompts): 预构建的流程,用于每日摘要和专业邮件撰写。

🚀 安装与配置

前置条件

  • Python 3.10+

  • 已安装 Ollama 并带有 llama3.1 模型。

  • 一个 Google Cloud Platform(GCP)账户。

1. Google 凭据配置(必填)

出于安全原因,本仓库不包含访问凭据。你必须生成自己的凭据:

  1. 前往 Google Cloud Console

  2. 创建新项目并启用 Gmail API

  3. 配置 OAuth 同意屏幕(将你的邮箱添加为测试用户)。

  4. 创建 OAuth 客户端 ID 类型的凭据(桌面应用程序)。

  5. 下载 JSON 文件,将其重命名为 credentials.json,并放置在本项目的根目录中。

2. 环境运行

# Clonar repositorio
git clone [https://github.com/tu-usuario/gmail-mcp-server.git](https://github.com/tu-usuario/gmail-mcp-server.git)
cd gmail-mcp-server

# Crear entorno virtual e instalar dependencias
python -m venv venv
source venv/bin/activate  # En Windows: venv\Scripts\activate
pip install -r requirements.txt

# Iniciar la interfaz gráfica
streamlit run app.py
-
license - not tested
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • StremAI MCP: shared memory for AI coding agents. Connected agents can recall. OAuth + local stdio.

  • Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…

  • AI-powered medical document management for cancer patients. Google Drive, Gmail, Calendar via MCP.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/davsdevelop/DAVS-gmail-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server