agent-letterbox-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_letterbox_mcp-0.1.0/.gitignore +9 -0
- agent_letterbox_mcp-0.1.0/CHANGELOG.md +10 -0
- agent_letterbox_mcp-0.1.0/LICENSE +21 -0
- agent_letterbox_mcp-0.1.0/PKG-INFO +220 -0
- agent_letterbox_mcp-0.1.0/README.md +177 -0
- agent_letterbox_mcp-0.1.0/pyproject.toml +46 -0
- agent_letterbox_mcp-0.1.0/server.json +21 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/__init__.py +3 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/__main__.py +41 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/cli.py +111 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/constants.py +61 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/deadline.py +29 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/errors.py +44 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/ids.py +35 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/mailbox.py +496 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/render.py +61 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/schemas.py +197 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/send.py +57 -0
- agent_letterbox_mcp-0.1.0/src/letterbox_mcp/server.py +526 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
- Introduce the stdio MCP door with header-only mailbox checking, individual letter reading, a letter resource, and CLI-backed send, reply and file tools.
|
|
6
|
+
- Require a pinned CLI and registered identity; confine replies to the intended participant and inbox, and keep relay correspondence with its bridge. Handle repeated acknowledgements using the durable reply.
|
|
7
|
+
- Validate letter identifiers, timestamps, metadata and resource URIs; reject unsafe or duplicate frontmatter, avoid echoing unvalidated input, and bound copied threads. Preserve letter types and support LF and CRLF frontmatter.
|
|
8
|
+
- Make server-authored text the result contract and report doorbell outcomes separately from durable writes. Support the public Agent Letterbox environment variables with a warning for deprecated environment variable names.
|
|
9
|
+
- Document the public CLI setup, five tools, safety practices and pull-only MCP host; exercise mutations against the public CLI.
|
|
10
|
+
- Add a pinned, non-root container image and bind-mount guidance for a mailbox and CLI installation. Built and smoke-tested on Linux.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simon Mallas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agent-letterbox-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP tools for reading and handling Agent Letterbox letters.
|
|
5
|
+
Project-URL: Homepage, https://agentletterbox.com
|
|
6
|
+
Project-URL: Repository, https://github.com/SimonMallas/agent-letterbox-mcp
|
|
7
|
+
Project-URL: Changelog, https://github.com/SimonMallas/agent-letterbox-mcp/blob/master/CHANGELOG.md
|
|
8
|
+
Project-URL: Issues, https://github.com/SimonMallas/agent-letterbox-mcp/issues
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Simon Mallas
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Classifier: Development Status :: 4 - Beta
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Topic :: Communications
|
|
38
|
+
Requires-Python: >=3.11
|
|
39
|
+
Requires-Dist: mcp==1.30.0
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest==8.4.2; extra == 'dev'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# Agent Letterbox MCP door
|
|
45
|
+
|
|
46
|
+
<!-- mcp-name: io.github.SimonMallas/agent-letterbox-mcp -->
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
**Give any MCP app a seat at your agent team's mailbox.**
|
|
51
|
+
|
|
52
|
+
[Agent Letterbox](https://github.com/SimonMallas/agent-letterbox-cmux) is durable mail between AI coding agents:
|
|
53
|
+
letters as plain files on disk, a doorbell that wakes the recipient's terminal pane, and a queryable record of who
|
|
54
|
+
asked, who answered and what is still owed ([QEM](https://github.com/SimonMallas/agent-letterbox-cmux/blob/main/ARCHITECTURE.md)).
|
|
55
|
+
|
|
56
|
+
Until now a seat needed a terminal. **This door removes that requirement**: Claude Desktop, an IDE, any MCP client
|
|
57
|
+
can hold a mailbox as a first-class participant — check it, read letters, send, reply, file. Underneath, the door
|
|
58
|
+
shells out to the same pinned Letterbox CLI, so a letter written through it is byte-identical to one written in a
|
|
59
|
+
terminal: same envelope, same lifecycle, same record. **Five tools, one identity, files stay canonical.**
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
letterbox-mcp --mailbox /path/to/box --agent alpha
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Two planes, one door
|
|
66
|
+
|
|
67
|
+
Letterbox has two planes. The door exposes only one of them.
|
|
68
|
+
|
|
69
|
+
```mermaid
|
|
70
|
+
flowchart LR
|
|
71
|
+
subgraph DURABLE["DURABLE PLANE — canonical"]
|
|
72
|
+
BOX[("mailboxes\nletters as files")]
|
|
73
|
+
CLI["letterbox CLI\n(pinned helper)"]
|
|
74
|
+
CLI --- BOX
|
|
75
|
+
end
|
|
76
|
+
subgraph ATTENTION["ATTENTION PLANE"]
|
|
77
|
+
BELL(("doorbell"))
|
|
78
|
+
end
|
|
79
|
+
TERM["terminal agent\n(cmux · tmux · zellij · Herdr pane, Rex block)"] --- CLI
|
|
80
|
+
BELL -. "rings the pane" .-> TERM
|
|
81
|
+
HOST["MCP host\n(Claude Desktop, IDE, …)"] == "MCP door\n5 tools · letterbox://letter/{id}" ==> CLI
|
|
82
|
+
BELL x--x HOST
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
DURABLE PLANE files + CLI. Owns letters, identity, state, lifecycle. Canonical.
|
|
87
|
+
ATTENTION PLANE the doorbell. Signals that durable mail exists.
|
|
88
|
+
It does not carry the letter, does not prove consumption,
|
|
89
|
+
and DOES NOT REACH MCP HOSTS. A desktop seat is pull-only.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
MCP may expose the durable plane. It must never collapse the two.
|
|
93
|
+
|
|
94
|
+
## Law
|
|
95
|
+
|
|
96
|
+
1. CLI and files are the source of truth. MCP is a view. Any disagreement is a tool error carrying the CLI's own words.
|
|
97
|
+
2. `check` never returns bodies. `read` is one id. `include_body` defaults false.
|
|
98
|
+
3. No search tool. No bridge tokens, allowlists or chat ids in any schema, URI, log line or structured content.
|
|
99
|
+
4. One resource template, `letterbox://letter/{id}`. Never `file://`. Unknown id is an error, never an empty letter.
|
|
100
|
+
5. No decision-critical outcome exists only in `structuredContent`. Server-authored text is the compatibility contract.
|
|
101
|
+
6. MCP capabilities describe this adapter, not Letterbox. Absent `resources.subscribe` does not mean Letterbox cannot
|
|
102
|
+
notify; notification lives on the attention plane, outside MCP.
|
|
103
|
+
7. The door is jailed to ONE mailbox and ONE identity. It can read and write only that participant's own mail.
|
|
104
|
+
One writer per identity; the door does not weaken it.
|
|
105
|
+
8. Relay-originated letters (an external bridge's correspondence) cannot be replied to or filed through the door;
|
|
106
|
+
their lifecycle belongs to the bridge that carried them.
|
|
107
|
+
|
|
108
|
+
## The five tools
|
|
109
|
+
|
|
110
|
+
| Tool | Does | Writes? |
|
|
111
|
+
|---|---|---|
|
|
112
|
+
| `letterbox_check` | List open letters (headers only, never bodies) | no |
|
|
113
|
+
| `letterbox_read` | One letter by id; `include_body` defaults false | no |
|
|
114
|
+
| `letterbox_send` | A new letter (`to`, `type`, `subject`, `body`; rings the recipient) | yes |
|
|
115
|
+
| `letterbox_reply` | `ack` / `nack` / `result` on a letter in this inbox | yes |
|
|
116
|
+
| `letterbox_file` | Move a non-task letter to processed (content hash unchanged) | yes |
|
|
117
|
+
|
|
118
|
+
## Requirements
|
|
119
|
+
|
|
120
|
+
- Python ≥ 3.11; official Python MCP SDK (pinned in `pyproject.toml`); stdio transport, protocol 2025-11-25.
|
|
121
|
+
- A **pinned Letterbox CLI helper**. `LETTERBOX_CLI` is **required**: the door shells out to the CLI for writes and
|
|
122
|
+
refuses to run one without the pin. Verify the helper by manifest (`shasum -a 256 -c MANIFEST.sha256`) at deployment
|
|
123
|
+
and again before any live session.
|
|
124
|
+
- A mailbox and a **registered identity** for the host. The identity must exist as a participant before the door
|
|
125
|
+
starts; the door will not invent one.
|
|
126
|
+
|
|
127
|
+
## Install
|
|
128
|
+
|
|
129
|
+
The PyPI distribution is `agent-letterbox-mcp`; its command remains `letterbox-mcp`. To run that command with uv, use `uvx --from agent-letterbox-mcp letterbox-mcp --mailbox /path/to/box --agent alpha`.
|
|
130
|
+
|
|
131
|
+
Install into **its own worktree with its own venv** — never a development checkout's editable install (an editable
|
|
132
|
+
install runs whatever uncommitted files the dev repo carries; the stage-3 checklist requires evidence of which code
|
|
133
|
+
will run).
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
git worktree add ~/letterbox-mcp-<purpose>-<sha8> <reviewed-commit>
|
|
137
|
+
cd ~/letterbox-mcp-<purpose>-<sha8>
|
|
138
|
+
python3 -m venv .venv && .venv/bin/pip install .
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Verify what will actually run:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
.venv/bin/python -c 'import letterbox_mcp; print(letterbox_mcp.__file__)' # a path INSIDE this worktree
|
|
145
|
+
.venv/bin/pip show agent-letterbox-mcp # must NOT name a dev repo as an editable location
|
|
146
|
+
git rev-parse HEAD && git status --short # record both; status must be empty
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Container (stdio)
|
|
150
|
+
|
|
151
|
+
Build locally with Docker: `docker build -t letterbox-mcp:local .`. The image installs the locked Python dependencies and runs as UID/GID 65532, without embedding a mailbox, helper or credentials. Pass stdio through with `-i` (do not allocate a TTY):
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
docker run --rm -i --network none \
|
|
155
|
+
--mount type=bind,src=/absolute/path/to/box,dst=/box \
|
|
156
|
+
--mount type=bind,src=/absolute/path/to/agent-letterbox,dst=/opt/letterbox,readonly \
|
|
157
|
+
-e LETTERBOX_CLI=/opt/letterbox/bin/letterbox \
|
|
158
|
+
letterbox-mcp:local --mailbox /box --agent your-registered-seat
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Use a reviewed, manifest-verified **Linux-compatible** CLI installation, including its sibling files; the image does not include the helper. The mailbox must already be initialized, the seat registered, and its files writable by the container user. Adapt the runtime UID/GID and mount permissions to your host if necessary. Helper dependencies and paths must also work inside the container. Apply the same single-writer and supervised-write rules as for a host installation.
|
|
162
|
+
|
|
163
|
+
The mounted mailbox supplies the durable letters. A container does not connect the helper to a host terminal's doorbell: delivery of a durable letter does not mean the host terminal was rung. The MCP host itself is pull-only. Container support has not been validated with every Letterbox edition or host environment.
|
|
164
|
+
|
|
165
|
+
## Configuring a host — Claude Desktop example
|
|
166
|
+
|
|
167
|
+
Config: `~/Library/Application Support/Claude/claude_desktop_config.json` (mode 600). **Back it up first** (`cp -p` to
|
|
168
|
+
a dated sibling; record sha256 of both). Add ONE server beside whatever is already there; do not edit existing entries:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
"letterbox-live": {
|
|
172
|
+
"command": "/Users/you/letterbox-mcp-<purpose>-<sha8>/.venv/bin/letterbox-mcp",
|
|
173
|
+
"args": ["--mailbox", "/Users/you/project/.letterbox", "--agent", "desktop"],
|
|
174
|
+
"env": { "LETTERBOX_CLI": "/Users/you/.local/share/agent-letterbox-cmux/bin/letterbox" }
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Use the absolute `bin/letterbox` path of the public edition you reviewed and an initialized Letterbox root for `--mailbox`. Private helpers need separate qualification before use with this server.
|
|
179
|
+
|
|
180
|
+
Restart the host and confirm the server lists exactly **five** tools.
|
|
181
|
+
|
|
182
|
+
## Safety — read before the first live session
|
|
183
|
+
|
|
184
|
+
- **There is no read-only mode in v1.** The door advertises all five tools, always. Treat every live session as
|
|
185
|
+
**supervised**: a human approves or denies each write. **Never set `letterbox_send`, `letterbox_reply` or
|
|
186
|
+
`letterbox_file` to "Always allow".**
|
|
187
|
+
- **Relay-originated letters cannot be replied to or filed through the door.** A phone question is answered on the
|
|
188
|
+
phone, by the bridge that carried it.
|
|
189
|
+
- **Snapshot discipline for a first attach:** snapshot the mailbox before and after, diff, and apply the one-pass
|
|
190
|
+
rule — byte-identical, or every difference traced to a specific logged action inside the window. An untraced
|
|
191
|
+
difference fails the session, whoever caused it.
|
|
192
|
+
- **Abort rule:** if the host attempts a write you did not expect, deny it. If one executes anyway: quit the host,
|
|
193
|
+
take the after-snapshot, roll back, trace the write. A send may already have rung a seat — say so.
|
|
194
|
+
- Consumers of `structuredContent` and `resources/read` are handling untrusted data and must render it safely.
|
|
195
|
+
|
|
196
|
+
## Limits (v1, by design)
|
|
197
|
+
|
|
198
|
+
- **No bell into MCP hosts.** A desktop seat is pull-only; its habit is check-at-start. Nobody is coming to wake it.
|
|
199
|
+
- **No query (QEM), no progress verb, no supersedes on send.** The durable record underneath supports all three; the
|
|
200
|
+
door does not expose them yet.
|
|
201
|
+
- `letterbox_reply` is `ack | nack | result` only — a mid-task progress note is a new letter referencing the thread.
|
|
202
|
+
- Reply writes are jailed: participant-bound `from`, derived ids, no-follow into the target inbox. A non-TTY pipe that
|
|
203
|
+
never reaches EOF may still block the underlying CLI (known accepted limit, from the CLI).
|
|
204
|
+
|
|
205
|
+
## If something goes wrong
|
|
206
|
+
|
|
207
|
+
1. Quit the host.
|
|
208
|
+
2. Restore the config backup; verify its sha256 matches the recorded one.
|
|
209
|
+
3. Leave the worktree and pinned helper in place until evidence is filed.
|
|
210
|
+
4. An MCP-written letter looks like: `from: <identity>` in frontmatter, in some participant's inbox, mtime inside the
|
|
211
|
+
session window — `grep -l '^from: desktop' <bus>/*/inbox/*.md`.
|
|
212
|
+
|
|
213
|
+
## Proven
|
|
214
|
+
|
|
215
|
+
These claims are not aspirations. The door passed a supervised read-only pilot (byte-identical mailbox), a scripted
|
|
216
|
+
first-write comparison (door letter byte-identical to a CLI letter), live reply/file/thread mechanics, and a
|
|
217
|
+
supervised real-task trial in which a desktop seat acknowledged and answered a genuine request with byte-perfect
|
|
218
|
+
lifecycle evidence. Every stage was independently verified by a second reviewer.
|
|
219
|
+
|
|
220
|
+
Why the record is built this way: [The Case for Vectorless Accountability in Agent Memory](https://github.com/SimonMallas/vectorless-accountability).
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Agent Letterbox MCP door
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.SimonMallas/agent-letterbox-mcp -->
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
**Give any MCP app a seat at your agent team's mailbox.**
|
|
8
|
+
|
|
9
|
+
[Agent Letterbox](https://github.com/SimonMallas/agent-letterbox-cmux) is durable mail between AI coding agents:
|
|
10
|
+
letters as plain files on disk, a doorbell that wakes the recipient's terminal pane, and a queryable record of who
|
|
11
|
+
asked, who answered and what is still owed ([QEM](https://github.com/SimonMallas/agent-letterbox-cmux/blob/main/ARCHITECTURE.md)).
|
|
12
|
+
|
|
13
|
+
Until now a seat needed a terminal. **This door removes that requirement**: Claude Desktop, an IDE, any MCP client
|
|
14
|
+
can hold a mailbox as a first-class participant — check it, read letters, send, reply, file. Underneath, the door
|
|
15
|
+
shells out to the same pinned Letterbox CLI, so a letter written through it is byte-identical to one written in a
|
|
16
|
+
terminal: same envelope, same lifecycle, same record. **Five tools, one identity, files stay canonical.**
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
letterbox-mcp --mailbox /path/to/box --agent alpha
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Two planes, one door
|
|
23
|
+
|
|
24
|
+
Letterbox has two planes. The door exposes only one of them.
|
|
25
|
+
|
|
26
|
+
```mermaid
|
|
27
|
+
flowchart LR
|
|
28
|
+
subgraph DURABLE["DURABLE PLANE — canonical"]
|
|
29
|
+
BOX[("mailboxes\nletters as files")]
|
|
30
|
+
CLI["letterbox CLI\n(pinned helper)"]
|
|
31
|
+
CLI --- BOX
|
|
32
|
+
end
|
|
33
|
+
subgraph ATTENTION["ATTENTION PLANE"]
|
|
34
|
+
BELL(("doorbell"))
|
|
35
|
+
end
|
|
36
|
+
TERM["terminal agent\n(cmux · tmux · zellij · Herdr pane, Rex block)"] --- CLI
|
|
37
|
+
BELL -. "rings the pane" .-> TERM
|
|
38
|
+
HOST["MCP host\n(Claude Desktop, IDE, …)"] == "MCP door\n5 tools · letterbox://letter/{id}" ==> CLI
|
|
39
|
+
BELL x--x HOST
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
DURABLE PLANE files + CLI. Owns letters, identity, state, lifecycle. Canonical.
|
|
44
|
+
ATTENTION PLANE the doorbell. Signals that durable mail exists.
|
|
45
|
+
It does not carry the letter, does not prove consumption,
|
|
46
|
+
and DOES NOT REACH MCP HOSTS. A desktop seat is pull-only.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
MCP may expose the durable plane. It must never collapse the two.
|
|
50
|
+
|
|
51
|
+
## Law
|
|
52
|
+
|
|
53
|
+
1. CLI and files are the source of truth. MCP is a view. Any disagreement is a tool error carrying the CLI's own words.
|
|
54
|
+
2. `check` never returns bodies. `read` is one id. `include_body` defaults false.
|
|
55
|
+
3. No search tool. No bridge tokens, allowlists or chat ids in any schema, URI, log line or structured content.
|
|
56
|
+
4. One resource template, `letterbox://letter/{id}`. Never `file://`. Unknown id is an error, never an empty letter.
|
|
57
|
+
5. No decision-critical outcome exists only in `structuredContent`. Server-authored text is the compatibility contract.
|
|
58
|
+
6. MCP capabilities describe this adapter, not Letterbox. Absent `resources.subscribe` does not mean Letterbox cannot
|
|
59
|
+
notify; notification lives on the attention plane, outside MCP.
|
|
60
|
+
7. The door is jailed to ONE mailbox and ONE identity. It can read and write only that participant's own mail.
|
|
61
|
+
One writer per identity; the door does not weaken it.
|
|
62
|
+
8. Relay-originated letters (an external bridge's correspondence) cannot be replied to or filed through the door;
|
|
63
|
+
their lifecycle belongs to the bridge that carried them.
|
|
64
|
+
|
|
65
|
+
## The five tools
|
|
66
|
+
|
|
67
|
+
| Tool | Does | Writes? |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `letterbox_check` | List open letters (headers only, never bodies) | no |
|
|
70
|
+
| `letterbox_read` | One letter by id; `include_body` defaults false | no |
|
|
71
|
+
| `letterbox_send` | A new letter (`to`, `type`, `subject`, `body`; rings the recipient) | yes |
|
|
72
|
+
| `letterbox_reply` | `ack` / `nack` / `result` on a letter in this inbox | yes |
|
|
73
|
+
| `letterbox_file` | Move a non-task letter to processed (content hash unchanged) | yes |
|
|
74
|
+
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
- Python ≥ 3.11; official Python MCP SDK (pinned in `pyproject.toml`); stdio transport, protocol 2025-11-25.
|
|
78
|
+
- A **pinned Letterbox CLI helper**. `LETTERBOX_CLI` is **required**: the door shells out to the CLI for writes and
|
|
79
|
+
refuses to run one without the pin. Verify the helper by manifest (`shasum -a 256 -c MANIFEST.sha256`) at deployment
|
|
80
|
+
and again before any live session.
|
|
81
|
+
- A mailbox and a **registered identity** for the host. The identity must exist as a participant before the door
|
|
82
|
+
starts; the door will not invent one.
|
|
83
|
+
|
|
84
|
+
## Install
|
|
85
|
+
|
|
86
|
+
The PyPI distribution is `agent-letterbox-mcp`; its command remains `letterbox-mcp`. To run that command with uv, use `uvx --from agent-letterbox-mcp letterbox-mcp --mailbox /path/to/box --agent alpha`.
|
|
87
|
+
|
|
88
|
+
Install into **its own worktree with its own venv** — never a development checkout's editable install (an editable
|
|
89
|
+
install runs whatever uncommitted files the dev repo carries; the stage-3 checklist requires evidence of which code
|
|
90
|
+
will run).
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
git worktree add ~/letterbox-mcp-<purpose>-<sha8> <reviewed-commit>
|
|
94
|
+
cd ~/letterbox-mcp-<purpose>-<sha8>
|
|
95
|
+
python3 -m venv .venv && .venv/bin/pip install .
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Verify what will actually run:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
.venv/bin/python -c 'import letterbox_mcp; print(letterbox_mcp.__file__)' # a path INSIDE this worktree
|
|
102
|
+
.venv/bin/pip show agent-letterbox-mcp # must NOT name a dev repo as an editable location
|
|
103
|
+
git rev-parse HEAD && git status --short # record both; status must be empty
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Container (stdio)
|
|
107
|
+
|
|
108
|
+
Build locally with Docker: `docker build -t letterbox-mcp:local .`. The image installs the locked Python dependencies and runs as UID/GID 65532, without embedding a mailbox, helper or credentials. Pass stdio through with `-i` (do not allocate a TTY):
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
docker run --rm -i --network none \
|
|
112
|
+
--mount type=bind,src=/absolute/path/to/box,dst=/box \
|
|
113
|
+
--mount type=bind,src=/absolute/path/to/agent-letterbox,dst=/opt/letterbox,readonly \
|
|
114
|
+
-e LETTERBOX_CLI=/opt/letterbox/bin/letterbox \
|
|
115
|
+
letterbox-mcp:local --mailbox /box --agent your-registered-seat
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Use a reviewed, manifest-verified **Linux-compatible** CLI installation, including its sibling files; the image does not include the helper. The mailbox must already be initialized, the seat registered, and its files writable by the container user. Adapt the runtime UID/GID and mount permissions to your host if necessary. Helper dependencies and paths must also work inside the container. Apply the same single-writer and supervised-write rules as for a host installation.
|
|
119
|
+
|
|
120
|
+
The mounted mailbox supplies the durable letters. A container does not connect the helper to a host terminal's doorbell: delivery of a durable letter does not mean the host terminal was rung. The MCP host itself is pull-only. Container support has not been validated with every Letterbox edition or host environment.
|
|
121
|
+
|
|
122
|
+
## Configuring a host — Claude Desktop example
|
|
123
|
+
|
|
124
|
+
Config: `~/Library/Application Support/Claude/claude_desktop_config.json` (mode 600). **Back it up first** (`cp -p` to
|
|
125
|
+
a dated sibling; record sha256 of both). Add ONE server beside whatever is already there; do not edit existing entries:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
"letterbox-live": {
|
|
129
|
+
"command": "/Users/you/letterbox-mcp-<purpose>-<sha8>/.venv/bin/letterbox-mcp",
|
|
130
|
+
"args": ["--mailbox", "/Users/you/project/.letterbox", "--agent", "desktop"],
|
|
131
|
+
"env": { "LETTERBOX_CLI": "/Users/you/.local/share/agent-letterbox-cmux/bin/letterbox" }
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Use the absolute `bin/letterbox` path of the public edition you reviewed and an initialized Letterbox root for `--mailbox`. Private helpers need separate qualification before use with this server.
|
|
136
|
+
|
|
137
|
+
Restart the host and confirm the server lists exactly **five** tools.
|
|
138
|
+
|
|
139
|
+
## Safety — read before the first live session
|
|
140
|
+
|
|
141
|
+
- **There is no read-only mode in v1.** The door advertises all five tools, always. Treat every live session as
|
|
142
|
+
**supervised**: a human approves or denies each write. **Never set `letterbox_send`, `letterbox_reply` or
|
|
143
|
+
`letterbox_file` to "Always allow".**
|
|
144
|
+
- **Relay-originated letters cannot be replied to or filed through the door.** A phone question is answered on the
|
|
145
|
+
phone, by the bridge that carried it.
|
|
146
|
+
- **Snapshot discipline for a first attach:** snapshot the mailbox before and after, diff, and apply the one-pass
|
|
147
|
+
rule — byte-identical, or every difference traced to a specific logged action inside the window. An untraced
|
|
148
|
+
difference fails the session, whoever caused it.
|
|
149
|
+
- **Abort rule:** if the host attempts a write you did not expect, deny it. If one executes anyway: quit the host,
|
|
150
|
+
take the after-snapshot, roll back, trace the write. A send may already have rung a seat — say so.
|
|
151
|
+
- Consumers of `structuredContent` and `resources/read` are handling untrusted data and must render it safely.
|
|
152
|
+
|
|
153
|
+
## Limits (v1, by design)
|
|
154
|
+
|
|
155
|
+
- **No bell into MCP hosts.** A desktop seat is pull-only; its habit is check-at-start. Nobody is coming to wake it.
|
|
156
|
+
- **No query (QEM), no progress verb, no supersedes on send.** The durable record underneath supports all three; the
|
|
157
|
+
door does not expose them yet.
|
|
158
|
+
- `letterbox_reply` is `ack | nack | result` only — a mid-task progress note is a new letter referencing the thread.
|
|
159
|
+
- Reply writes are jailed: participant-bound `from`, derived ids, no-follow into the target inbox. A non-TTY pipe that
|
|
160
|
+
never reaches EOF may still block the underlying CLI (known accepted limit, from the CLI).
|
|
161
|
+
|
|
162
|
+
## If something goes wrong
|
|
163
|
+
|
|
164
|
+
1. Quit the host.
|
|
165
|
+
2. Restore the config backup; verify its sha256 matches the recorded one.
|
|
166
|
+
3. Leave the worktree and pinned helper in place until evidence is filed.
|
|
167
|
+
4. An MCP-written letter looks like: `from: <identity>` in frontmatter, in some participant's inbox, mtime inside the
|
|
168
|
+
session window — `grep -l '^from: desktop' <bus>/*/inbox/*.md`.
|
|
169
|
+
|
|
170
|
+
## Proven
|
|
171
|
+
|
|
172
|
+
These claims are not aspirations. The door passed a supervised read-only pilot (byte-identical mailbox), a scripted
|
|
173
|
+
first-write comparison (door letter byte-identical to a CLI letter), live reply/file/thread mechanics, and a
|
|
174
|
+
supervised real-task trial in which a desktop seat acknowledged and answered a genuine request with byte-perfect
|
|
175
|
+
lifecycle evidence. Every stage was independently verified by a second reviewer.
|
|
176
|
+
|
|
177
|
+
Why the record is built this way: [The Case for Vectorless Accountability in Agent Memory](https://github.com/SimonMallas/vectorless-accountability).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling==1.32.3"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agent-letterbox-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP tools for reading and handling Agent Letterbox letters."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Communications",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"mcp==1.30.0",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://agentletterbox.com"
|
|
27
|
+
Repository = "https://github.com/SimonMallas/agent-letterbox-mcp"
|
|
28
|
+
Changelog = "https://github.com/SimonMallas/agent-letterbox-mcp/blob/master/CHANGELOG.md"
|
|
29
|
+
Issues = "https://github.com/SimonMallas/agent-letterbox-mcp/issues"
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = ["pytest==8.4.2"]
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
letterbox-mcp = "letterbox_mcp.__main__:main"
|
|
36
|
+
|
|
37
|
+
[tool.pytest.ini_options]
|
|
38
|
+
testpaths = ["tests"]
|
|
39
|
+
addopts = "-q"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/letterbox_mcp"]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.sdist]
|
|
45
|
+
only-include = ["src/letterbox_mcp", "README.md", "LICENSE", "CHANGELOG.md", "pyproject.toml", "server.json"]
|
|
46
|
+
exclude = ["/.gitignore"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.SimonMallas/agent-letterbox-mcp",
|
|
4
|
+
"title": "Agent Letterbox MCP",
|
|
5
|
+
"description": "Read and handle Agent Letterbox letters through MCP.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/SimonMallas/agent-letterbox-mcp",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"packages": [
|
|
12
|
+
{
|
|
13
|
+
"registryType": "pypi",
|
|
14
|
+
"identifier": "agent-letterbox-mcp",
|
|
15
|
+
"version": "0.1.0",
|
|
16
|
+
"transport": {
|
|
17
|
+
"type": "stdio"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import asyncio
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from letterbox_mcp.mailbox import Mailbox
|
|
9
|
+
from letterbox_mcp.server import run_stdio
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main(argv: list[str] | None = None) -> None:
|
|
13
|
+
parser = argparse.ArgumentParser(prog="letterbox-mcp")
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"--mailbox",
|
|
16
|
+
help="Mailbox root (or LETTERBOX_DIR). Stage one tests pass a fixture path.",
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--agent",
|
|
20
|
+
help="Mailbox owner (or LETTERBOX_AGENT)."
|
|
21
|
+
)
|
|
22
|
+
args = parser.parse_args(argv)
|
|
23
|
+
for attr, primary, legacy in (("mailbox", "LETTERBOX_DIR", "BUS_DIR"),
|
|
24
|
+
("agent", "LETTERBOX_AGENT", "BUS_AGENT")):
|
|
25
|
+
if getattr(args, attr):
|
|
26
|
+
continue
|
|
27
|
+
value = os.environ.get(primary)
|
|
28
|
+
if not value:
|
|
29
|
+
value = os.environ.get(legacy)
|
|
30
|
+
if value:
|
|
31
|
+
print(f"letterbox-mcp: {legacy} is deprecated; use {primary}", file=sys.stderr)
|
|
32
|
+
setattr(args, attr, value)
|
|
33
|
+
if not args.mailbox or not args.agent:
|
|
34
|
+
print("letterbox-mcp: --mailbox/LETTERBOX_DIR and --agent/LETTERBOX_AGENT are required", file=sys.stderr)
|
|
35
|
+
raise SystemExit(2)
|
|
36
|
+
mailbox = Mailbox(args.mailbox, args.agent)
|
|
37
|
+
asyncio.run(run_stdio(mailbox))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
main()
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Invoke the configured Letterbox CLI without leaking mailbox paths in errors."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import subprocess
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
RING_LINE = re.compile(
|
|
12
|
+
r"^doorbell-outcome v=1 outcome=(\S+) reason=(\S+) target=(\S+)\s*$"
|
|
13
|
+
)
|
|
14
|
+
OUTCOMES = frozenset({"submitted", "pasted_not_submitted", "no_live_surface"})
|
|
15
|
+
SENT_LINE = re.compile(r"^sent: .*/([^/]+)\.md\s*$")
|
|
16
|
+
ALREADY_FILED = re.compile(r"^already filed:")
|
|
17
|
+
FILED_LINE = re.compile(r"^filed:")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class CliResult:
|
|
22
|
+
ok: bool
|
|
23
|
+
stdout: str
|
|
24
|
+
stderr: str
|
|
25
|
+
ring: dict[str, str] | None
|
|
26
|
+
letter_id: str | None
|
|
27
|
+
already_filed: bool
|
|
28
|
+
already_closed: bool
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def run_cli(
|
|
32
|
+
mailbox_root: str,
|
|
33
|
+
agent: str,
|
|
34
|
+
args: list[str],
|
|
35
|
+
*,
|
|
36
|
+
stdin: str = "",
|
|
37
|
+
timeout: float = 30.0,
|
|
38
|
+
) -> CliResult:
|
|
39
|
+
configured_cli = os.environ.get("LETTERBOX_CLI")
|
|
40
|
+
if not configured_cli:
|
|
41
|
+
return CliResult(
|
|
42
|
+
ok=False,
|
|
43
|
+
stdout="",
|
|
44
|
+
stderr="LETTERBOX_CLI must be explicitly configured",
|
|
45
|
+
ring=None,
|
|
46
|
+
letter_id=None,
|
|
47
|
+
already_filed=False,
|
|
48
|
+
already_closed=False,
|
|
49
|
+
)
|
|
50
|
+
cli = Path(configured_cli)
|
|
51
|
+
env = os.environ.copy()
|
|
52
|
+
env["LETTERBOX_DIR"] = str(Path(mailbox_root).resolve())
|
|
53
|
+
env["LETTERBOX_AGENT"] = agent
|
|
54
|
+
# Keep compatibility with the private bus helper.
|
|
55
|
+
env["BUS_DIR"] = env["LETTERBOX_DIR"]
|
|
56
|
+
env["BUS_AGENT"] = agent
|
|
57
|
+
proc = subprocess.run(
|
|
58
|
+
[str(cli), *args],
|
|
59
|
+
input=stdin,
|
|
60
|
+
capture_output=True,
|
|
61
|
+
text=True,
|
|
62
|
+
timeout=timeout,
|
|
63
|
+
env=env,
|
|
64
|
+
check=False,
|
|
65
|
+
)
|
|
66
|
+
stdout = proc.stdout or ""
|
|
67
|
+
stderr = _sanitize(proc.stderr or "", mailbox_root)
|
|
68
|
+
ring = parse_ring(stdout)
|
|
69
|
+
letter_id = _parse_sent_id(stdout)
|
|
70
|
+
already = bool(ALREADY_FILED.search(stdout))
|
|
71
|
+
closed = any(line.startswith("already closed:") for line in stdout.splitlines())
|
|
72
|
+
ok = proc.returncode == 0
|
|
73
|
+
return CliResult(
|
|
74
|
+
ok=ok,
|
|
75
|
+
stdout=stdout,
|
|
76
|
+
stderr=stderr,
|
|
77
|
+
ring=ring,
|
|
78
|
+
letter_id=letter_id,
|
|
79
|
+
already_filed=already,
|
|
80
|
+
already_closed=closed,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def parse_ring(stdout: str) -> dict[str, str] | None:
|
|
85
|
+
for line in stdout.splitlines():
|
|
86
|
+
match = RING_LINE.fullmatch(line)
|
|
87
|
+
if match:
|
|
88
|
+
outcome, reason, target = match.group(1), match.group(2), match.group(3)
|
|
89
|
+
if outcome not in OUTCOMES:
|
|
90
|
+
return None
|
|
91
|
+
return {"outcome": outcome, "reason": reason, "target": target}
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _parse_sent_id(stdout: str) -> str | None:
|
|
96
|
+
for line in stdout.splitlines():
|
|
97
|
+
match = SENT_LINE.fullmatch(line)
|
|
98
|
+
if match:
|
|
99
|
+
return match.group(1)
|
|
100
|
+
if line.startswith("sent: "):
|
|
101
|
+
name = Path(line[6:].strip()).name
|
|
102
|
+
if name.endswith(".md"):
|
|
103
|
+
return name[:-3]
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _sanitize(text: str, mailbox_root: str) -> str:
|
|
108
|
+
root = str(Path(mailbox_root).resolve())
|
|
109
|
+
home = str(Path.home())
|
|
110
|
+
cleaned = text.replace(root, "").replace(home, "")
|
|
111
|
+
return cleaned.strip()[:500]
|