apimend-mail-mcp 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +137 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -101,6 +101,143 @@ export function createApimendMcpServer(options) {
101
101
  return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to diagnose email" }] };
102
102
  }
103
103
  });
104
+ server.registerTool("sandbox_send", {
105
+ title: "Send email to Customer Sandbox",
106
+ description: "Capture a test email in Customer Sandbox without contacting real recipients or using live quota.",
107
+ inputSchema: {
108
+ from: z.string().email(),
109
+ to: z.union([z.string().email(), z.array(z.string().email()).min(1).max(20)]),
110
+ subject: z.string().min(1).max(998),
111
+ html: z.string().optional(),
112
+ text: z.string().optional(),
113
+ idempotency_key: z.string().min(1).max(200).optional(),
114
+ },
115
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
116
+ }, async ({ from, to, subject, html, text, idempotency_key }) => {
117
+ try {
118
+ const result = await request("/v1/send", {
119
+ method: "POST",
120
+ body: {
121
+ from,
122
+ to,
123
+ subject,
124
+ ...(html !== undefined ? { html } : {}),
125
+ ...(text !== undefined ? { text } : {}),
126
+ ...(idempotency_key ? { idempotencyKey: idempotency_key } : {}),
127
+ sandbox: true,
128
+ },
129
+ });
130
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
131
+ }
132
+ catch (error) {
133
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to send sandbox email" }] };
134
+ }
135
+ });
136
+ server.registerTool("list_sandbox_inbox", {
137
+ title: "List Development Inbox captures",
138
+ description: "List recent emails captured in Customer Sandbox.",
139
+ inputSchema: { limit: z.number().int().min(1).max(100).optional() },
140
+ annotations: { readOnlyHint: true },
141
+ }, async ({ limit }) => {
142
+ try {
143
+ const result = await request(`/v1/sandbox/emails?limit=${limit ?? 25}`);
144
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
145
+ }
146
+ catch (error) {
147
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to list sandbox inbox" }] };
148
+ }
149
+ });
150
+ server.registerTool("run_email_qa", {
151
+ title: "Run Pre-release Email QA",
152
+ description: "Score an email draft or saved email (0-100) for unresolved tokens, unsafe links, and spam signals.",
153
+ inputSchema: {
154
+ email_id: z.string().optional(),
155
+ subject: z.string().optional(),
156
+ html: z.string().optional(),
157
+ text: z.string().optional(),
158
+ },
159
+ annotations: { readOnlyHint: true },
160
+ }, async ({ email_id, subject, html, text }) => {
161
+ try {
162
+ const result = email_id
163
+ ? await request(`/v1/emails/${encodeURIComponent(email_id)}/qa`)
164
+ : await request("/v1/qa/check", {
165
+ method: "POST",
166
+ body: { ...(subject ? { subject } : {}), ...(html ? { html } : {}), ...(text ? { text } : {}) },
167
+ });
168
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
169
+ }
170
+ catch (error) {
171
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to run email QA" }] };
172
+ }
173
+ });
174
+ server.registerTool("create_inbox", {
175
+ title: "Create a managed agent inbox",
176
+ description: "Provision an instant zero-DNS receiving address for two-way agent conversations.",
177
+ inputSchema: { slug: z.string().optional(), label: z.string().optional() },
178
+ annotations: { readOnlyHint: false },
179
+ }, async ({ slug, label }) => {
180
+ try {
181
+ const result = await request("/v1/inboxes", {
182
+ method: "POST",
183
+ body: { mode: "managed", ...(slug ? { slug } : {}), ...(label ? { label } : {}) },
184
+ });
185
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
186
+ }
187
+ catch (error) {
188
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to create inbox" }] };
189
+ }
190
+ });
191
+ server.registerTool("list_inboxes", {
192
+ title: "List two-way agent inboxes",
193
+ description: "List managed or custom-MX receiving inboxes.",
194
+ inputSchema: { status: z.enum(["open", "waiting", "resolved", "escalated"]).optional() },
195
+ annotations: { readOnlyHint: true },
196
+ }, async ({ status }) => {
197
+ try {
198
+ const qs = status ? `?status=${encodeURIComponent(status)}` : "";
199
+ const result = await request(`/v1/inboxes${qs}`);
200
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
201
+ }
202
+ catch (error) {
203
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to list inboxes" }] };
204
+ }
205
+ });
206
+ server.registerTool("get_thread", {
207
+ title: "Read an email thread",
208
+ description: "Fetch a thread with original content, extracted replies, attachments, and security scan reports.",
209
+ inputSchema: { thread_id: z.string().min(1) },
210
+ annotations: { readOnlyHint: true },
211
+ }, async ({ thread_id }) => {
212
+ try {
213
+ const result = await request(`/v1/threads/${encodeURIComponent(thread_id)}`);
214
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
215
+ }
216
+ catch (error) {
217
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to fetch thread" }] };
218
+ }
219
+ });
220
+ server.registerTool("reply_thread", {
221
+ title: "Reply to an email thread",
222
+ description: "Send a threaded reply with automatic In-Reply-To, References, and Reply-To headers.",
223
+ inputSchema: {
224
+ thread_id: z.string().min(1),
225
+ text: z.string().min(1),
226
+ status_after_reply: z.enum(["open", "waiting", "resolved", "escalated"]).optional(),
227
+ },
228
+ annotations: { readOnlyHint: false },
229
+ }, async ({ thread_id, text, status_after_reply }) => {
230
+ try {
231
+ const result = await request(`/v1/threads/${encodeURIComponent(thread_id)}/reply`, {
232
+ method: "POST",
233
+ body: { text, ...(status_after_reply ? { statusAfterReply: status_after_reply } : {}) },
234
+ });
235
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
236
+ }
237
+ catch (error) {
238
+ return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "Unable to reply to thread" }] };
239
+ }
240
+ });
104
241
  return server;
105
242
  }
106
243
  export async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apimend-mail-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Local stdio MCP server for Apimend Mail",
5
5
  "type": "module",
6
6
  "bin": {