QCH-Hermes
Provides tools to search and retrieve Gmail messages from authenticated Gmail mailboxes, with support for multiple accounts and OAuth-based authorization.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@QCH-HermesFind emails from Jane in my work mailbox"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
QCH-Hermes Gmail Gateway
QCH-Hermes เป็น Gmail gateway แบบ self-hosted สำหรับเชื่อมต่อ Gmail หลาย mailbox ผ่าน OAuth แบบ explicit consent แล้วเปิดความสามารถอ่านอีเมลให้กับ web UI และ MCP client ผ่าน backend authorization boundary เดียวกัน
โปรเจคนี้ทำอะไร
เชื่อมต่อ Gmail ได้หลายบัญชี โดยให้แต่ละบัญชีอนุมัติ OAuth แยกกัน
ใช้ Gmail scope แบบ least privilege เริ่มต้นที่
gmail.readonlyเก็บ Gmail refresh token แบบเข้ารหัส AES-GCM ใน SQLite ฝั่ง server
ตรวจ session, mailbox ownership และสิทธิ์ก่อนอ่าน Gmail ทุกครั้ง
มี MCP JSON-RPC endpoint สำหรับ
gmail_searchและgmail_getบังคับให้ทุก Gmail MCP tool ระบุ
mailboxIdรองรับ disconnect/revoke mailbox
เสิร์ฟ web UI, API, OAuth และ MCP จาก single Docker container เดียว
โปรเจคนี้ยังเป็น gateway ขนาดเล็ก ไม่ใช่ Google Workspace Domain-Wide Delegation และไม่ได้ให้สิทธิ์อ่าน mailbox ของทั้งองค์กรโดยอัตโนมัติ แต่ละ mailbox ต้องได้รับ consent เอง เว้นแต่ภายหลังจะติดตั้ง Workspace Domain-Wide Delegation อย่างถูกต้องโดย Super Admin
Related MCP server: Gmail MCP Server (ArtyMcLabin fork)
Architecture
Browser ───────────────┐
│ same origin :3300
MCP client ── Bearer ──┤
▼
Bun + Elysia server
├── Web UI static files
├── OAuth/session boundary
├── Gmail gateway
└── MCP JSON-RPC /mcp
│
├── data/local.db
│ └── encrypted refresh tokens
└── Gmail APIRequirements
Docker Desktop with Docker Compose
Google Cloud project
Gmail API enabled
Google OAuth Web application client
OAuth redirect URI ที่ตรงกันทุกตัวอักษร
ไม่จำเป็นต้องติดตั้ง Bun เพื่อใช้งาน runtime แบบ Docker
Google OAuth setup
ใน Google Cloud Console:
Enable Gmail API
Configure OAuth consent screen
Create OAuth Client ID ประเภท Web application
เพิ่ม redirect URI:
http://localhost:3300/oauth/google/callbackถ้า OAuth app ยังอยู่ใน Testing ให้เพิ่ม Google accounts ที่จะใช้เป็น test users
Production ควรใช้ domain policy จริงและห้ามใช้ development bypass:
NODE_ENV=production
ALLOW_ANY_VERIFIED_GOOGLE_ACCOUNT=false
GOOGLE_ALLOWED_DOMAIN=company.exampleการอยู่ใน company domain อย่างเดียวไม่ถือเป็น authorization; ผู้ใช้แต่ละคนยังต้อง approve OAuth consent
Local Docker setup: single container
1. เตรียม environment
cp apps/server/.env.docker.example apps/server/.envแก้ค่าใน apps/server/.env:
GOOGLE_OAUTH_CLIENT_ID=...
GOOGLE_OAUTH_CLIENT_SECRET=...
GOOGLE_OAUTH_REDIRECT_URI=http://localhost:3300/oauth/google/callback
GOOGLE_ALLOWED_DOMAIN=company.example
TOKEN_ENCRYPTION_KEY=...
MCP_GATEWAY_KEY=...สร้าง random secrets ตัวอย่าง:
openssl rand -base64 32 | tr '+/' '-_' | tr -d '='
openssl rand -base64 48 | tr '+/' '-_' | tr -d '='development-only ถ้าต้องการทดสอบ Gmail ส่วนตัว:
NODE_ENV=development
ALLOW_ANY_VERIFIED_GOOGLE_ACCOUNT=trueห้ามใช้ค่านี้ใน production
ตั้ง permission ของไฟล์ลับ:
chmod 600 apps/server/.env2. เตรียม database
Docker Compose bind-mount database ที่:
./data:/datacontainer ใช้:
DATABASE_URL=file:/data/local.dbถ้ามีฐานข้อมูลเดิมที่ root project ให้ย้ายครั้งแรกแบบไม่ overwrite database ที่มีอยู่แล้ว:
mkdir -p data
test -e data/local.db || cp local.db data/local.db
chmod 700 data
chmod 600 data/local.db3. Build และ start
docker compose build
docker compose up -dSingle container นี้จะเปิด:
Web UI: http://localhost:3300
API: http://localhost:3300
OAuth start: http://localhost:3300/oauth/google/start
MCP: http://localhost:3300/mcpตรวจสถานะ:
docker compose ps
curl http://localhost:3300/healthzควรได้:
OKดู logs:
docker compose logs -f appหยุด container โดยรักษา database:
docker compose downอย่าใช้ docker compose down -v หากยังต้องการรักษาข้อมูล volume
เชื่อมต่อ Gmail
เปิด
http://localhost:3300กด เชื่อมต่อ Gmail
เลือก Google account ที่ต้องการ
ตรวจสอบ OAuth consent และ approve scope ที่ร้องขอ
ทำซ้ำสำหรับ mailbox อื่น
หลัง callback สำเร็จ mailbox จะปรากฏใน web UI
ระบบเก็บเฉพาะ metadata ที่จำเป็นและ encrypted refresh token ฝั่ง server ไม่ส่ง refresh token ไป browser หรือ MCP client
การ disconnect จะทำให้ mailbox ไม่สามารถถูกใช้ผ่าน session/MCP ต่อ และเปิดทางให้ OAuth ใหม่สำหรับ mailbox นั้น
Gmail credentials และ persistence
ใน SQLite ตาราง Mailbox จะเก็บ ciphertext และ IV ของ refresh token:
refreshTokenCiphertext
refreshTokenIv
grantedScopesTOKEN_ENCRYPTION_KEY อยู่นอก database และไม่อยู่ใน Docker image โดย Compose inject จาก apps/server/.env
ต้อง backup ทั้งสองอย่างแยกกัน:
data/local.dbTOKEN_ENCRYPTION_KEY
ถ้า database ยังอยู่แต่ encryption key หาย จะถอดรหัส refresh token เดิมไม่ได้
ห้ามเก็บ secret ใน:
frontend หรือ
localStorageURL หรือ query string
committed file
Dockerfile หรือ Docker image layer
logs
Customer deployment from Docker Hub
ลูกค้าไม่จำเป็นต้อง clone source code หรือ install Bun ลูกค้าสามารถ pull image จาก Docker Hub แล้วรัน container โดยตรงได้
Image:
hadesgod/qch-hermes-gmail-gateway:latestOption A: Docker Compose สำหรับลูกค้า
ดาวน์โหลดไฟล์ customer Compose และ environment template:
mkdir qch-hermes-gmail-gateway
cd qch-hermes-gmail-gateway
curl -fsSLO https://raw.githubusercontent.com/seenark/qch-hermes-gmail-gateway/main/docker-compose.customer.yml
curl -fsSLO https://raw.githubusercontent.com/seenark/qch-hermes-gmail-gateway/main/apps/server/.env.docker.example
mv .env.docker.example .env
mkdir -p dataแก้ .env ก่อนเริ่ม โดยใส่ Google OAuth credentials, encryption key และ MCP gateway key:
NODE_ENV=production
ALLOW_ANY_VERIFIED_GOOGLE_ACCOUNT=false
GOOGLE_OAUTH_CLIENT_ID=ลูกค้าใส่ค่าจริง
GOOGLE_OAUTH_CLIENT_SECRET=ลูกค้าใส่ค่าจริง
GOOGLE_OAUTH_REDIRECT_URI=https://gmail.example.com/oauth/google/callback
GOOGLE_ALLOWED_DOMAIN=customer.example.com
TOKEN_ENCRYPTION_KEY=สร้างค่า random ใหม่
MCP_GATEWAY_KEY=สร้างค่า random ใหม่ใน Google Cloud Console ต้อง register redirect URI เดียวกันแบบ exact match ตัวอย่างด้านบน
เริ่มระบบ:
docker compose -f docker-compose.customer.yml pull
docker compose -f docker-compose.customer.yml up -dตรวจสถานะ:
docker compose -f docker-compose.customer.yml ps
curl -fsS http://localhost:3300/healthzเปิด web UI ที่ http://localhost:3300 หรือ public HTTPS URL ของ reverse proxy
ถ้า deploy หลัง reverse proxy ให้ใช้ HTTPS public URL ที่ proxy ส่งต่อมายัง container port 3300 และตั้งค่าใน .env ให้ตรงกัน:
CORS_ORIGIN=https://gmail.example.com
GOOGLE_OAUTH_REDIRECT_URI=https://gmail.example.com/oauth/google/callbackOption B: Docker CLI โดยตรง
หากใช้ Docker CLI โดยไม่ใช้ Compose ให้ดาวน์โหลดและแก้ .env template ตามขั้นตอน OAuth ด้านบนก่อน แล้วใช้คำสั่งต่อไปนี้:
mkdir -p qch-hermes-data
docker pull hadesgod/qch-hermes-gmail-gateway:latest
docker run -d \\
--name qch-hermes-gmail-gateway \\
--restart unless-stopped \\
--env-file .env \\
-e DATABASE_URL=file:/data/local.db \\
-e PORT=3300 \\
-e WEB_DIST_DIR=/app/public \\
-p 3300:3300 \\
-v "$PWD/qch-hermes-data:/data" \\
hadesgod/qch-hermes-gmail-gateway:latestดู logs และหยุด container:
docker logs -f qch-hermes-gmail-gateway
docker stop qch-hermes-gmail-gatewayUpdating an existing customer deployment
Database อยู่ใน bind mount จึงไม่ควรถูกลบตอน update:
docker compose -f docker-compose.customer.yml pull
docker compose -f docker-compose.customer.yml up -dก่อน update ควร backup ทั้ง database และ encryption key:
cp data/local.db "data/local.db.backup.$(date +%Y%m%d%H%M%S)"
chmod 600 .envห้ามใช้ docker compose down -v และห้ามเปลี่ยน TOKEN_ENCRYPTION_KEY โดยไม่มีกระบวนการ key rotation ที่รองรับ เพราะ refresh token เดิมจะถอดรหัสไม่ได้
Customer operations
# logs
docker compose -f docker-compose.customer.yml logs -f app
# status
docker compose -f docker-compose.customer.yml ps
# stop without deleting data
docker compose -f docker-compose.customer.yml down
# start again
docker compose -f docker-compose.customer.yml up -dลูกค้าควรจำกัดสิทธิ์ของเครื่องที่เก็บ .env, data/local.db และ TOKEN_ENCRYPTION_KEY ผู้ใช้งาน MCP ไม่ควรได้รับค่า Google client secret, refresh token หรือ encryption key
MCP connection
MCP endpoint:
http://localhost:3300/mcpใช้ header:
Authorization: Bearer <MCP_GATEWAY_KEY>
Content-Type: application/jsonMCP methods ที่มี:
initializetools/listtools/callสำหรับgmail_searchtools/callสำหรับgmail_get
ทุก tool ต้องส่ง mailboxId ที่ได้จาก authenticated mailbox listing; ห้ามให้ MCP client ส่ง refresh token หรือ Google client secret
ตัวอย่าง shape ของ tool arguments:
{
"mailboxId": "mailbox-id-from-the-server",
"query": "newer_than:1d"
}สำหรับ gmail_get ให้ส่ง mailboxId และ messageId
Development without Docker
Docker เป็นวิธีรันหลักที่แนะนำ แต่ยังสามารถทำ development แยก process ได้:
bun install
bun run db:generate
bun run db:push
bun run devโหมดนี้ใช้ web dev server และ API แยก port ตาม environment ของโปรเจค ส่วนการใช้งานจริง local ให้ใช้ Docker Compose single container ตามขั้นตอนด้านบน
Verification commands
bun run lint
bun run check
bun run build
git diff --check
docker compose config --quiet
docker compose buildProject structure
apps/server/ Elysia API, OAuth, Gmail gateway, MCP
apps/web/ React/TanStack Router UI
packages/db/ Prisma schema and SQLite adapter
packages/env/ server/web environment validation
Dockerfile single-container build
docker-compose.yml runtime, bind mount, healthcheck
data/local.db ignored persistent SQLite databaseSecurity notes
ใช้ explicit OAuth consent ต่อ mailbox
ใช้ PKCE และ one-time OAuth state
ใช้ HTTP-only session cookie
ใช้ encrypted refresh token at rest
ใช้ exact-domain policy ใน production
development allow-any account ต้องไม่เปิดใน production
MCP ทุก operation ต้องผ่าน backend authorization
Google client secret, encryption key และ gateway key ต้องอยู่นอก Git และ image
License / public repository note
ก่อน push public ให้ตรวจว่าไม่มี .env, database, token, client secret หรือ generated credential อยู่ใน Git และตรวจ git status กับ secret scan ทุกครั้ง
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceStreamable HTTP MCP server for Gmail enabling search, read, draft management, and inbox organization.Last updated19ISC
- Alicense-qualityAmaintenanceLean Gmail MCP server with auto authentication, attachments, thread operations, filter management, and configurable OAuth scopes. Actively maintained fork of GongRzhe/Gmail-MCP-Server.Last updated334220MIT
- Flicense-qualityBmaintenanceA private, single-user MCP server that unifies Gmail, Microsoft 365/Outlook, and IMAP mailboxes for LLMs to search and read emails live, without storing or caching mailbox contents.Last updated
- Alicense-qualityBmaintenanceA local MCP server that provides Gmail tools (search, read, send, draft, label management) while keeping your emails only between your machine and Google, with no third-party access.Last updatedMIT
Related MCP Connectors
Read, search, send, organize, draft and schedule email across your inboxes from any MCP client.
Self-hosted federated MCP gateway: one OAuth 2.1 MCP server in front of N apps, user-level scopes.
Shipmail MCP server for AI agent custom-domain email inboxes with REST API and webhooks.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/seenark/qch-hermes-gmail-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server