mcp-email-server
AGENTS.md348 starsChanged 4 months agoBSD-3-ClauseView on GitHub
mcp-email-server is a Python MCP server that connects MCP clients to email accounts through IMAP and SMTP. Canonical repository: Primary repository areas: The revised Local Email App architecture under spec/ is the normative target currently being implemented. MCP stdio provides bounded mail workflows; CLI and the embedded loopback-only React UI provide the managed management plane. SQLite owns managed configuration and a rebuildable metadata projection. On Linux and Windows, its private managed_secret table is the default SecretStore; macOS uses the operating-system…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
25 rules. About 2 are common, 16 are distinctive, and 7 are very specific to this project.
≈2
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 28
Use uv for dependency management and command execution.
- Distinctive: line 29
Follow the existing typed, asynchronous Python style.
- Very specific: line 30
Prefer explicit types and isinstance checks over dynamic attribute checks.
- Distinctive: line 31
Use Pydantic models for configuration and structured responses.
- Distinctive: line 32
Keep MCP-facing descriptions accurate because clients derive tool schemas from them.
- Common: line 34
Treat credential storage, allowlists, attachment paths, and HTTP transport settings as security-sensitive behavior.
- Common: line 35
Do not log, document, or commit real email credentials, API keys, message contents, or tokens.
- Distinctive: line 65
Before completing a change, run:
- Distinctive: line 91
Every code change must include a review and corresponding update of the relevant documentation in the same change.
- Distinctive: line 98
Keep README.md limited to the quickest supported configuration path and links to the full documentation.
- Very specific: line 99
Update CONTRIBUTING.md when contributor or release workflows change.
- Very specific: line 100
Run make docs-test after changing code or documentation that can affect published docs.
- Very specific: line 107
Keep spec/ outside the MkDocs navigation.
- Distinctive: line 110
Write specs in English Markdown and use Mermaid for architecture, sequence, state, flow, and ER diagrams.
- Distinctive: line 115
Update the owning spec before or with architecture, workflow, persistence, interface, or security-boundary changes.
- Distinctive: line 116
Keep unresolved product decisions explicit in the owning spec rather than hiding them in implementation plans.
- Distinctive: line 117
Do not describe an accepted target as shipped behavior.
- Distinctive: line 127
Before using it, read the installed AnyCap skill and verify the locally installed CLI and authentication:
- Very specific: line 146
Keep platform differences behind a small typed filesystem-security compatibility layer.
- Distinctive: line 163
Add or update tests for every behavior change and regression fix.
- Distinctive: line 164
Keep unit tests deterministic and independent of live IMAP, SMTP, or keyring services.
- Very specific: line 165
Run make test-e2e for changes to IMAP, SMTP, MCP stdio, configuration loading, attachment handling, or mailbox mutations.
- Distinctive: line 167
When changing configuration, test TOML loading, supported environment overrides, persistence, and migration behavior as applicable.
- Distinctive: line 168
When changing MCP tools, test the complete catalog snapshot (names, descriptions, input/output schemas, annotations, resources, and …
- Distinctive: line 175
Keep related files synchronized:
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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
Repository Overview
mcp-email-server is a Python MCP server that connects MCP clients to email
accounts through IMAP and SMTP.
Canonical repository:
- HTTPS:
https://github.com/Wh1isper/mcp-email-server - SSH:
git@github.com:Wh1isper/mcp-email-server.git
Primary repository areas:
mcp_email_server/app.py— FastMCP server, resources, tools, and tool visibility.mcp_email_server/cli.py— stdio, SSE, Streamable HTTP, UI, reset, and credential migration commands.mcp_email_server/config.py— TOML settings, environment composition, account models, and persistence.mcp_email_server/keyring_store.py— operating system keyring integration.mcp_email_server/emails/— IMAP and SMTP behavior and response models.mcp_email_server/ui.py/ the replacement Web UI package — the local loopback management adapter and packaged static assets.frontend/— React/TypeScript management UI source and locked maintainer build.plugins/,.agents/, and.claude-plugin/— optional Codex/Claude Code plugin packaging, shared local MCP launch metadata, and safe non-secret setup guidance.tests/— unit, contract, integration, security, and browser-facing tests.docs/— user documentation published with MkDocs.spec/— unpublished normative architecture and product contracts kept as flat numbered documents.
Project Conventions
- Support Python 3.11 and later.
- Use
uvfor dependency management and command execution. - Follow the existing typed, asynchronous Python style.
- Prefer explicit types and
isinstancechecks over dynamic attribute checks. - Use Pydantic models for configuration and structured responses.
- Keep MCP-facing descriptions accurate because clients derive tool schemas from them.
- Preserve the distinction between persistent TOML settings and the environment-composited runtime view.
- Treat credential storage, allowlists, attachment paths, and HTTP transport settings as security-sensitive behavior.
- Do not log, document, or commit real email credentials, API keys, message contents, or tokens.
Current Architecture Direction
The revised Local Email App architecture under spec/ is the normative target
currently being implemented. MCP stdio provides bounded mail workflows; CLI and
the embedded loopback-only React UI provide the managed management plane.
SQLite owns managed configuration and a rebuildable metadata projection. On
Linux and Windows, its private managed_secret table is the default
SecretStore; macOS uses the operating-system keyring. Application
services resolve only the selected account/role secret immediately before
provider construction. Legacy TOML/environment/keyring behavior remains an
explicit compatibility mode and import source, but MCP exposes no account or
credential management in either mode. Historical add_email_account is removed. The optional Codex/Claude plugin
launches the current published mail-only stdio server through a shared .mcp.json;
its semver is independent from the Python application, while its skill hands
account and credential setup to interactive CLI/UI without receiving secrets.
Attachment compatibility preserves the caller's exact destination behind
explicit policy and filesystem defenses.
Centralized limits apply to application and serialized results. MCP Apps, remote
UI, daemon, multi-user, hard purge, and cloud-service design remain out of scope.
Development Workflow
Install the environment and pre-commit hooks:
make installBefore completing a change, run:
make check
make test
make docs-testDuring development, focused checks are encouraged, but the full relevant suite must pass before a change is considered complete.
Useful commands:
| Command | Description |
uv run mcp-email-server stdio | Run the local stdio MCP server. |
uv run mcp-email-server ui | Open the account configuration UI. |
make check | Run lockfile, formatting, lint, type, and dependency checks. |
make test | Run the test suite with coverage. |
make docs-test | Build the MkDocs site in strict mode. |
make docs | Serve the documentation locally. |
Documentation Requirements
Code and documentation must remain aligned.
- Every code change must include a review and corresponding update of the relevant documentation in the same change.
- User-visible behavior changes must always update the appropriate page under
docs/; internal changes must still keep docstrings and developer guidance accurate. - Configuration fields or environment variables require updates to
docs/configuration.mdand, when security-sensitive,docs/security.md. - CLI commands, arguments, transport defaults, or HTTP security behavior require updates to
docs/transports.md. - Local management UI behavior also requires review of
docs/getting-started.md,docs/configuration.md,docs/security.md, anddocs/troubleshooting.md; route/session/header changes always updatedocs/security.md. - MCP tool names, parameters, responses, visibility, or workflows require updates to
docs/tools.md. - New special cases and operational caveats belong in
docs/guides.mdordocs/troubleshooting.md. - Keep
README.mdlimited to the quickest supported configuration path and links to the full documentation. - Update
CONTRIBUTING.mdwhen contributor or release workflows change. - Run
make docs-testafter changing code or documentation that can affect published docs.
Specification Requirements
spec/ is the repository's workspace for architecture and product design before
those decisions become stable implementation or published user behavior.
- Keep
spec/outside the MkDocs navigation; published, implemented behavior belongs underdocs/. - Maintain
spec/README.mdas the global spec map and keep the current proposal's numbered documents directly underspec/. - Name detailed documents
NN-topic.mdand order them from system context and boundaries toward workflows, data design, and interfaces. - Write specs in English Markdown and use Mermaid for architecture, sequence, state, flow, and ER diagrams.
spec/README.mdis the sole navigation map; detailed specs do not containPrevious/Nextnavigation or per-document status metadata.- Give every normative contract one owning domain spec and cross-reference that owner instead of duplicating the contract.
- End every detailed domain spec with explicit acceptance criteria.
- Centralize implementation/test/docs traceability and delivery gates in
spec/12-delivery-validation-and-evolution.md; do not place implementation-status claims or evidence diaries in each domain spec. - Update the owning spec before or with architecture, workflow, persistence, interface, or security-boundary changes.
- Keep unresolved product decisions explicit in the owning spec rather than hiding them in implementation plans.
- Do not describe an accepted target as shipped behavior. Treat the complete proposal as delivered only when all domain acceptance criteria and the centralized delivery matrix are complete and published docs match.
The current Local Email App specification starts at spec/README.md. Continue
design discussions by updating the owning numbered document and its centralized
map/verification references.
AnyCap
This project uses AnyCap for web research, web crawling, multimodal generation and understanding, file sharing, and static page hosting. Before using it, read the installed AnyCap skill and verify the locally installed CLI and authentication:
anycap statusSubmit a bug or feature request when a capability fails or is missing:
anycap feedback --type bug -m "describe the issue" --request-id <id>
anycap feedback --type feature -m "describe the use case"Windows Compatibility and Filesystem Security
- Windows is a first-class supported platform. New runtime, CLI, UI, persistence, attachment, spill, packaging, and documentation changes must preserve Windows compatibility rather than assume POSIX APIs.
- Keep platform differences behind a small typed filesystem-security compatibility
layer. Application/domain code stays platform-neutral; do not scatter Win32,
fcntl, UID, mode-bit, or no-follow branches through business workflows. - POSIX retains owner/mode, directory-descriptor, no-follow, identity, and
fcntlguarantees. Windows uses local fixed NTFS, handle-bound reparse/identity checks, protected DACLs, hardenedLockFileExlocking, and write-through same-volume replacement. Never restore a weaker path-based fallback. - Any filesystem-security change requires native
windows-latestcoverage on real NTFS for applicable symlink/junction, ACL/owner, hard-link, lock, concurrent replacement, crash cleanup, and atomic-write behavior; mocks alone are not proof. - Explicitly document unsupported Windows storage such as direct volume-root targets, UNC/network paths, device namespaces, alternate data streams, and non-NTFS volumes, and fail before provider, authority, or secret-store effects.
Testing Expectations
- Add or update tests for every behavior change and regression fix.
- Keep unit tests deterministic and independent of live IMAP, SMTP, or keyring services.
- Run
make test-e2efor changes to IMAP, SMTP, MCP stdio, configuration loading, attachment handling, or mailbox mutations. This uses synthetic accounts on a loopback-only GreenMail container, and CI runs it once on the default Python version. - Cover both successful operations and security or failure boundaries.
- When changing configuration, test TOML loading, supported environment overrides, persistence, and migration behavior as applicable.
- When changing MCP tools, test the complete catalog snapshot (names, descriptions, input/output schemas, annotations, resources, and visibility), responses, limits, and account-specific error paths.
- Web UI changes require frontend lint/typecheck/unit coverage, backend route/auth/Host/Origin/CSRF/bootstrap-replay security tests, real-browser E2E for critical flows, and shutdown checks.
- Frontend/package changes require sdist/wheel inventory checks, a wheel rebuilt from the sdist without Node, isolated-install UI smoke, and packaged-asset drift checks.
- Agent integration changes require Codex/Claude Code installation fixtures, canonical-content drift tests, version-mismatch handling, and scenarios proving credentials are handed to user-operated CLI/UI rather than chat or MCP.
Repository Change Checklist
Keep related files synchronized:
- Dependency changes:
pyproject.tomlanduv.lock. - Public configuration changes: implementation, tests, and
docs/configuration.md. - Credential or access-control changes: implementation, tests,
docs/security.md, and troubleshooting guidance. - MCP surface changes:
mcp_email_server/app.py, tests, anddocs/tools.md. - CLI or transport changes:
mcp_email_server/cli.py, tests, anddocs/transports.md. - Agent integration changes: canonical
SKILL.md, shared.mcp.json, minimal vendor manifests/staged copies, independent plugin/application versioning, install/update/remove fixtures, security scenarios, and integration documentation. - Frontend dependency changes:
frontend/package.json, its lockfile, notices, source/build checks, and staged packaged assets. - Web UI route/session/security changes: backend tests, browser tests, and
docs/security.mdplus affected setup/troubleshooting docs. - Packaged asset changes: explicit sdist/wheel content assertions and Node-free from-sdist verification.
- Frontend maintainers own generated-asset synchronization: keep temporary
frontend/dist/ignored, but commitmcp_email_server/web_ui/static/andfrontend/embedded-assets.jsonaftermake frontend; release builds must not be the first place these assets are generated. - Architecture, workflow, persistence, interface, or security-boundary changes: the single owning file under
spec/, centralized delivery traceability, tests, and relevant published docs when implemented. - Quick-start changes:
README.md,docs/getting-started.md, andmkdocs.ymlwhen navigation changes.
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.

