google-tools-mcp 1.2.3 → 1.2.4
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Gmail Message tools
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { getGmailClient } from '../../clients.js';
|
|
4
|
-
import { processMessagePart, constructRawMessage, constructRawMessageWithAttachments, findHeader, formatEmailList, getNestedHistory, getPlainTextBody, wrapTextBody } from '../../helpers.js';
|
|
4
|
+
import { processMessagePart, constructRawMessage, constructRawMessageWithAttachments, findHeader, formatEmailList, getNestedHistory, getPlainTextBody, isHtmlBody, wrapTextBody } from '../../helpers.js';
|
|
5
5
|
|
|
6
6
|
export function register(server) {
|
|
7
7
|
server.addTool({
|
|
@@ -117,6 +117,7 @@ export function register(server) {
|
|
|
117
117
|
msgHeaders.push(`Subject: ${subject}`);
|
|
118
118
|
if (messageIdHeader) msgHeaders.push(`In-Reply-To: ${messageIdHeader}`);
|
|
119
119
|
if (references.length) msgHeaders.push(`References: ${references.join(' ')}`);
|
|
120
|
+
const htmlMode = isHtmlBody(params.body);
|
|
120
121
|
let raw;
|
|
121
122
|
if (params.attachments?.length) {
|
|
122
123
|
const boundary = `boundary_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
@@ -125,7 +126,7 @@ export function register(server) {
|
|
|
125
126
|
const parts = [];
|
|
126
127
|
parts.push([
|
|
127
128
|
`--${boundary}`,
|
|
128
|
-
|
|
129
|
+
`Content-Type: ${htmlMode ? 'text/html' : 'text/plain'}; charset="UTF-8"`,
|
|
129
130
|
'Content-Transfer-Encoding: base64',
|
|
130
131
|
'',
|
|
131
132
|
Buffer.from(fullBody).toString('base64'),
|
|
@@ -143,10 +144,10 @@ export function register(server) {
|
|
|
143
144
|
const rawStr = [msgHeaders.join('\r\n'), '', parts.join('\r\n'), `--${boundary}--`].join('\r\n');
|
|
144
145
|
raw = Buffer.from(rawStr).toString('base64url').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
145
146
|
} else {
|
|
146
|
-
msgHeaders.push(
|
|
147
|
+
msgHeaders.push(`Content-Type: ${htmlMode ? 'text/html' : 'text/plain'}; charset="UTF-8"`);
|
|
147
148
|
msgHeaders.push('Content-Transfer-Encoding: quoted-printable');
|
|
148
149
|
msgHeaders.push('MIME-Version: 1.0');
|
|
149
|
-
const rawStr = [msgHeaders.join('\r\n'), '', wrapTextBody(fullBody)].join('\r\n');
|
|
150
|
+
const rawStr = [msgHeaders.join('\r\n'), '', htmlMode ? fullBody : wrapTextBody(fullBody)].join('\r\n');
|
|
150
151
|
raw = Buffer.from(rawStr).toString('base64url').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
151
152
|
}
|
|
152
153
|
const { data } = await gmail.users.messages.send({
|
|
@@ -232,6 +233,7 @@ export function register(server) {
|
|
|
232
233
|
if (params.cc?.length) msgHeaders.push(`Cc: ${params.cc.join(', ')}`);
|
|
233
234
|
if (params.bcc?.length) msgHeaders.push(`Bcc: ${params.bcc.join(', ')}`);
|
|
234
235
|
msgHeaders.push(`Subject: ${subject}`);
|
|
236
|
+
const fwdHtmlMode = params.body && isHtmlBody(params.body);
|
|
235
237
|
let raw;
|
|
236
238
|
if (attachmentParts.length) {
|
|
237
239
|
const boundary = `boundary_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
@@ -240,7 +242,7 @@ export function register(server) {
|
|
|
240
242
|
const parts = [];
|
|
241
243
|
parts.push([
|
|
242
244
|
`--${boundary}`,
|
|
243
|
-
|
|
245
|
+
`Content-Type: ${fwdHtmlMode ? 'text/html' : 'text/plain'}; charset="UTF-8"`,
|
|
244
246
|
'Content-Transfer-Encoding: base64',
|
|
245
247
|
'',
|
|
246
248
|
Buffer.from(fullBody).toString('base64'),
|
|
@@ -258,10 +260,10 @@ export function register(server) {
|
|
|
258
260
|
const rawStr = [msgHeaders.join('\r\n'), '', parts.join('\r\n'), `--${boundary}--`].join('\r\n');
|
|
259
261
|
raw = Buffer.from(rawStr).toString('base64url').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
260
262
|
} else {
|
|
261
|
-
msgHeaders.push(
|
|
263
|
+
msgHeaders.push(`Content-Type: ${fwdHtmlMode ? 'text/html' : 'text/plain'}; charset="UTF-8"`);
|
|
262
264
|
msgHeaders.push('Content-Transfer-Encoding: quoted-printable');
|
|
263
265
|
msgHeaders.push('MIME-Version: 1.0');
|
|
264
|
-
const rawStr = [msgHeaders.join('\r\n'), '', wrapTextBody(fullBody)].join('\r\n');
|
|
266
|
+
const rawStr = [msgHeaders.join('\r\n'), '', fwdHtmlMode ? fullBody : wrapTextBody(fullBody)].join('\r\n');
|
|
265
267
|
raw = Buffer.from(rawStr).toString('base64url').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
266
268
|
}
|
|
267
269
|
const { data } = await gmail.users.messages.send({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "google-tools-mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "The easiest MCP server for Google Workspace — Drive, Docs, Sheets, Gmail, Calendar, and Forms. 153 tools with one-click browser auth. Read Word docs, PDFs, and spreadsheets straight from Drive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|