Skip to content

Commit 42bbd53

Browse files
[ACTION] Gmail MCP server add tool 'create-label' (#17227)
* create-label * pnpm-lock.yaml * update colors * Require Background Color and Text Color --------- Co-authored-by: Leo Vu <[email protected]>
1 parent e53a339 commit 42bbd53

File tree

3 files changed

+733
-1
lines changed

3 files changed

+733
-1
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import gmail from "../../gmail.app.mjs";
2+
import labelColors from "../../common/label-colors.mjs";
3+
import constants from "../../common/constants.mjs";
4+
5+
export default {
6+
key: "gmail-create-label",
7+
name: "Create Label",
8+
description: "Create a new label in the connected account. [See the documentation](https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.labels/create)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
gmail,
13+
name: {
14+
type: "string",
15+
label: "Name",
16+
description: "The display name of the label",
17+
},
18+
textColor: {
19+
type: "string",
20+
label: "Text Color",
21+
description: "The text color of the label",
22+
options: labelColors,
23+
optional: false,
24+
},
25+
backgroundColor: {
26+
type: "string",
27+
label: "Background Color",
28+
description: "The background color of the label",
29+
options: labelColors,
30+
optional: false,
31+
},
32+
messageListVisibility: {
33+
type: "string",
34+
label: "Message List Visibility",
35+
description: "The visibility of messages with this label in the message list in the Gmail web interface",
36+
options: [
37+
"show",
38+
"hide",
39+
],
40+
optional: true,
41+
},
42+
labelListVisibility: {
43+
type: "string",
44+
label: "Label List Visibility",
45+
description: "The visibility of the label in the label list in the Gmail web interface",
46+
options: [
47+
"labelShow",
48+
"labelShowIfUnread",
49+
"labelHide",
50+
],
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.gmail._client().users.labels.create({
56+
userId: constants.USER_ID,
57+
requestBody: {
58+
name: this.name,
59+
messageListVisibility: this.messageListVisibility,
60+
labelListVisibility: this.labelListVisibility,
61+
color: {
62+
textColor: this.textColor,
63+
backgroundColor: this.backgroundColor,
64+
},
65+
},
66+
});
67+
$.export("$summary", `Successfully created label: ${this.name}`);
68+
return response;
69+
},
70+
};

0 commit comments

Comments
 (0)