mcs-driver-mail 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.
- mcs_driver_mail-0.1.0/LICENSE +201 -0
- mcs_driver_mail-0.1.0/PKG-INFO +106 -0
- mcs_driver_mail-0.1.0/README.md +70 -0
- mcs_driver_mail-0.1.0/pyproject.toml +52 -0
- mcs_driver_mail-0.1.0/setup.cfg +4 -0
- mcs_driver_mail-0.1.0/src/mcs/driver/mail/__init__.py +4 -0
- mcs_driver_mail-0.1.0/src/mcs/driver/mail/driver.py +79 -0
- mcs_driver_mail-0.1.0/src/mcs/driver/mail/inspector.py +115 -0
- mcs_driver_mail-0.1.0/src/mcs/driver/mail/tooldriver.py +98 -0
- mcs_driver_mail-0.1.0/src/mcs_driver_mail.egg-info/PKG-INFO +106 -0
- mcs_driver_mail-0.1.0/src/mcs_driver_mail.egg-info/SOURCES.txt +14 -0
- mcs_driver_mail-0.1.0/src/mcs_driver_mail.egg-info/dependency_links.txt +1 -0
- mcs_driver_mail-0.1.0/src/mcs_driver_mail.egg-info/requires.txt +15 -0
- mcs_driver_mail-0.1.0/src/mcs_driver_mail.egg-info/top_level.txt +1 -0
- mcs_driver_mail-0.1.0/tests/test_driver.py +82 -0
- mcs_driver_mail-0.1.0/tests/test_tooldriver.py +94 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcs-driver-mail
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Composite mail driver for the Model Context Standard -- read, organise, and send e-mail.
|
|
5
|
+
Author-email: Danny Gerst <danny@dannygerst.de>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://www.modelcontextstandard.io
|
|
8
|
+
Project-URL: Source, https://github.com/modelcontextstandard/python-sdk
|
|
9
|
+
Keywords: mcs,modelcontextstandard,driver,mail,email,composite
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Communications :: Email
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: mcs-driver-core>=0.2
|
|
25
|
+
Requires-Dist: mcs-driver-mailread>=0.1
|
|
26
|
+
Requires-Dist: mcs-driver-mailsend>=0.1
|
|
27
|
+
Provides-Extra: imap
|
|
28
|
+
Requires-Dist: mcs-adapter-imap>=0.1; extra == "imap"
|
|
29
|
+
Provides-Extra: smtp
|
|
30
|
+
Requires-Dist: mcs-adapter-smtp>=0.1; extra == "smtp"
|
|
31
|
+
Provides-Extra: inspector
|
|
32
|
+
Requires-Dist: mcs-inspector>=0.1; extra == "inspector"
|
|
33
|
+
Provides-Extra: all
|
|
34
|
+
Requires-Dist: mcs-driver-mail[imap,inspector,smtp]; extra == "all"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# mcs-driver-mail
|
|
38
|
+
|
|
39
|
+
Composite mail driver for the **Model Context Standard (MCS)**.
|
|
40
|
+
|
|
41
|
+
Combines `mcs-driver-mailread` and `mcs-driver-mailsend` into a single driver
|
|
42
|
+
that exposes all 9 tools (7 read + 2 send). This demonstrates the MCS driver
|
|
43
|
+
stacking / composition pattern -- build focused drivers, then combine them.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install mcs-driver-mail
|
|
49
|
+
|
|
50
|
+
# With IMAP + SMTP adapters
|
|
51
|
+
pip install mcs-driver-mail[imap,smtp]
|
|
52
|
+
|
|
53
|
+
# Everything including inspector
|
|
54
|
+
pip install mcs-driver-mail[all]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from mcs.driver.mail import MailToolDriver
|
|
61
|
+
|
|
62
|
+
td = MailToolDriver(
|
|
63
|
+
read_adapter="imap",
|
|
64
|
+
send_adapter="smtp",
|
|
65
|
+
read_kwargs=dict(host="imap.example.com", user="alice@example.com", password="..."),
|
|
66
|
+
send_kwargs=dict(host="smtp.example.com", user="alice@example.com", password="...",
|
|
67
|
+
sender_name="Alice Smith"),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
tools = td.list_tools() # 9 tools (7 read + 2 send)
|
|
71
|
+
td.execute_tool("list_folders", {})
|
|
72
|
+
td.execute_tool("send_message", {"to": "bob@example.com", "subject": "Hi", "body": "Hello"})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Tools
|
|
76
|
+
|
|
77
|
+
| Tool | Source | Description |
|
|
78
|
+
|---------------------|--------------|----------------------------------------|
|
|
79
|
+
| `list_folders` | mailread | List all mailbox folders |
|
|
80
|
+
| `list_messages` | mailread | List message summaries in a folder |
|
|
81
|
+
| `fetch_message` | mailread | Fetch a full message by UID |
|
|
82
|
+
| `search_messages` | mailread | Search messages by criteria |
|
|
83
|
+
| `move_message` | mailread | Move a message to another folder |
|
|
84
|
+
| `set_flags` | mailread | Add or remove flags on a message |
|
|
85
|
+
| `create_folder` | mailread | Create a new mailbox folder |
|
|
86
|
+
| `send_message` | mailsend | Send a plain-text e-mail |
|
|
87
|
+
| `send_html_message` | mailsend | Send an HTML e-mail with text fallback |
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
mcs-driver-mail (composite)
|
|
93
|
+
├── mcs-driver-mailread ← mcs-adapter-imap (or Gmail, Graph, ...)
|
|
94
|
+
└── mcs-driver-mailsend ← mcs-adapter-smtp (or Gmail, Graph, ...)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Each sub-driver is protocol-agnostic -- swap adapters without changing driver code.
|
|
98
|
+
|
|
99
|
+
## Links
|
|
100
|
+
|
|
101
|
+
- **Homepage:** <https://www.modelcontextstandard.io>
|
|
102
|
+
- **Source:** <https://github.com/modelcontextstandard/python-sdk>
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
Apache-2.0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# mcs-driver-mail
|
|
2
|
+
|
|
3
|
+
Composite mail driver for the **Model Context Standard (MCS)**.
|
|
4
|
+
|
|
5
|
+
Combines `mcs-driver-mailread` and `mcs-driver-mailsend` into a single driver
|
|
6
|
+
that exposes all 9 tools (7 read + 2 send). This demonstrates the MCS driver
|
|
7
|
+
stacking / composition pattern -- build focused drivers, then combine them.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install mcs-driver-mail
|
|
13
|
+
|
|
14
|
+
# With IMAP + SMTP adapters
|
|
15
|
+
pip install mcs-driver-mail[imap,smtp]
|
|
16
|
+
|
|
17
|
+
# Everything including inspector
|
|
18
|
+
pip install mcs-driver-mail[all]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from mcs.driver.mail import MailToolDriver
|
|
25
|
+
|
|
26
|
+
td = MailToolDriver(
|
|
27
|
+
read_adapter="imap",
|
|
28
|
+
send_adapter="smtp",
|
|
29
|
+
read_kwargs=dict(host="imap.example.com", user="alice@example.com", password="..."),
|
|
30
|
+
send_kwargs=dict(host="smtp.example.com", user="alice@example.com", password="...",
|
|
31
|
+
sender_name="Alice Smith"),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
tools = td.list_tools() # 9 tools (7 read + 2 send)
|
|
35
|
+
td.execute_tool("list_folders", {})
|
|
36
|
+
td.execute_tool("send_message", {"to": "bob@example.com", "subject": "Hi", "body": "Hello"})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Tools
|
|
40
|
+
|
|
41
|
+
| Tool | Source | Description |
|
|
42
|
+
|---------------------|--------------|----------------------------------------|
|
|
43
|
+
| `list_folders` | mailread | List all mailbox folders |
|
|
44
|
+
| `list_messages` | mailread | List message summaries in a folder |
|
|
45
|
+
| `fetch_message` | mailread | Fetch a full message by UID |
|
|
46
|
+
| `search_messages` | mailread | Search messages by criteria |
|
|
47
|
+
| `move_message` | mailread | Move a message to another folder |
|
|
48
|
+
| `set_flags` | mailread | Add or remove flags on a message |
|
|
49
|
+
| `create_folder` | mailread | Create a new mailbox folder |
|
|
50
|
+
| `send_message` | mailsend | Send a plain-text e-mail |
|
|
51
|
+
| `send_html_message` | mailsend | Send an HTML e-mail with text fallback |
|
|
52
|
+
|
|
53
|
+
## Architecture
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
mcs-driver-mail (composite)
|
|
57
|
+
├── mcs-driver-mailread ← mcs-adapter-imap (or Gmail, Graph, ...)
|
|
58
|
+
└── mcs-driver-mailsend ← mcs-adapter-smtp (or Gmail, Graph, ...)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Each sub-driver is protocol-agnostic -- swap adapters without changing driver code.
|
|
62
|
+
|
|
63
|
+
## Links
|
|
64
|
+
|
|
65
|
+
- **Homepage:** <https://www.modelcontextstandard.io>
|
|
66
|
+
- **Source:** <https://github.com/modelcontextstandard/python-sdk>
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
Apache-2.0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=63", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mcs-driver-mail"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Composite mail driver for the Model Context Standard -- read, organise, and send e-mail."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
keywords = ["mcs", "modelcontextstandard", "driver", "mail", "email", "composite"]
|
|
13
|
+
authors = [{ name = "Danny Gerst", email = "danny@dannygerst.de" }]
|
|
14
|
+
license-files = ["LICENSE"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Communications :: Email",
|
|
25
|
+
"Topic :: Software Development :: Libraries",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
urls = {"Homepage" = "https://www.modelcontextstandard.io", "Source" = "https://github.com/modelcontextstandard/python-sdk"}
|
|
30
|
+
|
|
31
|
+
dependencies = [
|
|
32
|
+
"mcs-driver-core>=0.2",
|
|
33
|
+
"mcs-driver-mailread>=0.1",
|
|
34
|
+
"mcs-driver-mailsend>=0.1",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
imap = ["mcs-adapter-imap>=0.1"]
|
|
39
|
+
smtp = ["mcs-adapter-smtp>=0.1"]
|
|
40
|
+
inspector = ["mcs-inspector>=0.1"]
|
|
41
|
+
all = ["mcs-driver-mail[imap,smtp,inspector]"]
|
|
42
|
+
|
|
43
|
+
[tool.uv.sources]
|
|
44
|
+
mcs-driver-core = { workspace = true }
|
|
45
|
+
mcs-driver-mailread = { workspace = true }
|
|
46
|
+
mcs-driver-mailsend = { workspace = true }
|
|
47
|
+
mcs-adapter-imap = { workspace = true }
|
|
48
|
+
mcs-adapter-smtp = { workspace = true }
|
|
49
|
+
mcs-inspector = { workspace = true }
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.packages.find]
|
|
52
|
+
where = ["src"]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""MCS Hybrid Driver for full e-mail access (read + send).
|
|
2
|
+
|
|
3
|
+
Composite driver that stacks ``MailreadToolDriver`` and
|
|
4
|
+
``MailsendToolDriver``, inheriting prompt generation from ``DriverBase``.
|
|
5
|
+
|
|
6
|
+
See Section 4 of the MCS specification for the hybrid driver pattern.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
from mcs.driver.core import (
|
|
15
|
+
DriverBase,
|
|
16
|
+
DriverBinding,
|
|
17
|
+
DriverMeta,
|
|
18
|
+
MCSToolDriver,
|
|
19
|
+
PromptStrategy,
|
|
20
|
+
Tool,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class _MailDriverMeta(DriverMeta):
|
|
26
|
+
id: str = "c4e8f1a2-mail-4006-9000-maildriver0001"
|
|
27
|
+
name: str = "Mail MCS Driver"
|
|
28
|
+
version: str = "0.1.0"
|
|
29
|
+
bindings: tuple[DriverBinding, ...] = (
|
|
30
|
+
DriverBinding(capability="mailread", adapter="*", spec_format="Custom"),
|
|
31
|
+
DriverBinding(capability="mailsend", adapter="*", spec_format="Custom"),
|
|
32
|
+
)
|
|
33
|
+
supported_llms: tuple[str, ...] = ("*",)
|
|
34
|
+
capabilities: tuple[str, ...] = ("standalone", "orchestratable")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class MailDriver(DriverBase):
|
|
38
|
+
"""Hybrid composite mail driver: read + send e-mail.
|
|
39
|
+
|
|
40
|
+
Use this driver when you need the LLM to have full e-mail access
|
|
41
|
+
(read, organise, and send) through a single driver.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
meta: DriverMeta = _MailDriverMeta()
|
|
45
|
+
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
*,
|
|
49
|
+
read_adapter: str = "imap",
|
|
50
|
+
send_adapter: str = "smtp",
|
|
51
|
+
read_kwargs: dict[str, Any] | None = None,
|
|
52
|
+
send_kwargs: dict[str, Any] | None = None,
|
|
53
|
+
custom_tool_description: str | None = None,
|
|
54
|
+
custom_driver_system_message: str | None = None,
|
|
55
|
+
prompt_strategy: PromptStrategy | None = None,
|
|
56
|
+
_tooldriver: MCSToolDriver | None = None,
|
|
57
|
+
) -> None:
|
|
58
|
+
super().__init__(
|
|
59
|
+
prompt_strategy=prompt_strategy,
|
|
60
|
+
custom_tool_description=custom_tool_description,
|
|
61
|
+
custom_system_message=custom_driver_system_message,
|
|
62
|
+
)
|
|
63
|
+
if _tooldriver is not None:
|
|
64
|
+
self._td = _tooldriver
|
|
65
|
+
else:
|
|
66
|
+
from mcs.driver.mail.tooldriver import MailToolDriver
|
|
67
|
+
|
|
68
|
+
self._td = MailToolDriver(
|
|
69
|
+
read_adapter=read_adapter,
|
|
70
|
+
send_adapter=send_adapter,
|
|
71
|
+
read_kwargs=read_kwargs,
|
|
72
|
+
send_kwargs=send_kwargs,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
def list_tools(self) -> list[Tool]:
|
|
76
|
+
return self._td.list_tools()
|
|
77
|
+
|
|
78
|
+
def execute_tool(self, tool_name: str, arguments: dict[str, Any]) -> Any:
|
|
79
|
+
return self._td.execute_tool(tool_name, arguments)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""MCS Mail Inspector -- test connections and explore all mail tools interactively.
|
|
2
|
+
|
|
3
|
+
Run directly::
|
|
4
|
+
|
|
5
|
+
python -m mcs.driver.mail.inspector \\
|
|
6
|
+
--read-host imap.example.com --read-user alice@example.com \\
|
|
7
|
+
--send-host smtp.example.com --send-user alice@example.com
|
|
8
|
+
|
|
9
|
+
Or preferably via the unified CLI::
|
|
10
|
+
|
|
11
|
+
mcs-inspect mail \\
|
|
12
|
+
--read-host imap.example.com --read-user alice@example.com \\
|
|
13
|
+
--send-host smtp.example.com --send-user alice@example.com
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import argparse
|
|
19
|
+
import getpass
|
|
20
|
+
import json
|
|
21
|
+
import sys
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _parse_args() -> argparse.Namespace:
|
|
25
|
+
p = argparse.ArgumentParser(
|
|
26
|
+
prog="mcs-mail-inspector",
|
|
27
|
+
description="Inspect a full mail setup (read + send) -- test connections, browse tools, execute calls.",
|
|
28
|
+
)
|
|
29
|
+
# Read (mailbox) settings
|
|
30
|
+
p.add_argument("--read-host", required=True, help="Mailbox server hostname (e.g. imap.gmail.com)")
|
|
31
|
+
p.add_argument("--read-user", required=True, help="Mailbox login username")
|
|
32
|
+
p.add_argument("--read-password", default=None, help="Mailbox password (prompted if omitted)")
|
|
33
|
+
p.add_argument("--read-port", type=int, default=None, help="Mailbox server port")
|
|
34
|
+
p.add_argument("--read-no-ssl", action="store_true", help="Disable implicit SSL for reading")
|
|
35
|
+
p.add_argument("--read-starttls", action="store_true", help="Use STARTTLS for reading")
|
|
36
|
+
p.add_argument("--read-adapter", default="imap", help="Read adapter (default: imap)")
|
|
37
|
+
|
|
38
|
+
# Send settings
|
|
39
|
+
p.add_argument("--send-host", required=True, help="Mail-sending server hostname (e.g. smtp.gmail.com)")
|
|
40
|
+
p.add_argument("--send-user", required=True, help="Mail-sending login username")
|
|
41
|
+
p.add_argument("--send-password", default=None, help="Send password (prompted if omitted)")
|
|
42
|
+
p.add_argument("--send-port", type=int, default=None, help="Send server port")
|
|
43
|
+
p.add_argument("--send-ssl", action="store_true", help="Use implicit SSL for sending")
|
|
44
|
+
p.add_argument("--send-no-starttls", action="store_true", help="Disable STARTTLS for sending")
|
|
45
|
+
p.add_argument("--send-sender", default=None, help="Sender address (default: send-user)")
|
|
46
|
+
p.add_argument("--send-adapter", default="smtp", help="Send adapter (default: smtp)")
|
|
47
|
+
return p.parse_args()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def main() -> None:
|
|
51
|
+
args = _parse_args()
|
|
52
|
+
read_pw = args.read_password or getpass.getpass(f"Read password for {args.read_user}@{args.read_host}: ")
|
|
53
|
+
send_pw = args.send_password or getpass.getpass(f"Send password for {args.send_user}@{args.send_host}: ")
|
|
54
|
+
|
|
55
|
+
from mcs.driver.mail import MailToolDriver
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
from mcs.inspector import run_inspector
|
|
59
|
+
has_inspector = True
|
|
60
|
+
except ImportError:
|
|
61
|
+
has_inspector = False
|
|
62
|
+
|
|
63
|
+
print(f"\nSetting up mail driver...")
|
|
64
|
+
print(f" Read: {args.read_host} ({args.read_adapter})")
|
|
65
|
+
print(f" Send: {args.send_host} ({args.send_adapter})")
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
td = MailToolDriver(
|
|
69
|
+
read_adapter=args.read_adapter,
|
|
70
|
+
send_adapter=args.send_adapter,
|
|
71
|
+
read_kwargs=dict(
|
|
72
|
+
host=args.read_host,
|
|
73
|
+
user=args.read_user,
|
|
74
|
+
password=read_pw,
|
|
75
|
+
port=args.read_port,
|
|
76
|
+
ssl=not args.read_no_ssl,
|
|
77
|
+
starttls=args.read_starttls,
|
|
78
|
+
),
|
|
79
|
+
send_kwargs=dict(
|
|
80
|
+
host=args.send_host,
|
|
81
|
+
user=args.send_user,
|
|
82
|
+
password=send_pw,
|
|
83
|
+
port=args.send_port,
|
|
84
|
+
ssl=args.send_ssl,
|
|
85
|
+
starttls=not args.send_no_starttls,
|
|
86
|
+
sender=args.send_sender,
|
|
87
|
+
),
|
|
88
|
+
)
|
|
89
|
+
except Exception as exc:
|
|
90
|
+
print(f"Failed to create driver: {exc}", file=sys.stderr)
|
|
91
|
+
sys.exit(1)
|
|
92
|
+
|
|
93
|
+
# Test read connection
|
|
94
|
+
try:
|
|
95
|
+
folders = json.loads(td.execute_tool("list_folders", {}))
|
|
96
|
+
print(f"Mailbox connected. Found {len(folders)} folders: {', '.join(folders[:8])}")
|
|
97
|
+
except Exception as exc:
|
|
98
|
+
print(f"Mailbox connection failed: {exc}", file=sys.stderr)
|
|
99
|
+
sys.exit(1)
|
|
100
|
+
|
|
101
|
+
if has_inspector:
|
|
102
|
+
run_inspector(td, title="Mail Inspector (read + send)")
|
|
103
|
+
else:
|
|
104
|
+
print(f"\nDiscovered {len(td.list_tools())} tools:")
|
|
105
|
+
for i, tool in enumerate(td.list_tools(), 1):
|
|
106
|
+
params = [p.name for p in tool.parameters]
|
|
107
|
+
print(f" {i:3d}. {tool.name:20s} | {tool.title or ''} | params={params}")
|
|
108
|
+
print(
|
|
109
|
+
"\nInstall mcs-inspector for the full interactive experience:\n"
|
|
110
|
+
" pip install mcs-inspector[mail]"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
main()
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""MCS Composite ToolDriver for full e-mail access (read + send).
|
|
2
|
+
|
|
3
|
+
Stacks ``MailreadToolDriver`` and ``MailsendToolDriver`` into a single
|
|
4
|
+
ToolDriver that exposes all ten tools. This demonstrates MCS driver
|
|
5
|
+
composition -- two single-responsibility drivers combined into one
|
|
6
|
+
unified interface for the LLM.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from typing import Any, Dict, List
|
|
14
|
+
|
|
15
|
+
from mcs.driver.core import (
|
|
16
|
+
DriverBinding,
|
|
17
|
+
DriverMeta,
|
|
18
|
+
MCSToolDriver,
|
|
19
|
+
Tool,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass(frozen=True)
|
|
26
|
+
class _MailToolDriverMeta(DriverMeta):
|
|
27
|
+
id: str = "c4e8f1a2-mail-4005-9000-mailtooldrv001"
|
|
28
|
+
name: str = "Mail MCS ToolDriver"
|
|
29
|
+
version: str = "0.1.0"
|
|
30
|
+
bindings: tuple[DriverBinding, ...] = (
|
|
31
|
+
DriverBinding(capability="mailread", adapter="*", spec_format="Custom"),
|
|
32
|
+
DriverBinding(capability="mailsend", adapter="*", spec_format="Custom"),
|
|
33
|
+
)
|
|
34
|
+
supported_llms: None = None
|
|
35
|
+
capabilities: tuple[str, ...] = ("orchestratable",)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class MailToolDriver(MCSToolDriver):
|
|
39
|
+
"""Composite ToolDriver that stacks mailread + mailsend.
|
|
40
|
+
|
|
41
|
+
Accepts either pre-built ToolDrivers or adapter names with kwargs
|
|
42
|
+
for automatic construction.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
read_adapter :
|
|
47
|
+
Adapter name for mail reading (default: ``"imap"``).
|
|
48
|
+
send_adapter :
|
|
49
|
+
Adapter name for mail sending (default: ``"smtp"``).
|
|
50
|
+
_read_driver :
|
|
51
|
+
Inject a pre-built ``MailreadToolDriver`` (for testing / custom setups).
|
|
52
|
+
_send_driver :
|
|
53
|
+
Inject a pre-built ``MailsendToolDriver`` (for testing / custom setups).
|
|
54
|
+
read_kwargs :
|
|
55
|
+
Keyword arguments forwarded to the read adapter constructor.
|
|
56
|
+
send_kwargs :
|
|
57
|
+
Keyword arguments forwarded to the send adapter constructor.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
meta: DriverMeta = _MailToolDriverMeta()
|
|
61
|
+
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
*,
|
|
65
|
+
read_adapter: str = "imap",
|
|
66
|
+
send_adapter: str = "smtp",
|
|
67
|
+
_read_driver: MCSToolDriver | None = None,
|
|
68
|
+
_send_driver: MCSToolDriver | None = None,
|
|
69
|
+
read_kwargs: dict[str, Any] | None = None,
|
|
70
|
+
send_kwargs: dict[str, Any] | None = None,
|
|
71
|
+
) -> None:
|
|
72
|
+
if _read_driver is not None:
|
|
73
|
+
self._read = _read_driver
|
|
74
|
+
else:
|
|
75
|
+
from mcs.driver.mailread import MailreadToolDriver
|
|
76
|
+
self._read = MailreadToolDriver(adapter=read_adapter, **(read_kwargs or {}))
|
|
77
|
+
|
|
78
|
+
if _send_driver is not None:
|
|
79
|
+
self._send = _send_driver
|
|
80
|
+
else:
|
|
81
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
82
|
+
self._send = MailsendToolDriver(adapter=send_adapter, **(send_kwargs or {}))
|
|
83
|
+
|
|
84
|
+
# Build lookup: tool_name → owning driver
|
|
85
|
+
self._dispatch: dict[str, MCSToolDriver] = {}
|
|
86
|
+
for tool in self._read.list_tools():
|
|
87
|
+
self._dispatch[tool.name] = self._read
|
|
88
|
+
for tool in self._send.list_tools():
|
|
89
|
+
self._dispatch[tool.name] = self._send
|
|
90
|
+
|
|
91
|
+
def list_tools(self) -> List[Tool]:
|
|
92
|
+
return self._read.list_tools() + self._send.list_tools()
|
|
93
|
+
|
|
94
|
+
def execute_tool(self, tool_name: str, arguments: Dict[str, Any]) -> Any:
|
|
95
|
+
driver = self._dispatch.get(tool_name)
|
|
96
|
+
if driver is None:
|
|
97
|
+
raise ValueError(f"Unknown tool: {tool_name}")
|
|
98
|
+
return driver.execute_tool(tool_name, arguments)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcs-driver-mail
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Composite mail driver for the Model Context Standard -- read, organise, and send e-mail.
|
|
5
|
+
Author-email: Danny Gerst <danny@dannygerst.de>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://www.modelcontextstandard.io
|
|
8
|
+
Project-URL: Source, https://github.com/modelcontextstandard/python-sdk
|
|
9
|
+
Keywords: mcs,modelcontextstandard,driver,mail,email,composite
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Communications :: Email
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: mcs-driver-core>=0.2
|
|
25
|
+
Requires-Dist: mcs-driver-mailread>=0.1
|
|
26
|
+
Requires-Dist: mcs-driver-mailsend>=0.1
|
|
27
|
+
Provides-Extra: imap
|
|
28
|
+
Requires-Dist: mcs-adapter-imap>=0.1; extra == "imap"
|
|
29
|
+
Provides-Extra: smtp
|
|
30
|
+
Requires-Dist: mcs-adapter-smtp>=0.1; extra == "smtp"
|
|
31
|
+
Provides-Extra: inspector
|
|
32
|
+
Requires-Dist: mcs-inspector>=0.1; extra == "inspector"
|
|
33
|
+
Provides-Extra: all
|
|
34
|
+
Requires-Dist: mcs-driver-mail[imap,inspector,smtp]; extra == "all"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# mcs-driver-mail
|
|
38
|
+
|
|
39
|
+
Composite mail driver for the **Model Context Standard (MCS)**.
|
|
40
|
+
|
|
41
|
+
Combines `mcs-driver-mailread` and `mcs-driver-mailsend` into a single driver
|
|
42
|
+
that exposes all 9 tools (7 read + 2 send). This demonstrates the MCS driver
|
|
43
|
+
stacking / composition pattern -- build focused drivers, then combine them.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install mcs-driver-mail
|
|
49
|
+
|
|
50
|
+
# With IMAP + SMTP adapters
|
|
51
|
+
pip install mcs-driver-mail[imap,smtp]
|
|
52
|
+
|
|
53
|
+
# Everything including inspector
|
|
54
|
+
pip install mcs-driver-mail[all]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from mcs.driver.mail import MailToolDriver
|
|
61
|
+
|
|
62
|
+
td = MailToolDriver(
|
|
63
|
+
read_adapter="imap",
|
|
64
|
+
send_adapter="smtp",
|
|
65
|
+
read_kwargs=dict(host="imap.example.com", user="alice@example.com", password="..."),
|
|
66
|
+
send_kwargs=dict(host="smtp.example.com", user="alice@example.com", password="...",
|
|
67
|
+
sender_name="Alice Smith"),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
tools = td.list_tools() # 9 tools (7 read + 2 send)
|
|
71
|
+
td.execute_tool("list_folders", {})
|
|
72
|
+
td.execute_tool("send_message", {"to": "bob@example.com", "subject": "Hi", "body": "Hello"})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Tools
|
|
76
|
+
|
|
77
|
+
| Tool | Source | Description |
|
|
78
|
+
|---------------------|--------------|----------------------------------------|
|
|
79
|
+
| `list_folders` | mailread | List all mailbox folders |
|
|
80
|
+
| `list_messages` | mailread | List message summaries in a folder |
|
|
81
|
+
| `fetch_message` | mailread | Fetch a full message by UID |
|
|
82
|
+
| `search_messages` | mailread | Search messages by criteria |
|
|
83
|
+
| `move_message` | mailread | Move a message to another folder |
|
|
84
|
+
| `set_flags` | mailread | Add or remove flags on a message |
|
|
85
|
+
| `create_folder` | mailread | Create a new mailbox folder |
|
|
86
|
+
| `send_message` | mailsend | Send a plain-text e-mail |
|
|
87
|
+
| `send_html_message` | mailsend | Send an HTML e-mail with text fallback |
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
mcs-driver-mail (composite)
|
|
93
|
+
├── mcs-driver-mailread ← mcs-adapter-imap (or Gmail, Graph, ...)
|
|
94
|
+
└── mcs-driver-mailsend ← mcs-adapter-smtp (or Gmail, Graph, ...)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Each sub-driver is protocol-agnostic -- swap adapters without changing driver code.
|
|
98
|
+
|
|
99
|
+
## Links
|
|
100
|
+
|
|
101
|
+
- **Homepage:** <https://www.modelcontextstandard.io>
|
|
102
|
+
- **Source:** <https://github.com/modelcontextstandard/python-sdk>
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
Apache-2.0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/mcs/driver/mail/__init__.py
|
|
5
|
+
src/mcs/driver/mail/driver.py
|
|
6
|
+
src/mcs/driver/mail/inspector.py
|
|
7
|
+
src/mcs/driver/mail/tooldriver.py
|
|
8
|
+
src/mcs_driver_mail.egg-info/PKG-INFO
|
|
9
|
+
src/mcs_driver_mail.egg-info/SOURCES.txt
|
|
10
|
+
src/mcs_driver_mail.egg-info/dependency_links.txt
|
|
11
|
+
src/mcs_driver_mail.egg-info/requires.txt
|
|
12
|
+
src/mcs_driver_mail.egg-info/top_level.txt
|
|
13
|
+
tests/test_driver.py
|
|
14
|
+
tests/test_tooldriver.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mcs
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Tests for MailDriver (composite HybridDriver)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from mcs.driver.mail import MailDriver, MailToolDriver
|
|
10
|
+
from mcs.driver.mailread import MailreadToolDriver
|
|
11
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FakeMailboxAdapter:
|
|
15
|
+
def list_folders(self) -> str:
|
|
16
|
+
return json.dumps(["INBOX"])
|
|
17
|
+
|
|
18
|
+
def list_messages(self, folder="INBOX", *, limit=20) -> str:
|
|
19
|
+
return json.dumps([])
|
|
20
|
+
|
|
21
|
+
def fetch_message(self, uid, folder="INBOX") -> str:
|
|
22
|
+
return json.dumps({"uid": uid})
|
|
23
|
+
|
|
24
|
+
def move_message(self, uid, destination, folder="INBOX") -> str:
|
|
25
|
+
return json.dumps({"moved": uid})
|
|
26
|
+
|
|
27
|
+
def set_flags(self, uid, flags, *, remove=False, folder="INBOX") -> str:
|
|
28
|
+
return json.dumps({"uid": uid})
|
|
29
|
+
|
|
30
|
+
def create_folder(self, name) -> str:
|
|
31
|
+
return json.dumps({"created": name})
|
|
32
|
+
|
|
33
|
+
def search_messages(self, criteria="ALL", folder="INBOX", *, limit=20) -> str:
|
|
34
|
+
return json.dumps([])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class FakeMailsendAdapter:
|
|
38
|
+
def send_message(self, *, to, subject, body, cc="", bcc="", reply_to="") -> str:
|
|
39
|
+
return json.dumps({"status": "sent"})
|
|
40
|
+
|
|
41
|
+
def send_html_message(self, *, to, subject, html_body, text_body="",
|
|
42
|
+
cc="", bcc="", reply_to="") -> str:
|
|
43
|
+
return json.dumps({"status": "sent"})
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.fixture()
|
|
49
|
+
def driver() -> MailDriver:
|
|
50
|
+
read_td = MailreadToolDriver(_adapter=FakeMailboxAdapter())
|
|
51
|
+
send_td = MailsendToolDriver(_adapter=FakeMailsendAdapter())
|
|
52
|
+
mail_td = MailToolDriver(_read_driver=read_td, _send_driver=send_td)
|
|
53
|
+
return MailDriver(_tooldriver=mail_td)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class TestCompositeHybridDriver:
|
|
57
|
+
|
|
58
|
+
def test_system_message_not_empty(self, driver: MailDriver):
|
|
59
|
+
assert len(driver.get_driver_system_message()) > 0
|
|
60
|
+
|
|
61
|
+
def test_function_description_contains_all_tools(self, driver: MailDriver):
|
|
62
|
+
desc = driver.get_function_description()
|
|
63
|
+
assert "list_folders" in desc
|
|
64
|
+
assert "send_message" in desc
|
|
65
|
+
|
|
66
|
+
def test_list_tools_returns_nine(self, driver: MailDriver):
|
|
67
|
+
assert len(driver.list_tools()) == 9
|
|
68
|
+
|
|
69
|
+
def test_execute_read_tool(self, driver: MailDriver):
|
|
70
|
+
result = json.loads(driver.execute_tool("list_folders", {}))
|
|
71
|
+
assert "INBOX" in result
|
|
72
|
+
|
|
73
|
+
def test_execute_send_tool(self, driver: MailDriver):
|
|
74
|
+
result = json.loads(driver.execute_tool("send_message", {
|
|
75
|
+
"to": "a@b.c", "subject": "Hi", "body": "Hello",
|
|
76
|
+
}))
|
|
77
|
+
assert result["status"] == "sent"
|
|
78
|
+
|
|
79
|
+
def test_meta_attributes(self, driver: MailDriver):
|
|
80
|
+
assert driver.meta.name == "Mail MCS Driver"
|
|
81
|
+
assert "standalone" in driver.meta.capabilities
|
|
82
|
+
assert len(driver.meta.bindings) == 2
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Tests for MailToolDriver -- composite of mailread + mailsend."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from mcs.driver.mail import MailToolDriver
|
|
10
|
+
from mcs.driver.mailread import MailreadToolDriver
|
|
11
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FakeMailboxAdapter:
|
|
15
|
+
def list_folders(self) -> str:
|
|
16
|
+
return json.dumps(["INBOX", "Sent"])
|
|
17
|
+
|
|
18
|
+
def list_messages(self, folder="INBOX", *, limit=20) -> str:
|
|
19
|
+
return json.dumps([{"uid": 1, "subject": "Test"}])
|
|
20
|
+
|
|
21
|
+
def fetch_message(self, uid, folder="INBOX") -> str:
|
|
22
|
+
return json.dumps({"uid": uid, "body": "content"})
|
|
23
|
+
|
|
24
|
+
def move_message(self, uid, destination, folder="INBOX") -> str:
|
|
25
|
+
return json.dumps({"moved": uid})
|
|
26
|
+
|
|
27
|
+
def set_flags(self, uid, flags, *, remove=False, folder="INBOX") -> str:
|
|
28
|
+
return json.dumps({"uid": uid})
|
|
29
|
+
|
|
30
|
+
def create_folder(self, name) -> str:
|
|
31
|
+
return json.dumps({"created": name})
|
|
32
|
+
|
|
33
|
+
def search_messages(self, criteria="ALL", folder="INBOX", *, limit=20) -> str:
|
|
34
|
+
return json.dumps([])
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class FakeMailsendAdapter:
|
|
38
|
+
def send_message(self, *, to, subject, body, cc="", bcc="", reply_to="") -> str:
|
|
39
|
+
return json.dumps({"status": "sent", "recipients": [to], "subject": subject})
|
|
40
|
+
|
|
41
|
+
def send_html_message(self, *, to, subject, html_body, text_body="",
|
|
42
|
+
cc="", bcc="", reply_to="") -> str:
|
|
43
|
+
return json.dumps({"status": "sent", "recipients": [to], "subject": subject})
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.fixture()
|
|
49
|
+
def td() -> MailToolDriver:
|
|
50
|
+
read_td = MailreadToolDriver(_adapter=FakeMailboxAdapter())
|
|
51
|
+
send_td = MailsendToolDriver(_adapter=FakeMailsendAdapter())
|
|
52
|
+
return MailToolDriver(_read_driver=read_td, _send_driver=send_td)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class TestComposite:
|
|
56
|
+
|
|
57
|
+
def test_has_nine_tools(self, td: MailToolDriver):
|
|
58
|
+
assert len(td.list_tools()) == 9
|
|
59
|
+
|
|
60
|
+
def test_contains_read_tools(self, td: MailToolDriver):
|
|
61
|
+
names = {t.name for t in td.list_tools()}
|
|
62
|
+
assert "list_folders" in names
|
|
63
|
+
assert "fetch_message" in names
|
|
64
|
+
assert "search_messages" in names
|
|
65
|
+
|
|
66
|
+
def test_contains_send_tools(self, td: MailToolDriver):
|
|
67
|
+
names = {t.name for t in td.list_tools()}
|
|
68
|
+
assert "send_message" in names
|
|
69
|
+
assert "send_html_message" in names
|
|
70
|
+
|
|
71
|
+
def test_execute_read_tool(self, td: MailToolDriver):
|
|
72
|
+
result = json.loads(td.execute_tool("list_folders", {}))
|
|
73
|
+
assert "INBOX" in result
|
|
74
|
+
|
|
75
|
+
def test_execute_send_tool(self, td: MailToolDriver):
|
|
76
|
+
result = json.loads(td.execute_tool("send_message", {
|
|
77
|
+
"to": "alice@example.com", "subject": "Hi", "body": "Hello",
|
|
78
|
+
}))
|
|
79
|
+
assert result["status"] == "sent"
|
|
80
|
+
|
|
81
|
+
def test_unknown_tool_raises(self, td: MailToolDriver):
|
|
82
|
+
with pytest.raises(ValueError, match="Unknown tool"):
|
|
83
|
+
td.execute_tool("nonexistent", {})
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class TestDriverMeta:
|
|
87
|
+
|
|
88
|
+
def test_meta_name(self, td: MailToolDriver):
|
|
89
|
+
assert td.meta.name == "Mail MCS ToolDriver"
|
|
90
|
+
|
|
91
|
+
def test_meta_has_two_bindings(self, td: MailToolDriver):
|
|
92
|
+
assert len(td.meta.bindings) == 2
|
|
93
|
+
capabilities = {b.capability for b in td.meta.bindings}
|
|
94
|
+
assert capabilities == {"mailread", "mailsend"}
|