CLAUDE.md38 starsChanged 8 months agoApache-2.0View on GitHub
Ten repo/npm/image: n24q02m/email / @n24q02m/email / n24q02m/email (truoc day la better-email-mcp). CON GIU ten cu co chu dich: bin alias better-email-mcp, data dir ~/.email (PerPluginStore slug email + Outlook tokens.json; store cu ~/.better-email-mcp duoc copy sang luc startup), config namespace better-email-mcp (legacy config.enc doc qua hull resolveConfig), skret path /better-email-mcp/prod. Registry id la io.github.n24q02m/email; entry cu io.github.n24q02m/better-email-mcp dong bang ten do (registry version immutable). MCP Server cho Email (IMAP/SMTP). TypeScript, Node.js >= 24, bun, ESM. 4 composite tools (messages, folders,…
1 other project uses a version of this.
Adopted by
Most recently taken up by
- n24q02m/better-email-mcpword for word, first seen Mar 8, 2026
Other versions1 project uses a version of this.
Word for word · 1
- n24q02m/better-email-mcp★ 38100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- follow-upSkill
- inbox-reviewSkill
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 80
Import: import type rieng, .js extension bat buoc, node: prefix cho builtins
- Very specific: line 84
Test files co-located: errors.test.ts canh errors.ts
≈ “Common” is an estimate: at least 1 in 5 of the 28,029 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md - email
Ten repo/npm/image: n24q02m/email / @n24q02m/email / n24q02m/email (truoc day la better-email-mcp). CON GIU ten cu co chu dich: bin alias better-email-mcp, data dir ~/.email (PerPluginStore slug email + Outlook tokens.json; store cu ~/.better-email-mcp duoc copy sang luc startup), config namespace better-email-mcp (legacy config.enc doc qua hull resolveConfig), skret path /better-email-mcp/prod. Registry id la io.github.n24q02m/email; entry cu io.github.n24q02m/better-email-mcp dong bang ten do (registry version immutable).
MCP Server cho Email (IMAP/SMTP). TypeScript, Node.js >= 24, bun, ESM. 4 composite tools (messages, folders, attachments, config; outbound new/reply/forward under messages) plus help. Multi-account, App Passwords, auto-discovery.
Commands
# Setup
bun install
# Lint & Type check
bun run check # biome check + tsc --noEmit
bun run type-check # tsc --noEmit only
# Fix
bun run check:fix # biome fix + type check
# Test
bun run test # vitest (--passWithNoTests)
bun run test:watch # vitest watch
bun run test:coverage # vitest --coverage
bun vitest run src/tools/helpers/errors.test.ts # single file
# Build & Dev
bun run build # tsc --build tsconfig.build.json + esbuild CLI
bun run dev # tsx watch dev server
# Docker
bun run docker:build
bun run docker:run
# Mise shortcuts
mise run setup # full dev setup
mise run lint # bun run check
mise run test # bun run test
mise run fix # bun run check:fixCau truc thu muc
src/
init-server.ts # Entry point, env validation
credential-state.ts # Single-user / stdio credential resolution from env
auth/ # Outlook device-code OAuth (`email auth outlook <address>`)
outlook-device-code.ts # Microsoft device-code OAuth flow
transports/
http.ts # HTTP transport: hull runHttpServer, auth mode multi (users.toml, per-namespace accounts) / token (MCP_AUTH_TOKEN_HASH) / no-auth (loopback)
tenant.ts # Caller namespace for HTTP multi mode: per-user data dir + namespaced cache keys
docs/ # Markdown docs phuc vu qua MCP resources
tools/
registry.ts # Tool registration + routing
composite/ # Public domains: messages, folders, attachments, config; internal outbound helper: send.ts
helpers/ # errors, config, html-utils, imap-client, smtp-clientEnv vars
- stdio mode (default):
EMAIL_CREDENTIALS(bat buoc). Format:user@gmail.com:app-password- Multi-account:
user1@gmail.com:pass1,user2@outlook.com:pass2 - Custom IMAP host:
user@custom.com:password:imap.custom.com - Custom IMAP host + port:
user@custom.com:password:imap.custom.com:1993 - Local IMAP proxy:
user@custom.com:password:localhost:1993(localhostaccepted as host; per-account port)
- Multi-account:
- http mode (opt-in via
--http,MCP_TRANSPORT=http, orTRANSPORT_MODE=http):MCP_AUTH_MODE=multi|token|no-auth(transports/http.ts:resolveHttpAuth).multi: hullusers.toml(MCP_USERS_FILE, default~/.hull/users.toml). Moi caller chi thay~/.email/users/<namespace>/accounts.toml+tokens.jsoncua minh; accounts server-wide KHONG BAO GIO duoc phuc vu. Provision host-side:email auth outlook <address> --user <namespace>.token:MCP_AUTH_TOKEN_HASH(ten cuEMAIL_MCP_TOKEN_HASHvan doc; scrypt hash; mint withprintf '%s' "$TOKEN" | email token hash, token read from stdin, never argv),MCP_RPMtuy chon. Creds:EMAIL_CREDENTIALSenv; Outlook tokens~/.email/tokens.json.- Khong mode + khong hash:
no-authchi tren loopback; bind non-loopback thi tu choi start. Self-host quadocker-compose.http.yml(volume/data, publish loopback127.0.0.1:8082).
PORT(default0= OS-assigned random port),HOST(optional bind address)OUTLOOK_CLIENT_ID-- tu chon, cho self-hosted OAuth2 client. CLIauth --client-id=<id>override env var (flag thang env, xemauth-cli.ts:parseArgs)OUTLOOK_TENANT-- tu chon, tenant cho CA device-code LAN token refresh (oauth2.ts:getOutlookTenant). Defaultconsumers(stdio/CLI) vacommon(http delegated,auth/outlook-device-code.ts). Work/school (Entra ID) cancommonhoac tenant GUID -- refresh token cua work/school danh vao/consumersse loiAADSTS7000012OUTLOOK_SCOPES-- tu chon, danh sach scope cach nhau bang space (oauth2.ts:getOutlookScopes). Dung khi grant duoc consent hep hon default (vd IMAP-only, khong SMTP)OUTLOOK_EXTRA_DOMAINS-- tu chon, domain cach nhau bang dau phay, gop them vaoOUTLOOK_DOMAINSde mailbox M365 tren custom domain di duong OAuth thay vi doi password
Code conventions
- Biome: 2 spaces, 120 line width, single quotes, semicolons as needed, trailing commas none
- Import:
import typerieng,.jsextension bat buoc,node:prefix cho builtins - tsconfig:
strict: true, target es2021, module es2022, moduleResolution Bundler - Error:
EmailMCPError+withErrorHandling()HOF.enhanceError()+suggestFixes(). - Error details duoc sanitize de tranh lo secrets/passwords.
- Test files co-located:
errors.test.tscanherrors.ts noExplicitAny: off (email API responses dungany)
CD Pipeline
PSR v10 (workflow_dispatch) -> npm + Docker (amd64+arm64) + GHCR + MCP Registry.
Luu y
- Outlook/Hotmail/Live dung OAuth2 tu dong (Device Code flow). Token luu tai
~/.email/tokens.json; file cu~/.better-email-mcp/tokens.jsonduoc copy sang luc startup. - Gmail, Yahoo, iCloud: dung App Passwords, KHONG phai password thuong.
- Account resolution: filter theo email, id, hoac partial match.
- Composite tool signature:
async function toolName(accounts: AccountConfig[], input: TypedInput): Promise<any> - 3-tier token optimization: Tier 1 (compact), Tier 2 (help tool), Tier 3 (MCP Resources).
- Pre-commit: biome check --write, tsc --noEmit, bun run test.
- Secrets: skret SSM namespace
/better-email-mcp/prod(regionap-southeast-1)
Modes
Two transports, selected in init-server.ts:52-53. There is no MCP_MODE env var; the old remote-relay / local-relay distinction was removed (see transports/http.ts:5).
- stdio (default): MCP SDK
StdioServerTransportdirectly. Reads credentials fromEMAIL_CREDENTIALSOREMAIL_USER+EMAIL_APP_PASSWORD. Outlook accounts use an App Password in this mode. - http (opt-in, self-hosted): enabled via
--http,MCP_TRANSPORT=http, orTRANSPORT_MODE=http. Auth modetoken: one shared bearer token (MCP_AUTH_TOKEN_HASH/EMAIL_MCP_TOKEN_HASH), accounts fromEMAIL_CREDENTIALSoremail auth outlook <address>. Auth modemulti: several users from hullusers.toml, accounts resolved per tool call for the caller's namespace (registerTools(server, [], { resolveAccounts: loadCallerConfig })). There is no relay form. The project no longer operates a public n24q02m HTTP deployment.
Known bugs (phat hien 2026-04-18 E2E)
- Config storage path: legacy
config.encfrom earlier releases lives in the platformdirsmcpconfig dir ($APPDATA\mcp\Config\config.encon Windows). It is read through hullresolveConfigonly; this server does not write it. When debugging, clear that path and~/.email/tokens.json(plus the pre-rename~/.better-email-mcp/tokens.jsonif the upgrade has not run yet) to reset state. - Outlook token identity: resolved in the current source.
saveOutlookTokensresolves the key in this order: tokenemail,OUTLOOK_EMAIL, tokensub, decodedid_tokensubject, then the deterministicoutlook-device-codefallback.oauth2.test.tscovers each branch. KeepOUTLOOK_EMAILas an explicit workaround only when the provider response has no usable identity claim; do not treat the old "long-term fix" note as open work.
Tests
- Unit and integration:
bun run test(vitest). The full suite runs in GitHub Actions. - Live protocol checks:
tests/live/(manual; needs real provider credentials).
The mcp-core e2e matrix and relay-form drivers were removed with the relay; this repo has no T2 relay-form configs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

