mailferret 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.
Files changed (127) hide show
  1. mailferret-0.1.0/LICENSE +21 -0
  2. mailferret-0.1.0/PKG-INFO +131 -0
  3. mailferret-0.1.0/README.md +94 -0
  4. mailferret-0.1.0/pyproject.toml +110 -0
  5. mailferret-0.1.0/pyproject.toml.orig +84 -0
  6. mailferret-0.1.0/src/mailferret/__init__.py +5 -0
  7. mailferret-0.1.0/src/mailferret/__main__.py +3 -0
  8. mailferret-0.1.0/src/mailferret/aliases/__init__.py +30 -0
  9. mailferret-0.1.0/src/mailferret/aliases/aggregate.py +53 -0
  10. mailferret-0.1.0/src/mailferret/aliases/match.py +85 -0
  11. mailferret-0.1.0/src/mailferret/aliases/resolver.py +176 -0
  12. mailferret-0.1.0/src/mailferret/aliases/rules.py +86 -0
  13. mailferret-0.1.0/src/mailferret/auth/__init__.py +28 -0
  14. mailferret-0.1.0/src/mailferret/auth/errors.py +58 -0
  15. mailferret-0.1.0/src/mailferret/auth/markers.py +384 -0
  16. mailferret-0.1.0/src/mailferret/auth/password.py +136 -0
  17. mailferret-0.1.0/src/mailferret/auth/protocol.py +33 -0
  18. mailferret-0.1.0/src/mailferret/cli/__init__.py +27 -0
  19. mailferret-0.1.0/src/mailferret/cli/accounts.py +50 -0
  20. mailferret-0.1.0/src/mailferret/cli/auth.py +287 -0
  21. mailferret-0.1.0/src/mailferret/cli/context.py +67 -0
  22. mailferret-0.1.0/src/mailferret/cli/doctor.py +164 -0
  23. mailferret-0.1.0/src/mailferret/cli/doctor_accounts.py +254 -0
  24. mailferret-0.1.0/src/mailferret/cli/doctor_registrations.py +313 -0
  25. mailferret-0.1.0/src/mailferret/cli/doctor_report.py +114 -0
  26. mailferret-0.1.0/src/mailferret/cli/register.py +85 -0
  27. mailferret-0.1.0/src/mailferret/cli/serve.py +21 -0
  28. mailferret-0.1.0/src/mailferret/cli/setup.py +300 -0
  29. mailferret-0.1.0/src/mailferret/config/__init__.py +22 -0
  30. mailferret-0.1.0/src/mailferret/config/paths.py +39 -0
  31. mailferret-0.1.0/src/mailferret/config/schema.py +244 -0
  32. mailferret-0.1.0/src/mailferret/config/store.py +183 -0
  33. mailferret-0.1.0/src/mailferret/content/__init__.py +1 -0
  34. mailferret-0.1.0/src/mailferret/content/charset.py +106 -0
  35. mailferret-0.1.0/src/mailferret/content/css.py +2043 -0
  36. mailferret-0.1.0/src/mailferret/content/extractors.py +125 -0
  37. mailferret-0.1.0/src/mailferret/content/headers.py +339 -0
  38. mailferret-0.1.0/src/mailferret/content/html.py +810 -0
  39. mailferret-0.1.0/src/mailferret/content/html_notes.py +37 -0
  40. mailferret-0.1.0/src/mailferret/content/invisible.py +55 -0
  41. mailferret-0.1.0/src/mailferret/content/mime.py +689 -0
  42. mailferret-0.1.0/src/mailferret/content/pdf_host.py +174 -0
  43. mailferret-0.1.0/src/mailferret/content/pdf_worker.py +267 -0
  44. mailferret-0.1.0/src/mailferret/content/precut.py +32 -0
  45. mailferret-0.1.0/src/mailferret/content/truncate.py +55 -0
  46. mailferret-0.1.0/src/mailferret/credentials/__init__.py +35 -0
  47. mailferret-0.1.0/src/mailferret/credentials/bindings.py +62 -0
  48. mailferret-0.1.0/src/mailferret/credentials/command_backend.py +155 -0
  49. mailferret-0.1.0/src/mailferret/credentials/dbus.py +75 -0
  50. mailferret-0.1.0/src/mailferret/credentials/detect.py +48 -0
  51. mailferret-0.1.0/src/mailferret/credentials/errors.py +114 -0
  52. mailferret-0.1.0/src/mailferret/credentials/keyring_backend.py +75 -0
  53. mailferret-0.1.0/src/mailferret/credentials/keyring_probe.py +125 -0
  54. mailferret-0.1.0/src/mailferret/credentials/memory.py +28 -0
  55. mailferret-0.1.0/src/mailferret/credentials/probe.py +163 -0
  56. mailferret-0.1.0/src/mailferret/credentials/probe_protocol.py +13 -0
  57. mailferret-0.1.0/src/mailferret/credentials/process.py +93 -0
  58. mailferret-0.1.0/src/mailferret/credentials/protocol.py +58 -0
  59. mailferret-0.1.0/src/mailferret/credentials/recipe.py +62 -0
  60. mailferret-0.1.0/src/mailferret/credentials/registry.py +36 -0
  61. mailferret-0.1.0/src/mailferret/credentials/secret.py +83 -0
  62. mailferret-0.1.0/src/mailferret/credentials/wsl.py +31 -0
  63. mailferret-0.1.0/src/mailferret/imap/__init__.py +60 -0
  64. mailferret-0.1.0/src/mailferret/imap/capabilities.py +38 -0
  65. mailferret-0.1.0/src/mailferret/imap/caps.py +101 -0
  66. mailferret-0.1.0/src/mailferret/imap/errors.py +199 -0
  67. mailferret-0.1.0/src/mailferret/imap/grammar.py +153 -0
  68. mailferret-0.1.0/src/mailferret/imap/guard.py +425 -0
  69. mailferret-0.1.0/src/mailferret/imap/handle.py +58 -0
  70. mailferret-0.1.0/src/mailferret/imap/lifecycle.py +346 -0
  71. mailferret-0.1.0/src/mailferret/imap/probe.py +51 -0
  72. mailferret-0.1.0/src/mailferret/imap/selfcheck.py +89 -0
  73. mailferret-0.1.0/src/mailferret/imap/session.py +252 -0
  74. mailferret-0.1.0/src/mailferret/imap/tls.py +26 -0
  75. mailferret-0.1.0/src/mailferret/imap/transport.py +239 -0
  76. mailferret-0.1.0/src/mailferret/limits.py +242 -0
  77. mailferret-0.1.0/src/mailferret/logging.py +259 -0
  78. mailferret-0.1.0/src/mailferret/providers/__init__.py +25 -0
  79. mailferret-0.1.0/src/mailferret/providers/presets.py +98 -0
  80. mailferret-0.1.0/src/mailferret/providers/presets.toml +10 -0
  81. mailferret-0.1.0/src/mailferret/providers/resolve.py +48 -0
  82. mailferret-0.1.0/src/mailferret/py.typed +0 -0
  83. mailferret-0.1.0/src/mailferret/query/__init__.py +83 -0
  84. mailferret-0.1.0/src/mailferret/query/aliases.py +102 -0
  85. mailferret-0.1.0/src/mailferret/query/attachment_meta.py +68 -0
  86. mailferret-0.1.0/src/mailferret/query/attachments.py +226 -0
  87. mailferret-0.1.0/src/mailferret/query/criteria.py +143 -0
  88. mailferret-0.1.0/src/mailferret/query/cursor.py +125 -0
  89. mailferret-0.1.0/src/mailferret/query/deadline.py +33 -0
  90. mailferret-0.1.0/src/mailferret/query/errors.py +56 -0
  91. mailferret-0.1.0/src/mailferret/query/fetch.py +97 -0
  92. mailferret-0.1.0/src/mailferret/query/folders.py +257 -0
  93. mailferret-0.1.0/src/mailferret/query/guarded.py +32 -0
  94. mailferret-0.1.0/src/mailferret/query/message.py +314 -0
  95. mailferret-0.1.0/src/mailferret/query/message_text.py +211 -0
  96. mailferret-0.1.0/src/mailferret/query/postfilter.py +168 -0
  97. mailferret-0.1.0/src/mailferret/query/scan.py +60 -0
  98. mailferret-0.1.0/src/mailferret/query/search.py +353 -0
  99. mailferret-0.1.0/src/mailferret/query/thread.py +533 -0
  100. mailferret-0.1.0/src/mailferret/query/windows.py +41 -0
  101. mailferret-0.1.0/src/mailferret/registration/__init__.py +33 -0
  102. mailferret-0.1.0/src/mailferret/registration/claude_code.py +108 -0
  103. mailferret-0.1.0/src/mailferret/registration/constraints.txt +126 -0
  104. mailferret-0.1.0/src/mailferret/registration/desktop.py +214 -0
  105. mailferret-0.1.0/src/mailferret/registration/discovery.py +91 -0
  106. mailferret-0.1.0/src/mailferret/registration/files.py +244 -0
  107. mailferret-0.1.0/src/mailferret/registration/launch.py +110 -0
  108. mailferret-0.1.0/src/mailferret/registration/plugin.py +98 -0
  109. mailferret-0.1.0/src/mailferret/registration/runtime.py +279 -0
  110. mailferret-0.1.0/src/mailferret/server/__init__.py +1 -0
  111. mailferret-0.1.0/src/mailferret/server/app.py +497 -0
  112. mailferret-0.1.0/src/mailferret/server/envelope.py +105 -0
  113. mailferret-0.1.0/src/mailferret/server/errors.py +134 -0
  114. mailferret-0.1.0/src/mailferret/server/models.py +28 -0
  115. mailferret-0.1.0/src/mailferret/server/outputs.py +390 -0
  116. mailferret-0.1.0/src/mailferret/server/refs.py +68 -0
  117. mailferret-0.1.0/src/mailferret/server/result.py +297 -0
  118. mailferret-0.1.0/src/mailferret/server/runtime.py +121 -0
  119. mailferret-0.1.0/src/mailferret/server/serve.py +36 -0
  120. mailferret-0.1.0/src/mailferret/smtp/__init__.py +1 -0
  121. mailferret-0.1.0/src/mailferret/smtp/api.py +14 -0
  122. mailferret-0.1.0/src/mailferret/subproc/__init__.py +7 -0
  123. mailferret-0.1.0/src/mailferret/subproc/bounded.py +420 -0
  124. mailferret-0.1.0/src/mailferret/subproc/jobobject.py +100 -0
  125. mailferret-0.1.0/src/mailferret/subproc/launch.py +14 -0
  126. mailferret-0.1.0/src/mailferret/write/__init__.py +1 -0
  127. mailferret-0.1.0/src/mailferret/write/api.py +20 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DocGerd
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,131 @@
1
+ Metadata-Version: 2.4
2
+ Name: mailferret
3
+ Version: 0.1.0
4
+ Summary: A read-only-by-default IMAP MCP server and Claude Code plugin
5
+ Keywords: imap,mcp,claude,email,read-only
6
+ Author: DocGerd
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
18
+ Classifier: Topic :: Communications :: Email
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: click>=8.5,<9
21
+ Requires-Dist: imapclient==4.3.0
22
+ Requires-Dist: keyring>=25.7,<26
23
+ Requires-Dist: lxml>=6.1,<6.2
24
+ Requires-Dist: mcp>=2.3,<3
25
+ Requires-Dist: platformdirs>=4.14,<5
26
+ Requires-Dist: pydantic>=2.14,<3
27
+ Requires-Dist: pypdf>=7.2,<8
28
+ Requires-Dist: tomlkit>=0.15,<0.16
29
+ Requires-Python: >=3.13
30
+ Project-URL: Homepage, https://github.com/DocGerd/mailferret
31
+ Project-URL: Repository, https://github.com/DocGerd/mailferret
32
+ Project-URL: Issues, https://github.com/DocGerd/mailferret/issues
33
+ Project-URL: Changelog, https://github.com/DocGerd/mailferret/blob/main/CHANGELOG.md
34
+ Project-URL: Security, https://github.com/DocGerd/mailferret/blob/main/SECURITY.md
35
+ Project-URL: Documentation, https://github.com/DocGerd/mailferret/tree/main/docs/user
36
+ Description-Content-Type: text/markdown
37
+
38
+ <img src="https://raw.githubusercontent.com/DocGerd/mailferret/main/docs/brand/banner.svg" alt="mailferret by DocGerdSoft: read-only IMAP for MCP clients and Claude Code" width="100%">
39
+
40
+ [![mcp: stdio server](https://img.shields.io/badge/mcp-stdio%20server-B0457E?labelColor=3B4046)](https://modelcontextprotocol.io)
41
+ [![imap: read-only by default](https://img.shields.io/badge/imap-read--only%20by%20default-14161A?labelColor=3B4046)](https://github.com/DocGerd/mailferret/blob/main/SECURITY.md)
42
+ [![ci](https://img.shields.io/github/actions/workflow/status/DocGerd/mailferret/ci.yml?label=ci&labelColor=3B4046)](https://github.com/DocGerd/mailferret/actions/workflows/ci.yml)
43
+ [![python: 3.13+](https://img.shields.io/badge/python-3.13%2B-5E646B?labelColor=3B4046)](https://github.com/DocGerd/mailferret/blob/main/pyproject.toml)
44
+ [![license: MIT](https://img.shields.io/badge/license-MIT-5E646B?labelColor=3B4046)](https://github.com/DocGerd/mailferret/blob/main/LICENSE)
45
+
46
+ Read-only by default: folders open with `EXAMINE` and bodies are fetched with `BODY.PEEK`, so nothing is moved, flagged or marked read.
47
+
48
+ ```console
49
+ $ uv tool install git+https://github.com/DocGerd/mailferret
50
+ $ mailferret setup
51
+ ```
52
+
53
+ This puts `mailferret` on PATH, which every later command below needs, `register` in particular.
54
+ Before the first PyPI release, `register` finds no launcher without this install.
55
+ Alternatively, run the setup once with uvx, which leaves no `mailferret` on PATH:
56
+
57
+ ```console
58
+ $ uvx --from git+https://github.com/DocGerd/mailferret mailferret setup
59
+ ```
60
+
61
+ After the first PyPI release the install is `uv tool install mailferret` and the one-shot `uvx mailferret setup`.
62
+ pipx or a venv work too.
63
+ Requires [uv](https://docs.astral.sh/uv/) and Python 3.13 or newer.
64
+
65
+ Status: [docs/STATUS.md](https://github.com/DocGerd/mailferret/blob/main/docs/STATUS.md).
66
+
67
+ ## Safety
68
+
69
+ - Read-only: no tool moves, flags, deletes or sends. Writing and SMTP exist only as disabled interfaces; the config rejects enabling them.
70
+ - Credentials live in the OS keyring or a command you configure, never in the config, logs or tool output. Store them with `mailferret auth set`, never by pasting them into a chat.
71
+ - TLS certificate verification is always on. A rejected login is never retried.
72
+ - Mail text is untrusted data, wrapped in delimiters and stripped of hidden content.
73
+
74
+ Residual risk: mailferret cannot stop a client from obeying instructions hidden in a mail.
75
+ If your assistant can read mail and also run commands or fetch URLs, an injected mail may steer it to send what it has read elsewhere.
76
+ Read mail in a context without shell or web tools, and keep other outbound tools out of it.
77
+ The plugin's `mail-reader` agent is meant for this but is not installable yet, and its runtime tool list is unverified (`T-18`).
78
+ A residual path remains: its summary returns to a parent that may have shell and web tools.
79
+ Details: [SECURITY.md](https://github.com/DocGerd/mailferret/blob/main/SECURITY.md) and `T-18` in [docs/SECURITY.md](https://github.com/DocGerd/mailferret/blob/main/docs/SECURITY.md).
80
+
81
+ ## Set up
82
+
83
+ ```console
84
+ $ mailferret setup
85
+ $ mailferret accounts list
86
+ ```
87
+
88
+ `setup` adds an account, stores its password and tests the connection read-only.
89
+ Change or store a password later in a terminal:
90
+
91
+ ```console
92
+ $ mailferret auth set <account>
93
+ ```
94
+
95
+ Per-platform backends, WSL with `pass`, and exporting `DBUS_SESSION_BUS_ADDRESS` for the keyring: [docs/user/credentials.md](https://github.com/DocGerd/mailferret/blob/main/docs/user/credentials.md).
96
+
97
+ ## Connect a client
98
+
99
+ - Claude Code: `mailferret register claude-code`
100
+ - Claude Desktop: `mailferret register claude-desktop`
101
+ - Any MCP client: a stdio entry with command `mailferret` and args `["serve"]`
102
+ - Claude Code plugin (adds the `mail-reader` agent and `doctor` skill): not installable until the first PyPI release
103
+ - claude.ai zip upload: unverified
104
+
105
+ All of it: [docs/user/clients.md](https://github.com/DocGerd/mailferret/blob/main/docs/user/clients.md).
106
+
107
+ ## Tools
108
+
109
+ `list_accounts`, `list_folders`, `search`, `get_message`, `get_thread`, `list_attachments`, `get_attachment_text`, `list_aliases`.
110
+ Overview: [docs/user/tools.md](https://github.com/DocGerd/mailferret/blob/main/docs/user/tools.md).
111
+
112
+ ## Docs
113
+
114
+ - [Getting started](https://github.com/DocGerd/mailferret/blob/main/docs/user/getting-started.md)
115
+ - [Credentials](https://github.com/DocGerd/mailferret/blob/main/docs/user/credentials.md)
116
+ - [Configuration and presets](https://github.com/DocGerd/mailferret/blob/main/docs/user/configuration.md)
117
+ - [Clients](https://github.com/DocGerd/mailferret/blob/main/docs/user/clients.md)
118
+ - [Tools](https://github.com/DocGerd/mailferret/blob/main/docs/user/tools.md)
119
+ - [Troubleshooting](https://github.com/DocGerd/mailferret/blob/main/docs/user/troubleshooting.md)
120
+
121
+ ## Troubleshooting
122
+
123
+ ```console
124
+ $ mailferret doctor
125
+ ```
126
+
127
+ It checks config, credentials, the connection and client registrations, and changes nothing.
128
+
129
+ ## Contributing and security
130
+
131
+ [CONTRIBUTING.md](https://github.com/DocGerd/mailferret/blob/main/CONTRIBUTING.md). Report vulnerabilities privately as described in [SECURITY.md](https://github.com/DocGerd/mailferret/blob/main/SECURITY.md).
@@ -0,0 +1,94 @@
1
+ <img src="https://raw.githubusercontent.com/DocGerd/mailferret/main/docs/brand/banner.svg" alt="mailferret by DocGerdSoft: read-only IMAP for MCP clients and Claude Code" width="100%">
2
+
3
+ [![mcp: stdio server](https://img.shields.io/badge/mcp-stdio%20server-B0457E?labelColor=3B4046)](https://modelcontextprotocol.io)
4
+ [![imap: read-only by default](https://img.shields.io/badge/imap-read--only%20by%20default-14161A?labelColor=3B4046)](https://github.com/DocGerd/mailferret/blob/main/SECURITY.md)
5
+ [![ci](https://img.shields.io/github/actions/workflow/status/DocGerd/mailferret/ci.yml?label=ci&labelColor=3B4046)](https://github.com/DocGerd/mailferret/actions/workflows/ci.yml)
6
+ [![python: 3.13+](https://img.shields.io/badge/python-3.13%2B-5E646B?labelColor=3B4046)](https://github.com/DocGerd/mailferret/blob/main/pyproject.toml)
7
+ [![license: MIT](https://img.shields.io/badge/license-MIT-5E646B?labelColor=3B4046)](https://github.com/DocGerd/mailferret/blob/main/LICENSE)
8
+
9
+ Read-only by default: folders open with `EXAMINE` and bodies are fetched with `BODY.PEEK`, so nothing is moved, flagged or marked read.
10
+
11
+ ```console
12
+ $ uv tool install git+https://github.com/DocGerd/mailferret
13
+ $ mailferret setup
14
+ ```
15
+
16
+ This puts `mailferret` on PATH, which every later command below needs, `register` in particular.
17
+ Before the first PyPI release, `register` finds no launcher without this install.
18
+ Alternatively, run the setup once with uvx, which leaves no `mailferret` on PATH:
19
+
20
+ ```console
21
+ $ uvx --from git+https://github.com/DocGerd/mailferret mailferret setup
22
+ ```
23
+
24
+ After the first PyPI release the install is `uv tool install mailferret` and the one-shot `uvx mailferret setup`.
25
+ pipx or a venv work too.
26
+ Requires [uv](https://docs.astral.sh/uv/) and Python 3.13 or newer.
27
+
28
+ Status: [docs/STATUS.md](https://github.com/DocGerd/mailferret/blob/main/docs/STATUS.md).
29
+
30
+ ## Safety
31
+
32
+ - Read-only: no tool moves, flags, deletes or sends. Writing and SMTP exist only as disabled interfaces; the config rejects enabling them.
33
+ - Credentials live in the OS keyring or a command you configure, never in the config, logs or tool output. Store them with `mailferret auth set`, never by pasting them into a chat.
34
+ - TLS certificate verification is always on. A rejected login is never retried.
35
+ - Mail text is untrusted data, wrapped in delimiters and stripped of hidden content.
36
+
37
+ Residual risk: mailferret cannot stop a client from obeying instructions hidden in a mail.
38
+ If your assistant can read mail and also run commands or fetch URLs, an injected mail may steer it to send what it has read elsewhere.
39
+ Read mail in a context without shell or web tools, and keep other outbound tools out of it.
40
+ The plugin's `mail-reader` agent is meant for this but is not installable yet, and its runtime tool list is unverified (`T-18`).
41
+ A residual path remains: its summary returns to a parent that may have shell and web tools.
42
+ Details: [SECURITY.md](https://github.com/DocGerd/mailferret/blob/main/SECURITY.md) and `T-18` in [docs/SECURITY.md](https://github.com/DocGerd/mailferret/blob/main/docs/SECURITY.md).
43
+
44
+ ## Set up
45
+
46
+ ```console
47
+ $ mailferret setup
48
+ $ mailferret accounts list
49
+ ```
50
+
51
+ `setup` adds an account, stores its password and tests the connection read-only.
52
+ Change or store a password later in a terminal:
53
+
54
+ ```console
55
+ $ mailferret auth set <account>
56
+ ```
57
+
58
+ Per-platform backends, WSL with `pass`, and exporting `DBUS_SESSION_BUS_ADDRESS` for the keyring: [docs/user/credentials.md](https://github.com/DocGerd/mailferret/blob/main/docs/user/credentials.md).
59
+
60
+ ## Connect a client
61
+
62
+ - Claude Code: `mailferret register claude-code`
63
+ - Claude Desktop: `mailferret register claude-desktop`
64
+ - Any MCP client: a stdio entry with command `mailferret` and args `["serve"]`
65
+ - Claude Code plugin (adds the `mail-reader` agent and `doctor` skill): not installable until the first PyPI release
66
+ - claude.ai zip upload: unverified
67
+
68
+ All of it: [docs/user/clients.md](https://github.com/DocGerd/mailferret/blob/main/docs/user/clients.md).
69
+
70
+ ## Tools
71
+
72
+ `list_accounts`, `list_folders`, `search`, `get_message`, `get_thread`, `list_attachments`, `get_attachment_text`, `list_aliases`.
73
+ Overview: [docs/user/tools.md](https://github.com/DocGerd/mailferret/blob/main/docs/user/tools.md).
74
+
75
+ ## Docs
76
+
77
+ - [Getting started](https://github.com/DocGerd/mailferret/blob/main/docs/user/getting-started.md)
78
+ - [Credentials](https://github.com/DocGerd/mailferret/blob/main/docs/user/credentials.md)
79
+ - [Configuration and presets](https://github.com/DocGerd/mailferret/blob/main/docs/user/configuration.md)
80
+ - [Clients](https://github.com/DocGerd/mailferret/blob/main/docs/user/clients.md)
81
+ - [Tools](https://github.com/DocGerd/mailferret/blob/main/docs/user/tools.md)
82
+ - [Troubleshooting](https://github.com/DocGerd/mailferret/blob/main/docs/user/troubleshooting.md)
83
+
84
+ ## Troubleshooting
85
+
86
+ ```console
87
+ $ mailferret doctor
88
+ ```
89
+
90
+ It checks config, credentials, the connection and client registrations, and changes nothing.
91
+
92
+ ## Contributing and security
93
+
94
+ [CONTRIBUTING.md](https://github.com/DocGerd/mailferret/blob/main/CONTRIBUTING.md). Report vulnerabilities privately as described in [SECURITY.md](https://github.com/DocGerd/mailferret/blob/main/SECURITY.md).
@@ -0,0 +1,110 @@
1
+ [project]
2
+ name = "mailferret"
3
+ version = "0.1.0"
4
+ description = "A read-only-by-default IMAP MCP server and Claude Code plugin"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.13"
9
+ keywords = [
10
+ "imap",
11
+ "mcp",
12
+ "claude",
13
+ "email",
14
+ "read-only",
15
+ ]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: POSIX :: Linux",
21
+ "Operating System :: Microsoft :: Windows",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Programming Language :: Python :: 3.15",
26
+ "Topic :: Communications :: Email",
27
+ "Typing :: Typed",
28
+ ]
29
+ dependencies = [
30
+ "click>=8.5,<9",
31
+ "imapclient==4.3.0",
32
+ "keyring>=25.7,<26",
33
+ "lxml>=6.1,<6.2",
34
+ "mcp>=2.3,<3",
35
+ "platformdirs>=4.14,<5",
36
+ "pydantic>=2.14,<3",
37
+ "pypdf>=7.2,<8",
38
+ "tomlkit>=0.15,<0.16",
39
+ ]
40
+
41
+ [[project.authors]]
42
+ name = "DocGerd"
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/DocGerd/mailferret"
46
+ Repository = "https://github.com/DocGerd/mailferret"
47
+ Issues = "https://github.com/DocGerd/mailferret/issues"
48
+ Changelog = "https://github.com/DocGerd/mailferret/blob/main/CHANGELOG.md"
49
+ Security = "https://github.com/DocGerd/mailferret/blob/main/SECURITY.md"
50
+ Documentation = "https://github.com/DocGerd/mailferret/tree/main/docs/user"
51
+
52
+ [project.scripts]
53
+ mailferret = "mailferret.cli:main"
54
+
55
+ [dependency-groups]
56
+ dev = [
57
+ "hypothesis>=6.170",
58
+ "mypy>=2.4",
59
+ "pytest>=9.2",
60
+ "pytest-xdist>=3.8.0",
61
+ "ruff>=0.17",
62
+ ]
63
+
64
+ [build-system]
65
+ requires = ["uv_build>=0.13,<0.14"]
66
+ build-backend = "uv_build"
67
+
68
+ [tool.uv]
69
+ required-version = "==0.13.10"
70
+
71
+ [tool.ruff]
72
+ line-length = 100
73
+ target-version = "py313"
74
+ extend-exclude = [
75
+ ".claude",
76
+ ".githooks",
77
+ "docs",
78
+ "scripts",
79
+ "tests/tooling",
80
+ ]
81
+
82
+ [tool.ruff.lint]
83
+ select = [
84
+ "E",
85
+ "F",
86
+ "I",
87
+ "B",
88
+ "UP",
89
+ "S",
90
+ "SIM",
91
+ "RUF",
92
+ ]
93
+
94
+ [tool.ruff.lint.per-file-ignores]
95
+ "tests/**" = ["S101"]
96
+
97
+ [tool.mypy]
98
+ strict = true
99
+ python_version = "3.13"
100
+
101
+ [[tool.mypy.overrides]]
102
+ module = [
103
+ "lxml",
104
+ "lxml.*",
105
+ ]
106
+ ignore_missing_imports = true
107
+
108
+ [tool.pytest.ini_options]
109
+ testpaths = ["tests"]
110
+ addopts = "--ignore=tests/tooling -ra --strict-markers --strict-config"
@@ -0,0 +1,84 @@
1
+ [project]
2
+ name = "mailferret"
3
+ version = "0.1.0"
4
+ description = "A read-only-by-default IMAP MCP server and Claude Code plugin"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.13"
9
+ keywords = ["imap", "mcp", "claude", "email", "read-only"]
10
+ authors = [{ name = "DocGerd" }]
11
+ classifiers = [
12
+ "Development Status :: 4 - Beta",
13
+ "Environment :: Console",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: POSIX :: Linux",
16
+ "Operating System :: Microsoft :: Windows",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Programming Language :: Python :: 3.15",
21
+ "Topic :: Communications :: Email",
22
+ "Typing :: Typed",
23
+ ]
24
+ dependencies = [
25
+ "click>=8.5,<9",
26
+ "imapclient==4.3.0",
27
+ "keyring>=25.7,<26",
28
+ "lxml>=6.1,<6.2",
29
+ "mcp>=2.3,<3",
30
+ "platformdirs>=4.14,<5",
31
+ "pydantic>=2.14,<3",
32
+ "pypdf>=7.2,<8",
33
+ "tomlkit>=0.15,<0.16",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/DocGerd/mailferret"
38
+ Repository = "https://github.com/DocGerd/mailferret"
39
+ Issues = "https://github.com/DocGerd/mailferret/issues"
40
+ Changelog = "https://github.com/DocGerd/mailferret/blob/main/CHANGELOG.md"
41
+ Security = "https://github.com/DocGerd/mailferret/blob/main/SECURITY.md"
42
+ Documentation = "https://github.com/DocGerd/mailferret/tree/main/docs/user"
43
+
44
+ [project.scripts]
45
+ mailferret = "mailferret.cli:main"
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "hypothesis>=6.170",
50
+ "mypy>=2.4",
51
+ "pytest>=9.2",
52
+ "pytest-xdist>=3.8.0",
53
+ "ruff>=0.17",
54
+ ]
55
+
56
+ [build-system]
57
+ requires = ["uv_build>=0.13,<0.14"]
58
+ build-backend = "uv_build"
59
+
60
+ [tool.uv]
61
+ required-version = "==0.13.10"
62
+
63
+ [tool.ruff]
64
+ line-length = 100
65
+ target-version = "py313"
66
+ extend-exclude = [".claude", ".githooks", "docs", "scripts", "tests/tooling"]
67
+
68
+ [tool.ruff.lint]
69
+ select = ["E", "F", "I", "B", "UP", "S", "SIM", "RUF"]
70
+
71
+ [tool.ruff.lint.per-file-ignores]
72
+ "tests/**" = ["S101"]
73
+
74
+ [tool.mypy]
75
+ strict = true
76
+ python_version = "3.13"
77
+
78
+ [tool.pytest.ini_options]
79
+ testpaths = ["tests"]
80
+ addopts = "--ignore=tests/tooling -ra --strict-markers --strict-config"
81
+
82
+ [[tool.mypy.overrides]]
83
+ module = ["lxml", "lxml.*"]
84
+ ignore_missing_imports = true
@@ -0,0 +1,5 @@
1
+ """mailferret: a read-only-by-default IMAP MCP server."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ __version__ = version("mailferret")
@@ -0,0 +1,3 @@
1
+ from mailferret.cli import main
2
+
3
+ main()
@@ -0,0 +1,30 @@
1
+ """Alias resolution: pure functions over header values, no I/O (A§2.6, R§5)."""
2
+
3
+ from mailferret.aliases.aggregate import Aggregation, AliasCount, aggregate_aliases
4
+ from mailferret.aliases.match import (
5
+ Pattern,
6
+ PatternTooLongError,
7
+ compile_pattern,
8
+ glob_match,
9
+ matches,
10
+ prefilter_fragment,
11
+ )
12
+ from mailferret.aliases.resolver import Alias, Resolution, resolve_alias
13
+ from mailferret.aliases.rules import AliasRules, validate_header_names
14
+
15
+ __all__ = [
16
+ "Aggregation",
17
+ "Alias",
18
+ "AliasCount",
19
+ "AliasRules",
20
+ "Pattern",
21
+ "PatternTooLongError",
22
+ "Resolution",
23
+ "aggregate_aliases",
24
+ "compile_pattern",
25
+ "glob_match",
26
+ "matches",
27
+ "prefilter_fragment",
28
+ "resolve_alias",
29
+ "validate_header_names",
30
+ ]
@@ -0,0 +1,53 @@
1
+ """Aggregation for ``list_aliases`` (R§5): aliases seen with their message counts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections import Counter
6
+ from collections.abc import Iterable, Mapping, Sequence
7
+ from dataclasses import dataclass
8
+ from typing import Final
9
+
10
+ from mailferret.aliases.resolver import resolve_alias
11
+ from mailferret.aliases.rules import AliasRules
12
+ from mailferret.limits import Limits
13
+
14
+ _DEFAULT_LIMITS: Final = Limits()
15
+
16
+
17
+ @dataclass(frozen=True, slots=True)
18
+ class AliasCount:
19
+ address: str
20
+ count: int
21
+
22
+
23
+ @dataclass(frozen=True, slots=True)
24
+ class Aggregation:
25
+ aliases: list[AliasCount]
26
+ scanned: int
27
+ truncated: bool
28
+
29
+
30
+ def aggregate_aliases(
31
+ messages: Iterable[Mapping[str, Sequence[str | bytes]]],
32
+ rules: AliasRules,
33
+ limits: Limits = _DEFAULT_LIMITS,
34
+ ) -> Aggregation:
35
+ """Count the resolved alias per message, most frequent first, ties by address.
36
+
37
+ Stops after ``max_alias_scan`` (L-17) messages. ``truncated`` is set when more remain or a
38
+ message's headers were cut by an input bound (L-04, L-05, L-30, L-31).
39
+ """
40
+ counts: Counter[str] = Counter()
41
+ scanned = 0
42
+ truncated = False
43
+ for headers in messages:
44
+ if scanned >= limits.max_alias_scan:
45
+ truncated = True
46
+ break
47
+ scanned += 1
48
+ resolution = resolve_alias(headers, rules, limits)
49
+ truncated = truncated or resolution.truncated
50
+ if resolution.alias is not None:
51
+ counts[resolution.alias.address] += 1
52
+ ranked = sorted(counts.items(), key=lambda item: (-item[1], item[0]))
53
+ return Aggregation([AliasCount(a, n) for a, n in ranked], scanned, truncated)
@@ -0,0 +1,85 @@
1
+ """Exact and wildcard alias patterns, matched client-side only (T-09, A§2.6)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ from typing import Final
7
+
8
+ from mailferret.limits import Limits
9
+
10
+ _DEFAULT_LIMITS: Final = Limits()
11
+ MIN_PREFILTER_CHARS: Final = 3
12
+
13
+
14
+ @dataclass(frozen=True, slots=True)
15
+ class Pattern:
16
+ text: str
17
+ wildcard: bool
18
+
19
+
20
+ class PatternTooLongError(ValueError):
21
+ """An L-23 breach: the server maps it to ``limit_exceeded``."""
22
+
23
+ limit_id: Final = "L-23"
24
+
25
+
26
+ def compile_pattern(raw: str, limits: Limits = _DEFAULT_LIMITS) -> Pattern:
27
+ """Validate and lower-case a pattern; ``*`` and ``?`` are the only metacharacters.
28
+
29
+ Raises ``PatternTooLongError`` over L-23, checked again after lower-casing, which can
30
+ lengthen the text. Raises a plain ``ValueError`` for an empty or control-bearing pattern.
31
+ """
32
+ if not raw:
33
+ raise ValueError("alias pattern is empty")
34
+ if len(raw) > limits.max_query_chars:
35
+ raise PatternTooLongError("alias pattern is too long")
36
+ if any(ord(c) < 0x20 or 0x7F <= ord(c) < 0xA0 for c in raw):
37
+ raise ValueError("alias pattern contains control characters")
38
+ text = raw.lower()
39
+ if len(text) > limits.max_query_chars:
40
+ raise PatternTooLongError("alias pattern is too long")
41
+ return Pattern(text, "*" in text or "?" in text)
42
+
43
+
44
+ def glob_match(pattern: str, text: str) -> bool:
45
+ """Iterative ``*``/``?`` match with no backtracking blow-up and no character classes."""
46
+ p = t = 0
47
+ star = -1
48
+ mark = 0
49
+ while t < len(text):
50
+ if p < len(pattern) and pattern[p] == "*":
51
+ star = p
52
+ mark = t
53
+ p += 1
54
+ elif p < len(pattern) and (pattern[p] == "?" or pattern[p] == text[t]):
55
+ p += 1
56
+ t += 1
57
+ elif star >= 0:
58
+ p = star + 1
59
+ mark += 1
60
+ t = mark
61
+ else:
62
+ return False
63
+ while p < len(pattern) and pattern[p] == "*":
64
+ p += 1
65
+ return p == len(pattern)
66
+
67
+
68
+ def matches(pattern: Pattern, address: str) -> bool:
69
+ """``address`` must already be lower-case (as ``Alias.address`` is)."""
70
+ if pattern.wildcard:
71
+ return glob_match(pattern.text, address)
72
+ return pattern.text == address
73
+
74
+
75
+ def prefilter_fragment(pattern: Pattern) -> str | None:
76
+ """The literal text for the server-side prefilter (A§2.6).
77
+
78
+ An exact pattern is its own fragment. A wildcard yields its longest literal run when that
79
+ has at least ``MIN_PREFILTER_CHARS`` characters, else ``None`` (no prefilter).
80
+ """
81
+ if not pattern.wildcard:
82
+ return pattern.text
83
+ runs = [run for chunk in pattern.text.split("*") for run in chunk.split("?")]
84
+ best = max(runs, key=len, default="")
85
+ return best if len(best) >= MIN_PREFILTER_CHARS else None