gmail-workspace-mcp-server 0.0.4 → 0.0.5
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.
package/package.json
CHANGED
|
@@ -3,10 +3,13 @@ import { z } from 'zod';
|
|
|
3
3
|
import type { ClientFactory } from '../server.js';
|
|
4
4
|
export declare const GetEmailConversationSchema: z.ZodObject<{
|
|
5
5
|
email_id: z.ZodString;
|
|
6
|
+
include_html: z.ZodOptional<z.ZodBoolean>;
|
|
6
7
|
}, "strip", z.ZodTypeAny, {
|
|
7
8
|
email_id: string;
|
|
9
|
+
include_html?: boolean | undefined;
|
|
8
10
|
}, {
|
|
9
11
|
email_id: string;
|
|
12
|
+
include_html?: boolean | undefined;
|
|
10
13
|
}>;
|
|
11
14
|
export declare function getEmailConversationTool(server: Server, clientFactory: ClientFactory): {
|
|
12
15
|
name: string;
|
|
@@ -18,6 +21,10 @@ export declare function getEmailConversationTool(server: Server, clientFactory:
|
|
|
18
21
|
type: string;
|
|
19
22
|
description: string;
|
|
20
23
|
};
|
|
24
|
+
include_html: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
21
28
|
};
|
|
22
29
|
required: string[];
|
|
23
30
|
};
|
|
@@ -3,9 +3,12 @@ import { getHeader } from '../utils/email-helpers.js';
|
|
|
3
3
|
const PARAM_DESCRIPTIONS = {
|
|
4
4
|
email_id: 'The unique identifier of the email to retrieve. ' +
|
|
5
5
|
'Obtain this from list_email_conversations or search_email_conversations.',
|
|
6
|
+
include_html: 'When true, includes the raw HTML body of the email (if available) in addition to the plain text. ' +
|
|
7
|
+
'Useful for rendering emails with original formatting, creating screenshots, or archival workflows.',
|
|
6
8
|
};
|
|
7
9
|
export const GetEmailConversationSchema = z.object({
|
|
8
10
|
email_id: z.string().min(1).describe(PARAM_DESCRIPTIONS.email_id),
|
|
11
|
+
include_html: z.boolean().optional().describe(PARAM_DESCRIPTIONS.include_html),
|
|
9
12
|
});
|
|
10
13
|
const TOOL_DESCRIPTION = `Retrieve the full content of a specific email conversation by its ID.
|
|
11
14
|
|
|
@@ -13,11 +16,13 @@ Returns the complete email including headers, body content, and attachment infor
|
|
|
13
16
|
|
|
14
17
|
**Parameters:**
|
|
15
18
|
- email_id: The unique identifier of the email (required)
|
|
19
|
+
- include_html: When true, includes raw HTML body in addition to plain text (optional)
|
|
16
20
|
|
|
17
21
|
**Returns:**
|
|
18
22
|
Full email details including:
|
|
19
23
|
- Subject, From, To, Cc, Date headers
|
|
20
24
|
- Full message body (plain text preferred, HTML as fallback)
|
|
25
|
+
- Raw HTML body (when include_html is true and HTML content is available)
|
|
21
26
|
- List of attachments (if any)
|
|
22
27
|
- Labels assigned to the email
|
|
23
28
|
|
|
@@ -25,6 +30,8 @@ Full email details including:
|
|
|
25
30
|
- Read the full content of an email after listing conversations
|
|
26
31
|
- Extract specific information from an email body
|
|
27
32
|
- Check attachment details
|
|
33
|
+
- Render emails with original HTML formatting (use include_html: true)
|
|
34
|
+
- Create email screenshots or archives with original styling
|
|
28
35
|
|
|
29
36
|
**Note:** Use list_email_conversations or search_email_conversations first to get email IDs.`;
|
|
30
37
|
/**
|
|
@@ -84,6 +91,22 @@ function getEmailBody(email) {
|
|
|
84
91
|
}
|
|
85
92
|
return '(No body content available)';
|
|
86
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the raw HTML body content from an email (if available)
|
|
96
|
+
*/
|
|
97
|
+
function getEmailHtmlBody(email) {
|
|
98
|
+
// Check if body is directly on payload and it's HTML
|
|
99
|
+
if (email.payload?.body?.data && email.payload.mimeType === 'text/html') {
|
|
100
|
+
return decodeBase64Url(email.payload.body.data);
|
|
101
|
+
}
|
|
102
|
+
// Try to extract HTML from parts
|
|
103
|
+
if (email.payload?.parts) {
|
|
104
|
+
const html = extractBodyContent(email.payload.parts, 'text/html');
|
|
105
|
+
if (html)
|
|
106
|
+
return html;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
87
110
|
/**
|
|
88
111
|
* Extracts attachment information from email parts
|
|
89
112
|
*/
|
|
@@ -108,7 +131,7 @@ function getAttachments(parts) {
|
|
|
108
131
|
/**
|
|
109
132
|
* Formats an email for display
|
|
110
133
|
*/
|
|
111
|
-
function formatFullEmail(email) {
|
|
134
|
+
function formatFullEmail(email, options) {
|
|
112
135
|
const subject = getHeader(email, 'Subject') || '(No Subject)';
|
|
113
136
|
const from = getHeader(email, 'From') || 'Unknown';
|
|
114
137
|
const to = getHeader(email, 'To') || 'Unknown';
|
|
@@ -136,6 +159,26 @@ function formatFullEmail(email) {
|
|
|
136
159
|
## Body
|
|
137
160
|
|
|
138
161
|
${body}`;
|
|
162
|
+
// Include raw HTML body if requested
|
|
163
|
+
if (options?.includeHtml) {
|
|
164
|
+
const htmlBody = getEmailHtmlBody(email);
|
|
165
|
+
if (htmlBody) {
|
|
166
|
+
output += `
|
|
167
|
+
|
|
168
|
+
## HTML Body
|
|
169
|
+
|
|
170
|
+
\`\`\`html
|
|
171
|
+
${htmlBody}
|
|
172
|
+
\`\`\``;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
output += `
|
|
176
|
+
|
|
177
|
+
## HTML Body
|
|
178
|
+
|
|
179
|
+
(No HTML content available)`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
139
182
|
if (attachments.length > 0) {
|
|
140
183
|
output += `\n\n## Attachments (${attachments.length})\n`;
|
|
141
184
|
attachments.forEach((att, i) => {
|
|
@@ -156,6 +199,10 @@ export function getEmailConversationTool(server, clientFactory) {
|
|
|
156
199
|
type: 'string',
|
|
157
200
|
description: PARAM_DESCRIPTIONS.email_id,
|
|
158
201
|
},
|
|
202
|
+
include_html: {
|
|
203
|
+
type: 'boolean',
|
|
204
|
+
description: PARAM_DESCRIPTIONS.include_html,
|
|
205
|
+
},
|
|
159
206
|
},
|
|
160
207
|
required: ['email_id'],
|
|
161
208
|
},
|
|
@@ -166,7 +213,9 @@ export function getEmailConversationTool(server, clientFactory) {
|
|
|
166
213
|
const email = await client.getMessage(parsed.email_id, {
|
|
167
214
|
format: 'full',
|
|
168
215
|
});
|
|
169
|
-
const formattedEmail = formatFullEmail(email
|
|
216
|
+
const formattedEmail = formatFullEmail(email, {
|
|
217
|
+
includeHtml: parsed.include_html,
|
|
218
|
+
});
|
|
170
219
|
return {
|
|
171
220
|
content: [
|
|
172
221
|
{
|