lanmail
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
lanmail
A file mailbox for AI agents and scripts: an MCP server (stdio), a CLI and a wake server over a plain folder. Any MCP client (Claude Code, Cursor, Codex) and any language can use it, and mail survives restarts.
One folder per box, one file per message, readable by humans and by any language.
Atomic delivery and exactly-once reads, even with several readers (Windows included).
ccand multi-recipient sends, threads, replies, read receipts, expiry, attachments by reference, relays.A wake watcher that turns bursts of mail into one wake per agent, under rules that stop ping-pong.
One shared wake server per mail root, started on demand and restarted if it dies.
Claude Code hooks: mark a session busy while it works, hand it new mail when it stops.
Built with Effect 4.
Install
npx lanmail --help # or: pnpm dlx lanmail --help
npm i -g lanmail # puts `lanmail` on PATHNode 20 or newer.
Related MCP server: Zoho Mail MCP
Where the mail lives, and who you are
Setting | First of | Default |
Root (folder of boxes) |
|
|
Your box |
| none (needed to read, wait or send) |
A box is a stable name such as bob or lane-a, never a session id: 1–64 characters (letters, digits, ., _,
-) starting with a letter or digit.
Opting a project in. Put .lanmail.json in the project (it is found from any subfolder):
{ "root": "../lanes/mail", "box": "lane-a" }A relative root is resolved against the file's folder. Every project that names the same root shares that root's
one wake server. With no root named (the ~/.lanmail default), nothing runs in the background: watch watches
its own box in-process.
CLI
lanmail send bob "build #12 is up" --subject "build 12" --thread release
lanmail send lane-a,lane-b "rule change" --cc bob # one message, a copy in every box
echo "long text" | lanmail send bob - # text from stdin
lanmail send bob "slot1 is yours" --urgent --expires 10m --receipt
lanmail send bob "trace attached" --attach trace.json,shot.png
lanmail reply <id> "on it" # to reply_to (or the sender), same thread, reference chain; --all copies everyone
lanmail forward <id> phat # relay unchanged, adding a "received" line
lanmail read # new mail, clean view, filed under read/
lanmail peek # new mail, left unread
lanmail ls # one line per unread message
lanmail show <id> # one message with every header
lanmail history -n 5 # the last 5 filed messages (after a lost wake, say)
lanmail boxes # every box: unread count, oldest unread's age, expired count
lanmail wait --timeout 60 # block until mail arrives; exit 2 on timeout
lanmail tail [--keep] # every new message as it arrives, no wake rules
lanmail watch [--json] # wakes, by the wake rules (below)
lanmail serve # the shared wake server (watch starts it for you)
lanmail server status
lanmail mcp # the MCP server on stdio
lanmail hook prompt | hook stop # Claude Code hooksread, peek, history, wait, tail and watch show a clean view by default: one summary line (id,
sender, subject, and only the flags that matter) and the text. --full or show <id> prints every header. Most
commands take --json.
MCP tools
Tool | Arguments | Does |
|
| Send from your box; returns the id and any warnings |
|
| Reply in the same thread |
|
| Relay a message to other boxes |
| New mail (clean view), filed | |
| New mail, left unread | |
|
| One message with every header |
|
| Already-read mail |
| Boxes with unread counts | |
|
| Block until mail arrives, then return and file it |
The agent gives only what it knows; the tool fills id, from, at and the origin trace.
Claude Code
claude mcp add lanmail --env LANMAIL_BOX=lane-a --env LANMAIL_ROOT=/path/to/mail -- npx -y lanmail mcpOr in .mcp.json:
{
"mcpServers": {
"lanmail": {
"command": "npx",
"args": ["-y", "lanmail", "mcp"],
"env": { "LANMAIL_BOX": "lane-a", "LANMAIL_ROOT": "/path/to/mail" }
}
}
}Cursor
~/.cursor/mcp.json (or .cursor/mcp.json in a project) takes the same mcpServers block.
Codex
~/.codex/config.toml:
[mcp_servers.lanmail]
command = "npx"
args = ["-y", "lanmail", "mcp"]
env = { LANMAIL_BOX = "lane-a", LANMAIL_ROOT = "/path/to/mail" }On Windows, if a client can't start npx directly, use "command": "cmd", "args": ["/c", "npx", "-y", "lanmail", "mcp"].
Claude Code hooks
{
"env": { "LANMAIL_BOX": "lane-a", "LANMAIL_ROOT": "/path/to/mail" },
"hooks": {
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "npx -y lanmail hook prompt" }] }],
"Stop": [{ "hooks": [{ "type": "command", "command": "npx -y lanmail hook stop" }] }]
}
}hook promptmarks the box busy, so the watcher never interrupts a turn, and records the session id, transcript and turn count for the origin trace.hook stophands over new mail: it files it and prints{"decision": "block", "reason": "<the mail>"}, so the session handles it without a separate turn. It blocks at most 3 times in a row (LANMAIL_STOP_BLOCKS); after that it lets the session stop and leaves the mail to the watcher. With no mail it marks the box idle, then checks once more for mail that landed meanwhile.
Waking agents
lanmail watch prints one wake per burst of mail, with the mail in it, for a Monitor or any script that turns
output lines into turns. --json gives one object per wake on one line.
Rule | Behaviour | Default |
1. Burst | Wake once no new mail has arrived for the quiet time, never later than the cap | 3 s quiet, 30 s cap |
2. Busy | A busy box (between | 10 min |
3. Size | Messages in full up to a cap (filed); the rest stay unread ("N more, read your box") | 10 messages, 8,000 chars |
4. Urgent |
| |
5. Ping-pong |
| 4 per 60 s |
6. Repeats | Each message is claimed once, so nothing is delivered twice | |
7. Gap | At least this long between wakes for one box | 15 s |
One watcher per box: a second watch on the same box is refused (tail --keep gives a read-only view). A crashed
watcher's lock is taken over at once on the same machine, or after 90 s without a heartbeat elsewhere. send warns
when the recipient has shown no sign of life (no hooks, no watcher) for 10 minutes.
The shared server. For a named root, watch subscribes to that root's one wake server (lanmail serve),
starting it if needed. The server watches the whole root once and applies the rules centrally (the pair limit sees every
box). It listens on a named pipe (Windows) or Unix socket derived from the root, writes <root>/.server, and exits 5
minutes after its last subscriber leaves. If it dies, watchers restart it; if it can't start, they watch their own box
directly.
Variable | Default |
| 3000 / 30000 |
| 15000 |
| 4 / 60000 |
| 10 / 8000 |
| 600000 |
| 30000 / 90000 |
| 600000 |
| 3 |
| 500 |
| 300000 |
| never start a server |
The server takes its settings from the environment of the watcher that started it.
LAN mail (off by default)
Mail boxes on other machines as box@node. Each machine runs one node (the wake server of its root); nodes talk over
plain HTTP, but every message is signed (Ed25519) and sealed (X25519 + HKDF + ChaCha20-Poly1305) for one paired node.
lanmail lan enable --alias pc # on each machine (prints the firewall rule on Windows)
lanmail lan nearby # machines heard on the LAN
lanmail lan pair mac # on pc (or by address: lan pair 192.168.1.20): prints a 6-digit code and waits
lanmail lan pending # on mac: shows pc with the same code
lanmail lan accept pc # on mac: "same on pc? [y/N]" (Match and click)
lanmail send lane@mac "build is up" # queued in <root>/.lan/outbox/mac, delivered by pc's node
lanmail lan status # peers, outbox countsMail from an unpaired node is refused and never stored. The sender's outbox retries (2 s doubling to 5 min, jittered) and bounces back to the sender after 3 days, or at the message's own
expires.Only a person pairs: no MCP tool pairs, and
acceptneeds a terminal or--yes --i-am-human.Received mail shows
from bob@pcand[remote], with areceived:line andlan_verified:(the checked key).Only loopback, private, link-local and tailnet addresses may connect. Identity keys live outside the root (
%APPDATA%/lanmailor~/.config/lanmail, orLANMAIL_IDENTITY_DIR).Discovery: nodes announce alias, port and key fingerprint (never box names) on multicast 239.255.77.77, UDP 53320, every 60 s.
lan nearbylists them andlan pair <name>uses the address it heard; signed announcements let a paired machine that changed IP be followed. Where multicast is blocked (guest Wi-Fi, VPN), pair by address.lan doctorchecks the node, the port, interfaces, discovery, each peer, and prints the firewall commands.
Folder format
Other tools can read and write the folder directly:
<root>/
.server the wake server's pid and heartbeat, while one runs
<box>/
<id>.md new mail
<id>.md.tmp being written: ignore
read/<id>.md filed mail
expired/<id>.md mail that expired before anyone read it
.state .session .watch.lock .stop-blocks small JSON files for hooks and watchersA message file is key: value header lines, one blank line, then the text (UTF-8):
id: 20261128T004905123Z-01a3f9c2-bob
from: bob
to: lane-a, lane-b
cc: phat
at: 2026-11-28T00:49:05.123Z
subject: slot1 is yours
thread: slots
priority: urgent
receipt: read
expires: 2026-11-28T01:00:00.000Z
attach: 9f86d081884c7d65... 1024 /path/to/trace.json
origin-via: claude-code via lanmail-cli/0.1.0
origin-host: build-pc
origin-repo: https://github.com/you/game
The text, any length, any lines.Field | Filled by | Meaning |
| tool | File name without |
| tool | Sender box, ISO 8601 time |
| sender | Comma-separated boxes; each gets its own copy |
| sender | Wake/list line; the text's first line when absent |
| sender | Groups related messages |
| tool on reply | The message replied to; the chain, oldest first, space-separated |
| sender | Where replies and receipts go instead of |
| sender |
|
| sender |
|
| sender |
|
| sender | Read after this, the message goes to |
| tool |
|
| tool on relay |
|
| tool | When it was filed |
| tool | Where it was sent from: |
Unknown header keys are ignored. Files with only from and at also parse: id then comes from the file name and
to from the folder.
To send: write
<box>/<id>.md.tmp, then rename it to<box>/<id>.md(in every recipient's box).To read: create
<box>/read/<id>.mdexclusively (O_CREAT|O_EXCL; give up if it exists), then rename<box>/<id>.mdover it. Exactly one reader wins. A plain rename is not enough on Windows, where two renames of the same file can both succeed. An empty placeholder older than 30 s whose message is still in the box was left by a crashed reader and can be taken over.
Library
import { Mailbox, MailConfig, Presence, WakeHub, watch } from "lanmail"Everything is an Effect service (Mailbox, Presence, Origin, WakeHub, Host). Provide the Node
platform once, as src/bin.ts does: NodeServices.layer, NodeCrypto.layerDigest and the Node Host layer.
Development
pnpm install
pnpm test # unit tests: in-memory files and TestClock, no real waiting (~3 s)
pnpm test:all # unit + integration: real files, child processes, the wake server (~30 s)
pnpm check # tsc with Effect diagnostics as errors + scripts/effect-gate.ts + unit tests
pnpm check:all # the same with integration tests (prepublishOnly and CI)
bash scripts/demo.shThe code follows the Effect rules in AGENTS.md; scripts/effect-gate.ts enforces what the type checker
can't see, and counts // effect-ok: escapes (there are none).
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Shared memory and mail for your AI agents. Verified with Claude Code; other MCP clients in testing.
Your agent needs a mailbox of its own — to receive, thread, draft and send, with attachments, without borrowing your personal inbox or your company's SMTP. **What you can ask for** • "Create an inbox for this agent and tell me its address." • "Read the new messages in this thread and draft a reply." • "Send this message with the attachment and wait for the response." • "Search this inbox for everything from that domain." • "Show delivery metrics and the events on this inbox." **How to use it** Point any MCP client at https://mcp.aisa.one/mail/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: create and delete inboxes, list and read messages, raw message bodies, attachments, threads, drafts and draft attachments, send and reply, message search, inbox events, metrics, and list entries — reads and writes. **Why this rather than the source** A real inbox an agent owns, rather than an SMTP credential it borrows from a human. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Find the contact elsewhere in the catalogue, then write to them from here — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/sales/mcp finds the person to write to.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables coding agents such as Codex and Claude Code to exchange durable, locally stored messages through shared MCP tools for listing enrolled recipients, sending and replying to messages, reading pending inbox items, acknowledging receipt, and checking message status. Delivery uses each runtime's native session interface, so messages persist across broker restarts without resuming or launching conversations.AGPL 3.0
- AlicenseBqualityBmaintenanceEnables AI agents to read, search, send, and organize mail, folders, messages, and threads through a local MCP server. It supports multiple data centers, attachments, and secure credential storage.334MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to exchange end-to-end encrypted, threaded email-style messages across tools, vendors, and machines through a zero-install remote MCP server. Supports sending, replying, reading, and threading messages with inbox checks, read receipts, and key verification.MIT
- AlicenseNot gradedqualityCmaintenanceEnables software agents to read and manage their own mailboxes, inspect inbound messages, and request outbound email that remains pending until an owner approves it. Exposes these agent mail operations as remote MCP tools alongside a REST API.MIT