mcs-driver-mailsend 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_mailsend-0.1.0/LICENSE +201 -0
- mcs_driver_mailsend-0.1.0/PKG-INFO +90 -0
- mcs_driver_mailsend-0.1.0/README.md +60 -0
- mcs_driver_mailsend-0.1.0/pyproject.toml +45 -0
- mcs_driver_mailsend-0.1.0/setup.cfg +4 -0
- mcs_driver_mailsend-0.1.0/src/mcs/driver/mailsend/__init__.py +5 -0
- mcs_driver_mailsend-0.1.0/src/mcs/driver/mailsend/driver.py +72 -0
- mcs_driver_mailsend-0.1.0/src/mcs/driver/mailsend/inspector.py +83 -0
- mcs_driver_mailsend-0.1.0/src/mcs/driver/mailsend/ports.py +42 -0
- mcs_driver_mailsend-0.1.0/src/mcs/driver/mailsend/tooldriver.py +195 -0
- mcs_driver_mailsend-0.1.0/src/mcs_driver_mailsend.egg-info/PKG-INFO +90 -0
- mcs_driver_mailsend-0.1.0/src/mcs_driver_mailsend.egg-info/SOURCES.txt +15 -0
- mcs_driver_mailsend-0.1.0/src/mcs_driver_mailsend.egg-info/dependency_links.txt +1 -0
- mcs_driver_mailsend-0.1.0/src/mcs_driver_mailsend.egg-info/requires.txt +7 -0
- mcs_driver_mailsend-0.1.0/src/mcs_driver_mailsend.egg-info/top_level.txt +1 -0
- mcs_driver_mailsend-0.1.0/tests/test_driver.py +54 -0
- mcs_driver_mailsend-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,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcs-driver-mailsend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Mail-sending driver for the Model Context Standard -- lets an LLM 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,smtp
|
|
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
|
+
Provides-Extra: smtp
|
|
26
|
+
Requires-Dist: mcs-adapter-smtp>=0.1; extra == "smtp"
|
|
27
|
+
Provides-Extra: inspector
|
|
28
|
+
Requires-Dist: mcs-inspector>=0.1; extra == "inspector"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# mcs-driver-mailsend
|
|
32
|
+
|
|
33
|
+
Mail-sending driver for the **Model Context Standard (MCS)**.
|
|
34
|
+
|
|
35
|
+
Provides tools for sending plain-text and HTML e-mail. The actual I/O is
|
|
36
|
+
delegated to a pluggable adapter, making the same driver work with SMTP,
|
|
37
|
+
Gmail API, Microsoft Graph, or any future backend.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install mcs-driver-mailsend
|
|
43
|
+
|
|
44
|
+
# With SMTP adapter
|
|
45
|
+
pip install mcs-driver-mailsend[smtp]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
52
|
+
|
|
53
|
+
# SMTP (default adapter)
|
|
54
|
+
td = MailsendToolDriver(
|
|
55
|
+
adapter="smtp",
|
|
56
|
+
host="smtp.example.com",
|
|
57
|
+
user="alice@example.com",
|
|
58
|
+
password="...",
|
|
59
|
+
sender_name="Alice Smith", # optional display name
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
tools = td.list_tools() # 2 tools
|
|
63
|
+
result = td.execute_tool("send_message", {
|
|
64
|
+
"to": "bob@example.com",
|
|
65
|
+
"subject": "Hello",
|
|
66
|
+
"body": "Hi Bob!",
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Tools
|
|
71
|
+
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|---------------------|--------------------------------------------------|
|
|
74
|
+
| `send_message` | Send a plain-text e-mail |
|
|
75
|
+
| `send_html_message` | Send an HTML e-mail with optional text fallback |
|
|
76
|
+
|
|
77
|
+
## Adapter protocol
|
|
78
|
+
|
|
79
|
+
The driver defines a `MailsendPort` typing protocol. Any object that implements
|
|
80
|
+
`send_message` and `send_html_message` satisfies the contract -- no inheritance
|
|
81
|
+
required.
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- **Homepage:** <https://www.modelcontextstandard.io>
|
|
86
|
+
- **Source:** <https://github.com/modelcontextstandard/python-sdk>
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
Apache-2.0
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# mcs-driver-mailsend
|
|
2
|
+
|
|
3
|
+
Mail-sending driver for the **Model Context Standard (MCS)**.
|
|
4
|
+
|
|
5
|
+
Provides tools for sending plain-text and HTML e-mail. The actual I/O is
|
|
6
|
+
delegated to a pluggable adapter, making the same driver work with SMTP,
|
|
7
|
+
Gmail API, Microsoft Graph, or any future backend.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install mcs-driver-mailsend
|
|
13
|
+
|
|
14
|
+
# With SMTP adapter
|
|
15
|
+
pip install mcs-driver-mailsend[smtp]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
22
|
+
|
|
23
|
+
# SMTP (default adapter)
|
|
24
|
+
td = MailsendToolDriver(
|
|
25
|
+
adapter="smtp",
|
|
26
|
+
host="smtp.example.com",
|
|
27
|
+
user="alice@example.com",
|
|
28
|
+
password="...",
|
|
29
|
+
sender_name="Alice Smith", # optional display name
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
tools = td.list_tools() # 2 tools
|
|
33
|
+
result = td.execute_tool("send_message", {
|
|
34
|
+
"to": "bob@example.com",
|
|
35
|
+
"subject": "Hello",
|
|
36
|
+
"body": "Hi Bob!",
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Tools
|
|
41
|
+
|
|
42
|
+
| Tool | Description |
|
|
43
|
+
|---------------------|--------------------------------------------------|
|
|
44
|
+
| `send_message` | Send a plain-text e-mail |
|
|
45
|
+
| `send_html_message` | Send an HTML e-mail with optional text fallback |
|
|
46
|
+
|
|
47
|
+
## Adapter protocol
|
|
48
|
+
|
|
49
|
+
The driver defines a `MailsendPort` typing protocol. Any object that implements
|
|
50
|
+
`send_message` and `send_html_message` satisfies the contract -- no inheritance
|
|
51
|
+
required.
|
|
52
|
+
|
|
53
|
+
## Links
|
|
54
|
+
|
|
55
|
+
- **Homepage:** <https://www.modelcontextstandard.io>
|
|
56
|
+
- **Source:** <https://github.com/modelcontextstandard/python-sdk>
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
Apache-2.0
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=63", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mcs-driver-mailsend"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Mail-sending driver for the Model Context Standard -- lets an LLM send e-mail."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
keywords = ["mcs", "modelcontextstandard", "driver", "mail", "email", "smtp"]
|
|
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
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
smtp = ["mcs-adapter-smtp>=0.1"]
|
|
37
|
+
inspector = ["mcs-inspector>=0.1"]
|
|
38
|
+
|
|
39
|
+
[tool.uv.sources]
|
|
40
|
+
mcs-driver-core = { workspace = true }
|
|
41
|
+
mcs-adapter-smtp = { workspace = true }
|
|
42
|
+
mcs-inspector = { workspace = true }
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.packages.find]
|
|
45
|
+
where = ["src"]
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""MCS Hybrid Driver for sending e-mail.
|
|
2
|
+
|
|
3
|
+
Inherits prompt generation and LLM response parsing from ``DriverBase``.
|
|
4
|
+
Only adds ToolDriver delegation.
|
|
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 _MailsendDriverMeta(DriverMeta):
|
|
26
|
+
id: str = "c4e8f1a2-mail-4004-9000-mailsenddrv001"
|
|
27
|
+
name: str = "Mailsend MCS Driver"
|
|
28
|
+
version: str = "0.1.0"
|
|
29
|
+
bindings: tuple[DriverBinding, ...] = (
|
|
30
|
+
DriverBinding(capability="mailsend", adapter="*", spec_format="Custom"),
|
|
31
|
+
)
|
|
32
|
+
supported_llms: tuple[str, ...] = ("*",)
|
|
33
|
+
capabilities: tuple[str, ...] = ("standalone", "orchestratable")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class MailsendDriver(DriverBase):
|
|
37
|
+
"""Hybrid mail-sending driver: ``DriverBase`` prompt engine + ``MailsendToolDriver``.
|
|
38
|
+
|
|
39
|
+
Use this driver standalone (with ``get_driver_system_message()`` and
|
|
40
|
+
``process_llm_response()``) or plug it into an Orchestrator as a
|
|
41
|
+
composable ToolDriver.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
meta: DriverMeta = _MailsendDriverMeta()
|
|
45
|
+
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
*,
|
|
49
|
+
adapter: str = "smtp",
|
|
50
|
+
custom_tool_description: str | None = None,
|
|
51
|
+
custom_driver_system_message: str | None = None,
|
|
52
|
+
prompt_strategy: PromptStrategy | None = None,
|
|
53
|
+
_tooldriver: MCSToolDriver | None = None,
|
|
54
|
+
**adapter_kwargs: Any,
|
|
55
|
+
) -> None:
|
|
56
|
+
super().__init__(
|
|
57
|
+
prompt_strategy=prompt_strategy,
|
|
58
|
+
custom_tool_description=custom_tool_description,
|
|
59
|
+
custom_system_message=custom_driver_system_message,
|
|
60
|
+
)
|
|
61
|
+
if _tooldriver is not None:
|
|
62
|
+
self._td = _tooldriver
|
|
63
|
+
else:
|
|
64
|
+
from mcs.driver.mailsend.tooldriver import MailsendToolDriver
|
|
65
|
+
|
|
66
|
+
self._td = MailsendToolDriver(adapter=adapter, **adapter_kwargs)
|
|
67
|
+
|
|
68
|
+
def list_tools(self) -> list[Tool]:
|
|
69
|
+
return self._td.list_tools()
|
|
70
|
+
|
|
71
|
+
def execute_tool(self, tool_name: str, arguments: dict[str, Any]) -> Any:
|
|
72
|
+
return self._td.execute_tool(tool_name, arguments)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""MCS Mailsend Inspector -- test connections and explore tools interactively.
|
|
2
|
+
|
|
3
|
+
Run directly::
|
|
4
|
+
|
|
5
|
+
python -m mcs.driver.mailsend.inspector --host smtp.example.com --user alice@example.com
|
|
6
|
+
|
|
7
|
+
Or preferably via the unified CLI::
|
|
8
|
+
|
|
9
|
+
mcs-inspect mailsend --host smtp.example.com --user alice@example.com
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import getpass
|
|
16
|
+
import json
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _parse_args() -> argparse.Namespace:
|
|
21
|
+
p = argparse.ArgumentParser(
|
|
22
|
+
prog="mcs-mailsend-inspector",
|
|
23
|
+
description="Inspect a mail-sending server -- test connections, browse tools, execute calls.",
|
|
24
|
+
)
|
|
25
|
+
p.add_argument("--host", required=True, help="Mail server hostname")
|
|
26
|
+
p.add_argument("--user", required=True, help="Login username / e-mail")
|
|
27
|
+
p.add_argument("--password", default=None, help="Password (prompted if omitted)")
|
|
28
|
+
p.add_argument("--port", type=int, default=None, help="Server port (auto: 465/SSL, 587/STARTTLS, 25/plain)")
|
|
29
|
+
p.add_argument("--ssl", action="store_true", help="Use implicit SSL (port 465)")
|
|
30
|
+
p.add_argument("--no-starttls", action="store_true", help="Disable STARTTLS upgrade")
|
|
31
|
+
p.add_argument("--sender", default=None, help="Sender address (default: login user)")
|
|
32
|
+
p.add_argument("--sender-name", default=None, help="Display name for the sender (e.g. 'Danny Gerst')")
|
|
33
|
+
p.add_argument("--adapter", default="smtp", help="Adapter to use (default: smtp)")
|
|
34
|
+
return p.parse_args()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def main() -> None:
|
|
38
|
+
args = _parse_args()
|
|
39
|
+
password = args.password or getpass.getpass(f"Password for {args.user}@{args.host}: ")
|
|
40
|
+
|
|
41
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
42
|
+
|
|
43
|
+
try:
|
|
44
|
+
from mcs.inspector import run_inspector
|
|
45
|
+
has_inspector = True
|
|
46
|
+
except ImportError:
|
|
47
|
+
has_inspector = False
|
|
48
|
+
|
|
49
|
+
print(f"\nConnecting to {args.host} as {args.user} (adapter: {args.adapter})...")
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
td = MailsendToolDriver(
|
|
53
|
+
adapter=args.adapter,
|
|
54
|
+
host=args.host,
|
|
55
|
+
user=args.user,
|
|
56
|
+
password=password,
|
|
57
|
+
port=args.port,
|
|
58
|
+
ssl=args.ssl,
|
|
59
|
+
starttls=not args.no_starttls,
|
|
60
|
+
sender=args.sender,
|
|
61
|
+
sender_name=args.sender_name,
|
|
62
|
+
)
|
|
63
|
+
except Exception as exc:
|
|
64
|
+
print(f"Failed to create driver: {exc}", file=sys.stderr)
|
|
65
|
+
sys.exit(1)
|
|
66
|
+
|
|
67
|
+
print(f"Driver created. Ready to inspect {args.host}.")
|
|
68
|
+
|
|
69
|
+
if has_inspector:
|
|
70
|
+
run_inspector(td, title="Mailsend Inspector")
|
|
71
|
+
else:
|
|
72
|
+
print("\nDiscovered tools:")
|
|
73
|
+
for i, tool in enumerate(td.list_tools(), 1):
|
|
74
|
+
params = [p.name for p in tool.parameters]
|
|
75
|
+
print(f" {i:3d}. {tool.name:20s} | {tool.title or ''} | params={params}")
|
|
76
|
+
print(
|
|
77
|
+
"\nInstall mcs-inspector for the full interactive experience:\n"
|
|
78
|
+
" pip install mcs-inspector[mailsend]"
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
main()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Adapter port for mail-sending drivers.
|
|
2
|
+
|
|
3
|
+
Defines the contract that any mail-sending adapter must satisfy.
|
|
4
|
+
Adapters fulfil this protocol through structural subtyping -- they do
|
|
5
|
+
**not** need to import or inherit from this module.
|
|
6
|
+
|
|
7
|
+
The reference implementation is ``SmtpAdapter`` from ``mcs-adapter-smtp``.
|
|
8
|
+
Future adapters (Gmail API, Microsoft Graph, ...) only need to implement
|
|
9
|
+
these methods.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from typing import Protocol, runtime_checkable
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@runtime_checkable
|
|
18
|
+
class MailsendPort(Protocol):
|
|
19
|
+
"""Contract that any mail-sending adapter must satisfy."""
|
|
20
|
+
|
|
21
|
+
def send_message(
|
|
22
|
+
self,
|
|
23
|
+
*,
|
|
24
|
+
to: str,
|
|
25
|
+
subject: str,
|
|
26
|
+
body: str,
|
|
27
|
+
cc: str = "",
|
|
28
|
+
bcc: str = "",
|
|
29
|
+
reply_to: str = "",
|
|
30
|
+
) -> str: ...
|
|
31
|
+
|
|
32
|
+
def send_html_message(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
to: str,
|
|
36
|
+
subject: str,
|
|
37
|
+
html_body: str,
|
|
38
|
+
text_body: str = "",
|
|
39
|
+
cc: str = "",
|
|
40
|
+
bcc: str = "",
|
|
41
|
+
reply_to: str = "",
|
|
42
|
+
) -> str: ...
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""MCS ToolDriver for sending e-mail.
|
|
2
|
+
|
|
3
|
+
Provides two tools for sending plain-text and HTML e-mail.
|
|
4
|
+
Delegates all I/O to the injected adapter so the same driver works
|
|
5
|
+
with any backend that satisfies ``MailsendPort`` (SMTP, Gmail API,
|
|
6
|
+
Microsoft Graph, ...).
|
|
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
|
+
ToolParameter,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
from .ports import MailsendPort
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class _MailsendToolDriverMeta(DriverMeta):
|
|
30
|
+
id: str = "c4e8f1a2-mail-4003-9000-mailsendtd0001"
|
|
31
|
+
name: str = "Mailsend MCS ToolDriver"
|
|
32
|
+
version: str = "0.1.0"
|
|
33
|
+
bindings: tuple[DriverBinding, ...] = (
|
|
34
|
+
DriverBinding(capability="mailsend", adapter="*", spec_format="Custom"),
|
|
35
|
+
)
|
|
36
|
+
supported_llms: None = None
|
|
37
|
+
capabilities: tuple[str, ...] = ("orchestratable",)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
_TOOLS: list[Tool] = [
|
|
41
|
+
Tool(
|
|
42
|
+
name="send_message",
|
|
43
|
+
title="Send a plain-text e-mail",
|
|
44
|
+
description=(
|
|
45
|
+
"Send an e-mail with a plain-text body. Supports To, CC, BCC, "
|
|
46
|
+
"and Reply-To headers."
|
|
47
|
+
),
|
|
48
|
+
parameters=[
|
|
49
|
+
ToolParameter(
|
|
50
|
+
name="to",
|
|
51
|
+
description="Comma-separated recipient addresses.",
|
|
52
|
+
required=True,
|
|
53
|
+
schema={"type": "string"},
|
|
54
|
+
),
|
|
55
|
+
ToolParameter(
|
|
56
|
+
name="subject",
|
|
57
|
+
description="E-mail subject line.",
|
|
58
|
+
required=True,
|
|
59
|
+
schema={"type": "string"},
|
|
60
|
+
),
|
|
61
|
+
ToolParameter(
|
|
62
|
+
name="body",
|
|
63
|
+
description="Plain-text message body.",
|
|
64
|
+
required=True,
|
|
65
|
+
schema={"type": "string", "format": "multiline"},
|
|
66
|
+
),
|
|
67
|
+
ToolParameter(
|
|
68
|
+
name="cc",
|
|
69
|
+
description="Comma-separated CC addresses (default: none).",
|
|
70
|
+
required=False,
|
|
71
|
+
schema={"type": "string", "default": ""},
|
|
72
|
+
),
|
|
73
|
+
ToolParameter(
|
|
74
|
+
name="bcc",
|
|
75
|
+
description="Comma-separated BCC addresses (default: none).",
|
|
76
|
+
required=False,
|
|
77
|
+
schema={"type": "string", "default": ""},
|
|
78
|
+
),
|
|
79
|
+
ToolParameter(
|
|
80
|
+
name="reply_to",
|
|
81
|
+
description="Reply-To address (default: none).",
|
|
82
|
+
required=False,
|
|
83
|
+
schema={"type": "string", "default": ""},
|
|
84
|
+
),
|
|
85
|
+
],
|
|
86
|
+
),
|
|
87
|
+
Tool(
|
|
88
|
+
name="send_html_message",
|
|
89
|
+
title="Send an HTML e-mail",
|
|
90
|
+
description=(
|
|
91
|
+
"Send an e-mail with an HTML body and an optional plain-text "
|
|
92
|
+
"fallback. Supports To, CC, BCC, and Reply-To headers."
|
|
93
|
+
),
|
|
94
|
+
parameters=[
|
|
95
|
+
ToolParameter(
|
|
96
|
+
name="to",
|
|
97
|
+
description="Comma-separated recipient addresses.",
|
|
98
|
+
required=True,
|
|
99
|
+
schema={"type": "string"},
|
|
100
|
+
),
|
|
101
|
+
ToolParameter(
|
|
102
|
+
name="subject",
|
|
103
|
+
description="E-mail subject line.",
|
|
104
|
+
required=True,
|
|
105
|
+
schema={"type": "string"},
|
|
106
|
+
),
|
|
107
|
+
ToolParameter(
|
|
108
|
+
name="html_body",
|
|
109
|
+
description="HTML message body.",
|
|
110
|
+
required=True,
|
|
111
|
+
schema={"type": "string", "format": "multiline"},
|
|
112
|
+
),
|
|
113
|
+
ToolParameter(
|
|
114
|
+
name="text_body",
|
|
115
|
+
description="Plain-text fallback body (default: none).",
|
|
116
|
+
required=False,
|
|
117
|
+
schema={"type": "string", "default": "", "format": "multiline"},
|
|
118
|
+
),
|
|
119
|
+
ToolParameter(
|
|
120
|
+
name="cc",
|
|
121
|
+
description="Comma-separated CC addresses (default: none).",
|
|
122
|
+
required=False,
|
|
123
|
+
schema={"type": "string", "default": ""},
|
|
124
|
+
),
|
|
125
|
+
ToolParameter(
|
|
126
|
+
name="bcc",
|
|
127
|
+
description="Comma-separated BCC addresses (default: none).",
|
|
128
|
+
required=False,
|
|
129
|
+
schema={"type": "string", "default": ""},
|
|
130
|
+
),
|
|
131
|
+
ToolParameter(
|
|
132
|
+
name="reply_to",
|
|
133
|
+
description="Reply-To address (default: none).",
|
|
134
|
+
required=False,
|
|
135
|
+
schema={"type": "string", "default": ""},
|
|
136
|
+
),
|
|
137
|
+
],
|
|
138
|
+
),
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class MailsendToolDriver(MCSToolDriver):
|
|
143
|
+
"""Provides mail-sending operations as structured tools.
|
|
144
|
+
|
|
145
|
+
The adapter can be selected by name (``adapter="smtp"``) or injected
|
|
146
|
+
directly via ``_adapter`` for testing. Any object satisfying
|
|
147
|
+
``MailsendPort`` works.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
meta: DriverMeta = _MailsendToolDriverMeta()
|
|
151
|
+
|
|
152
|
+
def __init__(
|
|
153
|
+
self,
|
|
154
|
+
*,
|
|
155
|
+
adapter: str = "smtp",
|
|
156
|
+
_adapter: MailsendPort | None = None,
|
|
157
|
+
**adapter_kwargs: Any,
|
|
158
|
+
) -> None:
|
|
159
|
+
if _adapter is not None:
|
|
160
|
+
self._adapter: MailsendPort = _adapter
|
|
161
|
+
elif adapter == "smtp":
|
|
162
|
+
from mcs.adapter.smtp import SmtpAdapter
|
|
163
|
+
self._adapter = SmtpAdapter(**adapter_kwargs)
|
|
164
|
+
else:
|
|
165
|
+
raise ValueError(
|
|
166
|
+
f"Unknown mailsend adapter: {adapter!r}. "
|
|
167
|
+
f"Available: 'smtp'. Or inject a custom adapter via _adapter=..."
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def list_tools(self) -> List[Tool]:
|
|
171
|
+
return list(_TOOLS)
|
|
172
|
+
|
|
173
|
+
def execute_tool(self, tool_name: str, arguments: Dict[str, Any]) -> Any:
|
|
174
|
+
if tool_name == "send_message":
|
|
175
|
+
return self._adapter.send_message(
|
|
176
|
+
to=arguments["to"],
|
|
177
|
+
subject=arguments["subject"],
|
|
178
|
+
body=arguments["body"],
|
|
179
|
+
cc=arguments.get("cc", ""),
|
|
180
|
+
bcc=arguments.get("bcc", ""),
|
|
181
|
+
reply_to=arguments.get("reply_to", ""),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if tool_name == "send_html_message":
|
|
185
|
+
return self._adapter.send_html_message(
|
|
186
|
+
to=arguments["to"],
|
|
187
|
+
subject=arguments["subject"],
|
|
188
|
+
html_body=arguments["html_body"],
|
|
189
|
+
text_body=arguments.get("text_body", ""),
|
|
190
|
+
cc=arguments.get("cc", ""),
|
|
191
|
+
bcc=arguments.get("bcc", ""),
|
|
192
|
+
reply_to=arguments.get("reply_to", ""),
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
raise ValueError(f"Unknown tool: {tool_name}")
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcs-driver-mailsend
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Mail-sending driver for the Model Context Standard -- lets an LLM 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,smtp
|
|
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
|
+
Provides-Extra: smtp
|
|
26
|
+
Requires-Dist: mcs-adapter-smtp>=0.1; extra == "smtp"
|
|
27
|
+
Provides-Extra: inspector
|
|
28
|
+
Requires-Dist: mcs-inspector>=0.1; extra == "inspector"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# mcs-driver-mailsend
|
|
32
|
+
|
|
33
|
+
Mail-sending driver for the **Model Context Standard (MCS)**.
|
|
34
|
+
|
|
35
|
+
Provides tools for sending plain-text and HTML e-mail. The actual I/O is
|
|
36
|
+
delegated to a pluggable adapter, making the same driver work with SMTP,
|
|
37
|
+
Gmail API, Microsoft Graph, or any future backend.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install mcs-driver-mailsend
|
|
43
|
+
|
|
44
|
+
# With SMTP adapter
|
|
45
|
+
pip install mcs-driver-mailsend[smtp]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
52
|
+
|
|
53
|
+
# SMTP (default adapter)
|
|
54
|
+
td = MailsendToolDriver(
|
|
55
|
+
adapter="smtp",
|
|
56
|
+
host="smtp.example.com",
|
|
57
|
+
user="alice@example.com",
|
|
58
|
+
password="...",
|
|
59
|
+
sender_name="Alice Smith", # optional display name
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
tools = td.list_tools() # 2 tools
|
|
63
|
+
result = td.execute_tool("send_message", {
|
|
64
|
+
"to": "bob@example.com",
|
|
65
|
+
"subject": "Hello",
|
|
66
|
+
"body": "Hi Bob!",
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Tools
|
|
71
|
+
|
|
72
|
+
| Tool | Description |
|
|
73
|
+
|---------------------|--------------------------------------------------|
|
|
74
|
+
| `send_message` | Send a plain-text e-mail |
|
|
75
|
+
| `send_html_message` | Send an HTML e-mail with optional text fallback |
|
|
76
|
+
|
|
77
|
+
## Adapter protocol
|
|
78
|
+
|
|
79
|
+
The driver defines a `MailsendPort` typing protocol. Any object that implements
|
|
80
|
+
`send_message` and `send_html_message` satisfies the contract -- no inheritance
|
|
81
|
+
required.
|
|
82
|
+
|
|
83
|
+
## Links
|
|
84
|
+
|
|
85
|
+
- **Homepage:** <https://www.modelcontextstandard.io>
|
|
86
|
+
- **Source:** <https://github.com/modelcontextstandard/python-sdk>
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
Apache-2.0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/mcs/driver/mailsend/__init__.py
|
|
5
|
+
src/mcs/driver/mailsend/driver.py
|
|
6
|
+
src/mcs/driver/mailsend/inspector.py
|
|
7
|
+
src/mcs/driver/mailsend/ports.py
|
|
8
|
+
src/mcs/driver/mailsend/tooldriver.py
|
|
9
|
+
src/mcs_driver_mailsend.egg-info/PKG-INFO
|
|
10
|
+
src/mcs_driver_mailsend.egg-info/SOURCES.txt
|
|
11
|
+
src/mcs_driver_mailsend.egg-info/dependency_links.txt
|
|
12
|
+
src/mcs_driver_mailsend.egg-info/requires.txt
|
|
13
|
+
src/mcs_driver_mailsend.egg-info/top_level.txt
|
|
14
|
+
tests/test_driver.py
|
|
15
|
+
tests/test_tooldriver.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mcs
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Tests for MailsendDriver (HybridDriver = DriverBase + ToolDriver delegation)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from mcs.driver.mailsend import MailsendDriver, MailsendToolDriver
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FakeMailsendAdapter:
|
|
13
|
+
"""Minimal adapter stub."""
|
|
14
|
+
|
|
15
|
+
def send_message(self, *, to, subject, body, cc="", bcc="", reply_to="") -> str:
|
|
16
|
+
return json.dumps({"status": "sent", "from": "test@example.com",
|
|
17
|
+
"recipients": [to], "subject": subject})
|
|
18
|
+
|
|
19
|
+
def send_html_message(self, *, to, subject, html_body, text_body="",
|
|
20
|
+
cc="", bcc="", reply_to="") -> str:
|
|
21
|
+
return json.dumps({"status": "sent", "from": "test@example.com",
|
|
22
|
+
"recipients": [to], "subject": subject})
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.fixture()
|
|
28
|
+
def driver() -> MailsendDriver:
|
|
29
|
+
td = MailsendToolDriver(_adapter=FakeMailsendAdapter())
|
|
30
|
+
return MailsendDriver(_tooldriver=td)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TestHybridDriver:
|
|
34
|
+
|
|
35
|
+
def test_system_message_not_empty(self, driver: MailsendDriver):
|
|
36
|
+
assert len(driver.get_driver_system_message()) > 0
|
|
37
|
+
|
|
38
|
+
def test_function_description_contains_tool_names(self, driver: MailsendDriver):
|
|
39
|
+
desc = driver.get_function_description()
|
|
40
|
+
assert "send_message" in desc
|
|
41
|
+
|
|
42
|
+
def test_list_tools_delegates(self, driver: MailsendDriver):
|
|
43
|
+
assert len(driver.list_tools()) == 2
|
|
44
|
+
|
|
45
|
+
def test_execute_tool_delegates(self, driver: MailsendDriver):
|
|
46
|
+
result = json.loads(driver.execute_tool("send_message", {
|
|
47
|
+
"to": "alice@example.com", "subject": "Hi", "body": "Hello",
|
|
48
|
+
}))
|
|
49
|
+
assert result["status"] == "sent"
|
|
50
|
+
|
|
51
|
+
def test_meta_attributes(self, driver: MailsendDriver):
|
|
52
|
+
assert driver.meta.name == "Mailsend MCS Driver"
|
|
53
|
+
assert "standalone" in driver.meta.capabilities
|
|
54
|
+
assert driver.meta.bindings[0].adapter == "*"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Tests for MailsendToolDriver -- uses a fake adapter (no real connection)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from mcs.driver.mailsend import MailsendToolDriver
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FakeMailsendAdapter:
|
|
13
|
+
"""Satisfies MailsendPort without touching the network."""
|
|
14
|
+
|
|
15
|
+
def send_message(self, *, to, subject, body, cc="", bcc="", reply_to="") -> str:
|
|
16
|
+
recipients = [a.strip() for a in to.split(",") if a.strip()]
|
|
17
|
+
if cc:
|
|
18
|
+
recipients += [a.strip() for a in cc.split(",") if a.strip()]
|
|
19
|
+
if bcc:
|
|
20
|
+
recipients += [a.strip() for a in bcc.split(",") if a.strip()]
|
|
21
|
+
return json.dumps({
|
|
22
|
+
"status": "sent", "from": "test@example.com",
|
|
23
|
+
"recipients": recipients, "subject": subject,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
def send_html_message(self, *, to, subject, html_body, text_body="",
|
|
27
|
+
cc="", bcc="", reply_to="") -> str:
|
|
28
|
+
recipients = [a.strip() for a in to.split(",") if a.strip()]
|
|
29
|
+
return json.dumps({
|
|
30
|
+
"status": "sent", "from": "test@example.com",
|
|
31
|
+
"recipients": recipients, "subject": subject,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@pytest.fixture()
|
|
38
|
+
def td() -> MailsendToolDriver:
|
|
39
|
+
return MailsendToolDriver(_adapter=FakeMailsendAdapter())
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class TestListTools:
|
|
43
|
+
|
|
44
|
+
def test_returns_two_tools(self, td: MailsendToolDriver):
|
|
45
|
+
assert len(td.list_tools()) == 2
|
|
46
|
+
|
|
47
|
+
def test_tool_names(self, td: MailsendToolDriver):
|
|
48
|
+
names = {t.name for t in td.list_tools()}
|
|
49
|
+
assert names == {"send_message", "send_html_message"}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TestExecuteTool:
|
|
53
|
+
|
|
54
|
+
def test_send_message(self, td: MailsendToolDriver):
|
|
55
|
+
result = json.loads(td.execute_tool("send_message", {
|
|
56
|
+
"to": "alice@example.com", "subject": "Hello", "body": "Hi!",
|
|
57
|
+
}))
|
|
58
|
+
assert result["status"] == "sent"
|
|
59
|
+
|
|
60
|
+
def test_send_message_with_cc_bcc(self, td: MailsendToolDriver):
|
|
61
|
+
result = json.loads(td.execute_tool("send_message", {
|
|
62
|
+
"to": "alice@example.com", "subject": "FYI", "body": "note",
|
|
63
|
+
"cc": "bob@example.com", "bcc": "carol@example.com",
|
|
64
|
+
}))
|
|
65
|
+
assert len(result["recipients"]) == 3
|
|
66
|
+
|
|
67
|
+
def test_send_html_message(self, td: MailsendToolDriver):
|
|
68
|
+
result = json.loads(td.execute_tool("send_html_message", {
|
|
69
|
+
"to": "alice@example.com", "subject": "News", "html_body": "<h1>Hi</h1>",
|
|
70
|
+
}))
|
|
71
|
+
assert result["status"] == "sent"
|
|
72
|
+
|
|
73
|
+
def test_unknown_tool_raises(self, td: MailsendToolDriver):
|
|
74
|
+
with pytest.raises(ValueError, match="Unknown tool"):
|
|
75
|
+
td.execute_tool("nonexistent", {})
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class TestDriverMeta:
|
|
79
|
+
|
|
80
|
+
def test_meta_attributes(self, td: MailsendToolDriver):
|
|
81
|
+
assert td.meta.name == "Mailsend MCS ToolDriver"
|
|
82
|
+
assert td.meta.bindings[0].capability == "mailsend"
|
|
83
|
+
assert td.meta.bindings[0].adapter == "*"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class TestConstructor:
|
|
87
|
+
|
|
88
|
+
def test_unknown_adapter_raises(self):
|
|
89
|
+
with pytest.raises(ValueError, match="Unknown mailsend adapter"):
|
|
90
|
+
MailsendToolDriver(adapter="nonexistent")
|
|
91
|
+
|
|
92
|
+
def test_accepts_adapter_injection(self):
|
|
93
|
+
td = MailsendToolDriver(_adapter=FakeMailsendAdapter())
|
|
94
|
+
assert td.list_tools()
|