agent-jmap-mcp 0.2.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.
@@ -0,0 +1,11 @@
1
+ # JMAP Server & Authentication Configuration Example
2
+ # Copy this file to .env and configure with your credentials
3
+
4
+ # Fastmail Session URL (default for Fastmail users)
5
+ JMAP_SESSION_URL=https://api.fastmail.com/.well-known/jmap
6
+
7
+ # JMAP Bearer API Token (generate in Fastmail / Stalwart / Cyrus settings)
8
+ JMAP_API_TOKEN=fmu1-xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
9
+
10
+ # Optional: Specific Primary Account ID (auto-discovered if omitted)
11
+ # JMAP_ACCOUNT_ID=u12345678
@@ -0,0 +1,35 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install .[dev]
28
+
29
+ - name: Lint with Ruff
30
+ run: |
31
+ ruff check src tests
32
+
33
+ - name: Test with Pytest
34
+ run: |
35
+ pytest -v --cov=agent_jmap_mcp
@@ -0,0 +1,28 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ pypi-publish:
10
+ name: Build and publish Python 🐍 distributions 📦 to PyPI
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ id-token: write # Mandatory for PyPI Trusted Publishing (OIDC)
14
+
15
+ steps:
16
+ - name: Checkout source
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Set up uv
20
+ uses: astral-sh/setup-uv@v5
21
+ with:
22
+ version: "latest"
23
+
24
+ - name: Build distributions
25
+ run: uv build
26
+
27
+ - name: Publish package distributions to PyPI
28
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,80 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+ cover/
51
+
52
+ # Jupyter Notebook
53
+ .ipynb_checkpoints
54
+
55
+ # Environments
56
+ .env
57
+ .env.*
58
+ !.env.example
59
+ .venv
60
+ env/
61
+ venv/
62
+ ENV/
63
+ env.bak/
64
+ venv.bak/
65
+
66
+ # Secrets & Credentials
67
+ *credential*.json
68
+ *token*.json
69
+ *secret*.json
70
+ *.pem
71
+ *.key
72
+ jmap-credentials.json
73
+
74
+ # IDE & Editor files
75
+ .vscode/
76
+ .idea/
77
+ *.swp
78
+ *.swo
79
+ *~
80
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eric Maddox
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,290 @@
1
+ Metadata-Version: 2.5
2
+ Name: agent-jmap-mcp
3
+ Version: 0.2.0
4
+ Summary: Modern, stateless JMAP email client and Model Context Protocol (MCP) server for AI agents.
5
+ Project-URL: Homepage, https://github.com/ericmaddox/agent-jmap-mcp
6
+ Project-URL: Repository, https://github.com/ericmaddox/agent-jmap-mcp.git
7
+ Project-URL: Issues, https://github.com/ericmaddox/agent-jmap-mcp/issues
8
+ Author-email: Eric Maddox <eric.maddox@outlook.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai-agents,claude,cursor,email,fastmail,hermes-agent,jmap,mcp,mcp-server,model-context-protocol
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Communications :: Email
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: html2text<2025.0.0,>=2024.2.26
24
+ Requires-Dist: httpx<1.0.0,>=0.28.0
25
+ Requires-Dist: mcp<2.0.0,>=1.3.0
26
+ Requires-Dist: pydantic<3.0.0,>=2.10.0
27
+ Requires-Dist: rich<14.0.0,>=13.9.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
30
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
31
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.8.0; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # agent-jmap-mcp
36
+
37
+ [![CI](https://github.com/ericmaddox/agent-jmap-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/ericmaddox/agent-jmap-mcp/actions/workflows/ci.yml)
38
+ [![Python Version](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue.svg)](https://www.python.org/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
40
+ [![MCP Protocol](https://img.shields.io/badge/MCP-1.3.0%2B-purple.svg)](https://modelcontextprotocol.io)
41
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
42
+
43
+ A stateless, production-grade JSON Meta Application Protocol (JMAP) client and Model Context Protocol (MCP) server for AI agents, automation pipelines, and developer workflows.
44
+
45
+ Compliant with [RFC 8620](https://datatracker.ietf.org/doc/html/rfc8620) (JMAP Core) and [RFC 8621](https://datatracker.ietf.org/doc/html/rfc8621) (JMAP Mail), `agent-jmap-mcp` allows language models (e.g. Claude, Hermes Agent, GPT-4, Cursor) to inspect mailboxes, search and retrieve messages, navigate conversation threads, download attachments, perform automated inbox triage, and compose/send emails atomically over pure HTTP.
46
+
47
+ ---
48
+
49
+ ## Architecture
50
+
51
+ ```mermaid
52
+ flowchart TD
53
+ subgraph Host["AI Agent / Host Application"]
54
+ Agent["AI Agent / LLM Client"]
55
+ end
56
+
57
+ subgraph MCP["agent-jmap-mcp Server"]
58
+ Server["FastMCP stdio Engine"]
59
+ Tools["Tools Interface<br/>(list, search, get, thread, download, send, triage)"]
60
+ TriageEng["Rule-Based Triage Engine"]
61
+ Converter["HTML-to-Markdown Engine"]
62
+ Client["RFC 8620/8621 JMAP Client"]
63
+ end
64
+
65
+ subgraph Upstream["JMAP Email Server"]
66
+ JMAPEndpoint["JMAP API Endpoint<br/>(Fastmail / Stalwart / Cyrus)"]
67
+ end
68
+
69
+ Agent <-->|"JSON-RPC / stdio"| Server
70
+ Server --> Tools
71
+ Tools --> TriageEng
72
+ Tools --> Converter
73
+ Tools --> Client
74
+ Client <-->|"Stateless HTTPS (JSON Batches / Binary Streams)"| JMAPEndpoint
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Key Capabilities
80
+
81
+ - **Stateless HTTP Architecture**: Operates over standard HTTPS with bearer token authentication. Avoids persistent IMAP socket overhead and connection timeout state.
82
+ - **Atomic Operations**: Executes message creation and dispatch in a single atomic transaction combining `Email/set` and `EmailSubmission/set`.
83
+ - **Conversation Threading (`Thread/get`)**: Full RFC 8621 conversation thread retrieval aggregating multi-turn email dialogues chronologically.
84
+ - **Binary Attachment Downloads**: High-speed streaming downloads for PDF, image, and data attachments via session `downloadUrl`.
85
+ - **Rich HTML-to-Markdown Extraction**: Automated markdown conversion for HTML-only newsletters and styled emails.
86
+ - **Session Auto-Discovery**: Automatically queries `/.well-known/jmap` to discover API endpoints, upload/download URLs, and primary account IDs.
87
+ - **Zero-Footprint Model Context**: Optimized JSON payloads structured specifically for minimal LLM context window consumption.
88
+ - **Automated Inbox Triage**: Built-in heuristic classification for inbox sorting (Urgent, Action Required, Personal, Notifications, Newsletters).
89
+ - **Universal MCP Compatibility**: Plugs directly into Claude Desktop, Hermes Agent, Cursor, Zed, and any MCP-compliant environment.
90
+
91
+ ---
92
+
93
+ ## Installation
94
+
95
+ ### Using uv (Recommended)
96
+
97
+ ```bash
98
+ uv tool install agent-jmap-mcp
99
+ ```
100
+
101
+ ### Using pipx or pip
102
+
103
+ ```bash
104
+ pipx install agent-jmap-mcp
105
+ # or
106
+ pip install agent-jmap-mcp
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Configuration
112
+
113
+ Set the required environment variables:
114
+
115
+ | Variable | Description | Example / Default |
116
+ | :--- | :--- | :--- |
117
+ | `JMAP_SESSION_URL` | JMAP Session discovery URL | `https://api.fastmail.com/.well-known/jmap` |
118
+ | `JMAP_API_TOKEN` | Bearer API token | `fmu1-...` |
119
+ | `JMAP_ACCOUNT_ID` | Optional target account ID | Auto-discovered from session if omitted |
120
+
121
+ A `.env.example` template is provided in the repository.
122
+
123
+ ---
124
+
125
+ ## MCP Server Integration
126
+
127
+ ### Claude Desktop
128
+
129
+ Add to your `claude_desktop_config.json`:
130
+
131
+ ```json
132
+ {
133
+ "mcpServers": {
134
+ "jmap": {
135
+ "command": "uvx",
136
+ "args": ["agent-jmap-mcp"],
137
+ "env": {
138
+ "JMAP_SESSION_URL": "https://api.fastmail.com/.well-known/jmap",
139
+ "JMAP_API_TOKEN": "YOUR_JMAP_API_TOKEN"
140
+ }
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ ### Hermes Agent
147
+
148
+ Add to `~/.hermes/config.yaml`:
149
+
150
+ ```yaml
151
+ mcp_servers:
152
+ jmap:
153
+ command: "uvx"
154
+ args: ["agent-jmap-mcp"]
155
+ env:
156
+ JMAP_SESSION_URL: "https://api.fastmail.com/.well-known/jmap"
157
+ JMAP_API_TOKEN: "${JMAP_API_TOKEN}"
158
+ ```
159
+
160
+ ### Cursor
161
+
162
+ Add to `.cursor/mcp.json`:
163
+
164
+ ```json
165
+ {
166
+ "mcpServers": {
167
+ "jmap": {
168
+ "command": "uvx",
169
+ "args": ["agent-jmap-mcp"],
170
+ "env": {
171
+ "JMAP_SESSION_URL": "https://api.fastmail.com/.well-known/jmap",
172
+ "JMAP_API_TOKEN": "YOUR_JMAP_API_TOKEN"
173
+ }
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
179
+ ### Zed Editor
180
+
181
+ Add to `settings.json`:
182
+
183
+ ```json
184
+ {
185
+ "context_servers": {
186
+ "jmap": {
187
+ "command": {
188
+ "path": "uvx",
189
+ "args": ["agent-jmap-mcp"],
190
+ "env": {
191
+ "JMAP_SESSION_URL": "https://api.fastmail.com/.well-known/jmap",
192
+ "JMAP_API_TOKEN": "YOUR_JMAP_API_TOKEN"
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Available MCP Tools
203
+
204
+ | Tool Name | Parameters | Description |
205
+ | :--- | :--- | :--- |
206
+ | `jmap_list_mailboxes` | None | Returns metadata for all mailboxes (IDs, names, roles, unread/total counts). |
207
+ | `jmap_list_emails` | `mailbox`, `limit`, `unread_only`, `query`, `from_address`, `subject_contains` | Queries email headers with filtering, search conditions, and sorting. |
208
+ | `jmap_get_email` | `email_id` (str), `mark_as_read` (bool) | Fetches full email body (converted to markdown if HTML), headers, and attachments. |
209
+ | `jmap_get_thread` | `thread_id` (str) | Fetches full multi-message conversation thread chronologically. |
210
+ | `jmap_download_attachment` | `blob_id` (str), `filename` (str), `save_directory` (str) | Downloads binary attachment from JMAP server and saves to disk. |
211
+ | `jmap_send_email` | `to` (list), `subject` (str), `body` (str), `from_address` (str), `cc` (list), `bcc` (list), `draft_only` (bool) | Atomically creates and submits an outgoing message (or saves to drafts). |
212
+ | `jmap_triage_inbox` | `mailbox` (str), `limit` (int), `unread_only` (bool) | Analyzes recent messages and returns categorization, priorities, and action items. |
213
+
214
+ ---
215
+
216
+ ## Command Line Interface (CLI)
217
+
218
+ The package includes a standalone CLI tool `agent-jmap`:
219
+
220
+ ```bash
221
+ # Start MCP server over stdio
222
+ agent-jmap serve
223
+
224
+ # List available mailboxes
225
+ agent-jmap mailboxes
226
+
227
+ # List recent emails
228
+ agent-jmap list --limit 10
229
+ agent-jmap list --unread --query "invoice"
230
+
231
+ # View specific email
232
+ agent-jmap get <email-id>
233
+
234
+ # View entire conversation thread
235
+ agent-jmap thread <thread-id>
236
+
237
+ # Download binary attachment
238
+ agent-jmap download <blob-id> --name report.pdf --output ./downloads
239
+
240
+ # Run inbox triage
241
+ agent-jmap triage --limit 20
242
+
243
+ # Send email from command line
244
+ agent-jmap send --to user@example.com --subject "Status Update" --body "Processing completed."
245
+ ```
246
+
247
+ ---
248
+
249
+ ## Development and Testing
250
+
251
+ ### Setup Environment
252
+
253
+ ```bash
254
+ git clone https://github.com/ericmaddox/agent-jmap-mcp.git
255
+ cd agent-jmap-mcp
256
+ uv sync --extra dev
257
+ ```
258
+
259
+ ### Running Test Suite
260
+
261
+ ```bash
262
+ uv run pytest -v
263
+ ```
264
+
265
+ ### Code Formatting and Linting
266
+
267
+ ```bash
268
+ uv run ruff check .
269
+ uv run ruff format .
270
+ ```
271
+
272
+ ### Building Distribution Packages
273
+
274
+ ```bash
275
+ uv build
276
+ ```
277
+
278
+ ---
279
+
280
+ ## RFC Compliance
281
+
282
+ - [RFC 8620: The JSON Meta Application Protocol (JMAP)](https://datatracker.ietf.org/doc/html/rfc8620)
283
+ - [RFC 8621: The JSON Meta Application Protocol (JMAP) for Mail](https://datatracker.ietf.org/doc/html/rfc8621)
284
+ - [RFC 5322: Internet Message Format](https://datatracker.ietf.org/doc/html/rfc5322)
285
+
286
+ ---
287
+
288
+ ## License
289
+
290
+ MIT License. Copyright (c) 2026 Eric Maddox. See [LICENSE](LICENSE) for details.