LM

linuxrrze/mcp-mail-oauth

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

0 stars 0 forks 质量 55 趋势 8

一个MCP服务器,允许AI助手在接受OAuth令牌(XOAUTH2 / OAUTHBEARER)的IMAP/SMTP服务器上读取并发送该代码,使用:无需额外授权步骤,无需存储密码,且......

概览

一个MCP服务器,允许AI助手在接受OAuth令牌(XOAUTH2 / OAUTHBEARER)的IMAP/SMTP服务器上读取并发送该命令,使用:无需额外授权步骤,无需存储密码,服务器上无需每个用户状态。 为 Open WebUI + Keycloak + Dovecot/Postfix 构建。服务器支持两种版本的凭据,显示给邮件服务器。其他所有内容,包括 Open WebUI、Dovecot 和 Postfix 配置,都是相同的。详情、决策表和 Keycloak 布局如下: 。 1. 用户用Keycloak登录Open WebUI。2. Open WebUI的MCP认证类型转发该用户的访问令牌。3. MCP-mail-oauth验证该令牌(签名、发行者、受众MCP-mail、每个工具范围),并从邮件申领中获取邮箱名称。4. 它登录Dovecot/Postfix。Dovecot通过内省对照Keycloak(活跃、受众鸽子、范围邮件)进行检查。 两个Keycloak客户端:Open WebUI和dovecot。 步骤1到3是一样的。

概述(AI 翻译)

一个MCP服务器,允许AI助手读取并发送已登录用户的 在接受OAuth XOAUTH2令牌的IMAP/SMTP服务器上发送邮件 OAUTHBEARER),使用用户现有登录:无额外授权 STEP,没有存储密码,服务器上没有每个用户的状态。

为Open WebUI + Keycloak + Dovecot/Postfix构建。服务器支持两个 它向邮件服务器展示的凭据变体。其他所有内容, 包括开放WebUI、Dovecot和Postfix配置,都是相同的。 详情、决策图表和钥匙隐形图布局: docs/mail-credential.md。

转发令牌(默认,MAIL_TOKEN_EXCHANGE=off)

  1. 用户通过Keycloak登录Open WebUI。
  2. Open WebUI 的 MCP 认证类型 “OAuth” 转发该用户的访问令牌。
  3. mcp-mail-oAuth 验证(签名、发行人、受众 mcp-mail, 每个工具的示波器)并从其 email 声明中取自邮箱名称。
  4. 它用相同的令牌登录Dovecot/Postfix。Dovecot通过以下方式检查 对钥隐斗的内省(活跃、观众dovecot、范围mail)。

两个Keycloak客户端:Open WebUI和dovecot。

代币交换 (MAIL_TOKEN_EXCHANGE=on)

步骤1到3是一样的。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

mcp-mail-oauth

An MCP server that lets an AI assistant read and send the signed-in user’s own mail on an IMAP/SMTP server that accepts OAuth tokens (XOAUTH2 / OAUTHBEARER), using the user’s existing login: no extra authorization step, no stored passwords, no per-user state on the server.

Built for Open WebUI + Keycloak + Dovecot/Postfix. The server supports two variants for the credential it presents to the mail server. Everything else, including the Open WebUI, Dovecot and Postfix configuration, is identical. Details, a decision chart and the Keycloak layouts: docs/mail-credential.md.

Forwarded token (default, MAIL_TOKEN_EXCHANGE=off)

sequenceDiagram
    actor U as User
    participant OW as Open WebUI
    participant KC as Keycloak
    participant MCP as mcp-mail-oauth
    participant MS as Dovecot / Postfix

    U->>OW: Log in
    OW->>KC: OIDC login (client openwebui)
    KC-->>OW: Access tokenaud: mcp-mail, dovecotscope: mail, mcp:mail/*

    U->>OW: "Show my newest mails"
    OW->>MCP: MCP tool callAuthorization: Bearer (user's token)
    Note over MCP: Verifies signature, issuer,audience mcp-mail and tool scope.Mailbox = token's email claim
    MCP->>MS: IMAP / SMTP login,XOAUTH2 with the same token
    MS->>KC: Introspect token (as client dovecot)
    KC-->>MS: active, email, scope mail
    MS-->>MCP: Mailbox data
    MCP-->>OW: Tool result
    OW-->>U: Answer

    Note over OW,KC: Before the token expires, Open WebUIrefreshes it with its refresh token
  1. The user logs in to Open WebUI with Keycloak.
  2. Open WebUI’s MCP auth type “OAuth” forwards that user’s access token.
  3. mcp-mail-oauth verifies it (signature, issuer, audience mcp-mail, per-tool scope) and takes the mailbox name from its email claim.
  4. It logs in to Dovecot/Postfix with the same token. Dovecot checks it by introspection against Keycloak (active, audience dovecot, scope mail).

Two Keycloak clients: Open WebUI’s and dovecot.

Token exchange (MAIL_TOKEN_EXCHANGE=on)

sequenceDiagram
    participant OW as Open WebUI
    participant KC as Keycloak
    participant MCP as mcp-mail-oauth
    participant MS as Dovecot / Postfix

    OW->>KC: OIDC login (client openwebui)
    KC-->>OW: Token Aaud: mcp-mail only, no mail scope
    OW->>MCP: Tool call, Bearer token A
    Note over MCP: Same checks as above
    MCP->>KC: RFC 8693 exchange as client mcp-mail:token A for audience dovecot
    KC-->>MCP: Token B (aud dovecot, scope mail),cached until shortly before expiry
    MCP->>MS: IMAP / SMTP login with token B
    MS->>KC: Introspect token B (as client dovecot)
    KC-->>MS: active, email, scope mail
    MS-->>MCP: Mailbox data
    MCP-->>OW: Tool result

Steps 1 to 3 are the same. In step 4 the server presents a separate token that Keycloak issued to it for the mail server. Token A alone is refused by

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →