agentleFS
n24q02mn24q02m/email/CLAUDE.md

email

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

  • Other versions1 project uses a version of this.

    Word for word · 1

    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.

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
  1. Very specific:

    Import: import type rieng, .js extension bat buoc, node: prefix cho builtins

    line 80
  2. Very specific:

    Test files co-located: errors.test.ts canh errors.ts

    line 84

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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:fix

Cau 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-client

Env 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 (localhost accepted as host; per-account port)
  • http mode (opt-in via --http, MCP_TRANSPORT=http, or TRANSPORT_MODE=http): MCP_AUTH_MODE = multi | token | no-auth (transports/http.ts:resolveHttpAuth).
    • multi: hull users.toml (MCP_USERS_FILE, default ~/.hull/users.toml). Moi caller chi thay ~/.email/users/<namespace>/accounts.toml + tokens.json cua 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 cu EMAIL_MCP_TOKEN_HASH van doc; scrypt hash; mint with printf '%s' "$TOKEN" | email token hash, token read from stdin, never argv), MCP_RPM tuy chon. Creds: EMAIL_CREDENTIALS env; Outlook tokens ~/.email/tokens.json.
    • Khong mode + khong hash: no-auth chi tren loopback; bind non-loopback thi tu choi start. Self-host qua docker-compose.http.yml (volume /data, publish loopback 127.0.0.1:8082).
  • PORT (default 0 = OS-assigned random port), HOST (optional bind address)
  • OUTLOOK_CLIENT_ID -- tu chon, cho self-hosted OAuth2 client. CLI auth --client-id=<id> override env var (flag thang env, xem auth-cli.ts:parseArgs)
  • OUTLOOK_TENANT -- tu chon, tenant cho CA device-code LAN token refresh (oauth2.ts:getOutlookTenant). Default consumers (stdio/CLI) va common (http delegated, auth/outlook-device-code.ts). Work/school (Entra ID) can common hoac tenant GUID -- refresh token cua work/school danh vao /consumers se loi AADSTS7000012
  • OUTLOOK_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 vao OUTLOOK_DOMAINS de 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 type rieng, .js extension 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.ts canh errors.ts
  • noExplicitAny: off (email API responses dung any)

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.json duoc 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 (region ap-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 StdioServerTransport directly. Reads credentials from EMAIL_CREDENTIALS OR EMAIL_USER + EMAIL_APP_PASSWORD. Outlook accounts use an App Password in this mode.
  • http (opt-in, self-hosted): enabled via --http, MCP_TRANSPORT=http, or TRANSPORT_MODE=http. Auth mode token: one shared bearer token (MCP_AUTH_TOKEN_HASH / EMAIL_MCP_TOKEN_HASH), accounts from EMAIL_CREDENTIALS or email auth outlook <address>. Auth mode multi: several users from hull users.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)

  1. Config storage path: legacy config.enc from earlier releases lives in the platformdirs mcp config dir ($APPDATA\mcp\Config\config.enc on Windows). It is read through hull resolveConfig only; this server does not write it. When debugging, clear that path and ~/.email/tokens.json (plus the pre-rename ~/.better-email-mcp/tokens.json if the upgrade has not run yet) to reset state.
  2. Outlook token identity: resolved in the current source. saveOutlookTokens resolves the key in this order: token email, OUTLOOK_EMAIL, token sub, decoded id_token subject, then the deterministic outlook-device-code fallback. oauth2.test.ts covers each branch. Keep OUTLOOK_EMAIL as 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.