FEAT-Add-Star-tool #8
@@ -358,3 +358,58 @@ server.registerTool(
|
||||
}
|
||||
}
|
||||
);
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Tool: star_emails
|
||||
// --------------------------------------------------------------------------- //
|
||||
server.registerTool(
|
||||
"star_emails",
|
||||
{
|
||||
description: "Mark reviewed emails with a star and mark them as read in Gmail. " +
|
||||
"Use this for all reviewed messages (Categories A, B, C, and D) " +
|
||||
"to signal they have been processed. Specify which account the emails belong to.",
|
||||
inputSchema: {
|
||||
account: accountSchema,
|
||||
messageIds: z
|
||||
.array(z.string())
|
||||
.describe("Array of Gmail message IDs to star and mark read"),
|
||||
},
|
||||
},
|
||||
async ({ account, messageIds }) => {
|
||||
try {
|
||||
if (messageIds.length === 0) {
|
||||
return { content: [{ type: "text" as const, text: "No message IDs provided." }] };
|
||||
}
|
||||
|
||||
const gmail = getGmailClient(account);
|
||||
|
||||
// Batch modify allows updating up to 1000 messages in a single API call
|
||||
await gmail.users.messages.batchModify({
|
||||
userId: "me",
|
||||
requestBody: {
|
||||
ids: messageIds,
|
||||
addLabelIds: ["STARRED"],
|
||||
removeLabelIds: ["UNREAD"]
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text" as const,
|
||||
text: `Successfully starred and marked read ${messageIds.length} email(s).`,
|
||||
},
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
const errMsg = error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "text" as const,
|
||||
text: `Error starring emails: ${errMsg}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user