gm-mcp 1.1.4 → 1.1.6
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/dist/env.d.ts +3 -3
- package/dist/env.js +2 -2
- package/dist/index.js +14 -12
- package/dist/tools/lark-tool.d.ts +1 -1
- package/dist/tools/lark-tool.js +17 -9
- package/package.json +1 -1
- package/src/env.ts +2 -2
- package/src/index.ts +15 -13
- package/src/tools/lark-tool.ts +18 -15
package/dist/env.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const envSchema: z.ZodObject<{
|
|
|
8
8
|
LARK_APP_SECRET: z.ZodString;
|
|
9
9
|
LARK_X3_GROUP_ID: z.ZodString;
|
|
10
10
|
LARK_X3_TEMPLATE_ID: z.ZodString;
|
|
11
|
-
SEND_MESSAGE_TO_LARK: z.
|
|
11
|
+
SEND_MESSAGE_TO_LARK: z.ZodString;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
13
|
DASH_URL: string;
|
|
14
14
|
PASSWORD: string;
|
|
@@ -18,7 +18,7 @@ declare const envSchema: z.ZodObject<{
|
|
|
18
18
|
LARK_APP_SECRET: string;
|
|
19
19
|
LARK_X3_GROUP_ID: string;
|
|
20
20
|
LARK_X3_TEMPLATE_ID: string;
|
|
21
|
-
SEND_MESSAGE_TO_LARK:
|
|
21
|
+
SEND_MESSAGE_TO_LARK: string;
|
|
22
22
|
}, {
|
|
23
23
|
DASH_URL: string;
|
|
24
24
|
PASSWORD: string;
|
|
@@ -28,7 +28,7 @@ declare const envSchema: z.ZodObject<{
|
|
|
28
28
|
LARK_APP_SECRET: string;
|
|
29
29
|
LARK_X3_GROUP_ID: string;
|
|
30
30
|
LARK_X3_TEMPLATE_ID: string;
|
|
31
|
-
SEND_MESSAGE_TO_LARK:
|
|
31
|
+
SEND_MESSAGE_TO_LARK: string;
|
|
32
32
|
}>;
|
|
33
33
|
export type GimoMcpEnv = z.infer<typeof envSchema>;
|
|
34
34
|
export declare function ensureEnvVariables(): boolean;
|
package/dist/env.js
CHANGED
|
@@ -15,7 +15,7 @@ const envSchema = zod_1.default.object({
|
|
|
15
15
|
LARK_APP_SECRET: zod_1.default.string({ description: `Lark's Bot app secret` }),
|
|
16
16
|
LARK_X3_GROUP_ID: zod_1.default.string({ description: `Id of lark's group x3` }),
|
|
17
17
|
LARK_X3_TEMPLATE_ID: zod_1.default.string({ description: `Id of lark's card template x3` }),
|
|
18
|
-
SEND_MESSAGE_TO_LARK: zod_1.default.
|
|
18
|
+
SEND_MESSAGE_TO_LARK: zod_1.default.string({ description: "Send message to lark or not" }),
|
|
19
19
|
});
|
|
20
20
|
function ensureEnvVariables() {
|
|
21
21
|
const { success, error } = envSchema.safeParse(process.env);
|
|
@@ -34,7 +34,7 @@ function getEnv() {
|
|
|
34
34
|
const LARK_APP_SECRET = process.env["LARK_APP_SECRET"];
|
|
35
35
|
const LARK_X3_GROUP_ID = process.env["LARK_X3_GROUP_ID"];
|
|
36
36
|
const LARK_X3_TEMPLATE_ID = process.env["LARK_X3_TEMPLATE_ID"];
|
|
37
|
-
const SEND_MESSAGE_TO_LARK =
|
|
37
|
+
const SEND_MESSAGE_TO_LARK = process.env["SEND_MESSAGE_TO_LARK"];
|
|
38
38
|
return {
|
|
39
39
|
DASH_URL,
|
|
40
40
|
PASSWORD,
|
package/dist/index.js
CHANGED
|
@@ -29,21 +29,21 @@ exports.server = new mcp_js_1.McpServer({
|
|
|
29
29
|
},
|
|
30
30
|
});
|
|
31
31
|
exports.server.tool("statistic_salary_x3_today", "Get statistic salary x3 today", {}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
return (0, tools_1.statisticX3TodayTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK });
|
|
32
|
+
return (0, tools_1.statisticX3TodayTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true" });
|
|
33
33
|
}));
|
|
34
34
|
exports.server.tool("statistic_salary_x3_yesterday", "Get statistic salary x3 yesterday", {}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
return (0, tools_1.statisticX3YesterdayTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK });
|
|
35
|
+
return (0, tools_1.statisticX3YesterdayTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true" });
|
|
36
36
|
}));
|
|
37
37
|
exports.server.tool("statistic_salary_x3_this_week", "Get statistic salary x3 this week", {}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
return (0, tools_1.statisticX3WeekTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK });
|
|
38
|
+
return (0, tools_1.statisticX3WeekTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true" });
|
|
39
39
|
}));
|
|
40
40
|
exports.server.tool("statistic_salary_x3_month", `Get statistic salary x3 with month`, {
|
|
41
41
|
month: zod_1.default.string().describe("Month to statistic, month must be represented with format MM/yyyy"),
|
|
42
42
|
}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
return (0, tools_1.statisticX3MonthTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK, month: args.month });
|
|
43
|
+
return (0, tools_1.statisticX3MonthTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true", month: args.month });
|
|
44
44
|
}));
|
|
45
45
|
exports.server.tool("statistic_salary_x3_this_month", `Get statistic salary x3 this month`, {}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
return (0, tools_1.statisticX3ThisMonthTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK });
|
|
46
|
+
return (0, tools_1.statisticX3ThisMonthTool)({ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true" });
|
|
47
47
|
}));
|
|
48
48
|
exports.server.tool("statistic_salary_x3", "Get statistic salary x3 with specific date,date must be formated in dd/mm/yyy or dd-mm-yyyy", {
|
|
49
49
|
date: zod_1.default.string({
|
|
@@ -52,7 +52,7 @@ exports.server.tool("statistic_salary_x3", "Get statistic salary x3 with specifi
|
|
|
52
52
|
}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
53
|
return (0, tools_1.statisticX3Tool)({
|
|
54
54
|
date: args.date,
|
|
55
|
-
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK,
|
|
55
|
+
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
|
|
56
56
|
});
|
|
57
57
|
}));
|
|
58
58
|
exports.server.tool("statistic_salary_x3_in_range", "Get statistic salary x3 with range of date,date must be formated in dd/mm/yyy or dd-mm-yyyy", {
|
|
@@ -66,18 +66,20 @@ exports.server.tool("statistic_salary_x3_in_range", "Get statistic salary x3 wit
|
|
|
66
66
|
return (0, tools_1.statisticX3RangeTool)({
|
|
67
67
|
startDateStr: args.start_date,
|
|
68
68
|
endDateStr: args.end_date,
|
|
69
|
-
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK,
|
|
69
|
+
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
|
|
70
70
|
});
|
|
71
71
|
}));
|
|
72
|
-
exports.server.tool("debt_collection_by_month", "The company's debt collection information by month", {
|
|
73
|
-
month: zod_1.default
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
exports.server.tool("debt_collection_by_month", "The company's debt collection information by month (month is optional)", {
|
|
73
|
+
month: zod_1.default
|
|
74
|
+
.string({
|
|
75
|
+
description: "Month to get data,if year is not provided, please use current year (in Vietnam timezone) instead of, month is represented with format MM/yyyy",
|
|
76
|
+
})
|
|
77
|
+
.optional(),
|
|
76
78
|
company_name: zod_1.default.string({ description: "Company name to get data" }),
|
|
77
79
|
}, (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
80
|
const { month, company_name } = args;
|
|
79
81
|
return (0, lark_tool_1.debtCollectionRateTool)({
|
|
80
|
-
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK,
|
|
82
|
+
sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
|
|
81
83
|
monthDate: month,
|
|
82
84
|
companyName: company_name,
|
|
83
85
|
});
|
package/dist/tools/lark-tool.js
CHANGED
|
@@ -26,11 +26,10 @@ function debtCollectionRateTool(options) {
|
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
var _c, _d;
|
|
28
28
|
const { sendMessageToLark, companyName, monthDate } = options;
|
|
29
|
-
const monthParts = (0, helpers_1.extractMonth)(monthDate);
|
|
30
|
-
if (monthParts === null) {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
const { month, year } = monthParts;
|
|
29
|
+
const monthParts = !monthDate ? null : (0, helpers_1.extractMonth)(monthDate);
|
|
30
|
+
// if (monthParts === null) {
|
|
31
|
+
// return { content: [{ type: "text", text: `${monthDate} is invalid` }] };
|
|
32
|
+
// }
|
|
34
33
|
const fieldNames = report_columns_1.REPORT_COLUMS.map((item) => item.field_name);
|
|
35
34
|
try {
|
|
36
35
|
const records = yield (0, lark_base_service_1.fetchDebtCollectionRecords)();
|
|
@@ -44,10 +43,19 @@ function debtCollectionRateTool(options) {
|
|
|
44
43
|
const companiesMatchName = records.filter((item) => item.fields[companyKey] === foundName);
|
|
45
44
|
// console.log(companiesMatchName);
|
|
46
45
|
// Find by debt reduction month, search fully match
|
|
47
|
-
const foundMonths = companiesMatchName.filter((item) =>
|
|
48
|
-
|
|
46
|
+
const foundMonths = companiesMatchName.filter((item) => {
|
|
47
|
+
if (monthParts === null) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
const { month } = monthParts;
|
|
51
|
+
return compareReductionDebtMonth(item.fields[debReductionMonthKey], month.toString());
|
|
52
|
+
});
|
|
53
|
+
// const foundMonth = searchLike(
|
|
54
|
+
// month.toString(),
|
|
55
|
+
// companiesMatchName.map((item) => item.fields["KỲ LƯƠNG"])
|
|
56
|
+
// )[0];
|
|
49
57
|
console.log(foundMonths);
|
|
50
|
-
const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
|
|
58
|
+
// const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
|
|
51
59
|
// console.log(finalCompnay);
|
|
52
60
|
const messages = [];
|
|
53
61
|
for (const item of foundMonths) {
|
|
@@ -68,7 +76,7 @@ function debtCollectionRateTool(options) {
|
|
|
68
76
|
message_content: messages.join("<hr>"),
|
|
69
77
|
});
|
|
70
78
|
}
|
|
71
|
-
return { content: [{ type: "text", text: JSON.stringify(
|
|
79
|
+
return { content: [{ type: "text", text: JSON.stringify(foundMonths) }] };
|
|
72
80
|
// console.log(finalCompnay);
|
|
73
81
|
}
|
|
74
82
|
catch (e) {
|
package/package.json
CHANGED
package/src/env.ts
CHANGED
|
@@ -9,7 +9,7 @@ const envSchema = z.object({
|
|
|
9
9
|
LARK_APP_SECRET: z.string({ description: `Lark's Bot app secret` }),
|
|
10
10
|
LARK_X3_GROUP_ID: z.string({ description: `Id of lark's group x3` }),
|
|
11
11
|
LARK_X3_TEMPLATE_ID: z.string({ description: `Id of lark's card template x3` }),
|
|
12
|
-
SEND_MESSAGE_TO_LARK: z.
|
|
12
|
+
SEND_MESSAGE_TO_LARK: z.string({ description: "Send message to lark or not" }),
|
|
13
13
|
});
|
|
14
14
|
export type GimoMcpEnv = z.infer<typeof envSchema>;
|
|
15
15
|
export function ensureEnvVariables() {
|
|
@@ -30,7 +30,7 @@ export function getEnv(): GimoMcpEnv {
|
|
|
30
30
|
const LARK_APP_SECRET = process.env["LARK_APP_SECRET"] as string;
|
|
31
31
|
const LARK_X3_GROUP_ID = process.env["LARK_X3_GROUP_ID"] as string;
|
|
32
32
|
const LARK_X3_TEMPLATE_ID = process.env["LARK_X3_TEMPLATE_ID"] as string;
|
|
33
|
-
const SEND_MESSAGE_TO_LARK =
|
|
33
|
+
const SEND_MESSAGE_TO_LARK = process.env["SEND_MESSAGE_TO_LARK"] as string;
|
|
34
34
|
return {
|
|
35
35
|
DASH_URL,
|
|
36
36
|
PASSWORD,
|
package/src/index.ts
CHANGED
|
@@ -27,15 +27,15 @@ export const server = new McpServer(
|
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
server.tool("statistic_salary_x3_today", "Get statistic salary x3 today", {}, async (args) => {
|
|
30
|
-
return statisticX3TodayTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK });
|
|
30
|
+
return statisticX3TodayTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true" });
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
server.tool("statistic_salary_x3_yesterday", "Get statistic salary x3 yesterday", {}, async (args) => {
|
|
34
|
-
return statisticX3YesterdayTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK });
|
|
34
|
+
return statisticX3YesterdayTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true" });
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
server.tool("statistic_salary_x3_this_week", "Get statistic salary x3 this week", {}, async (args) => {
|
|
38
|
-
return statisticX3WeekTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK });
|
|
38
|
+
return statisticX3WeekTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true" });
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
server.tool(
|
|
@@ -45,12 +45,12 @@ server.tool(
|
|
|
45
45
|
month: z.string().describe("Month to statistic, month must be represented with format MM/yyyy"),
|
|
46
46
|
},
|
|
47
47
|
async (args) => {
|
|
48
|
-
return statisticX3MonthTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK, month: args.month });
|
|
48
|
+
return statisticX3MonthTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true", month: args.month });
|
|
49
49
|
}
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
server.tool("statistic_salary_x3_this_month", `Get statistic salary x3 this month`, {}, async (args) => {
|
|
53
|
-
return statisticX3ThisMonthTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK });
|
|
53
|
+
return statisticX3ThisMonthTool({ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true" });
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
server.tool(
|
|
@@ -64,7 +64,7 @@ server.tool(
|
|
|
64
64
|
async (args) => {
|
|
65
65
|
return statisticX3Tool({
|
|
66
66
|
date: args.date,
|
|
67
|
-
sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK,
|
|
67
|
+
sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
);
|
|
@@ -84,25 +84,27 @@ server.tool(
|
|
|
84
84
|
return statisticX3RangeTool({
|
|
85
85
|
startDateStr: args.start_date,
|
|
86
86
|
endDateStr: args.end_date,
|
|
87
|
-
sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK,
|
|
87
|
+
sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
server.tool(
|
|
93
93
|
"debt_collection_by_month",
|
|
94
|
-
"The company's debt collection information by month",
|
|
94
|
+
"The company's debt collection information by month (month is optional)",
|
|
95
95
|
{
|
|
96
|
-
month: z
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
month: z
|
|
97
|
+
.string({
|
|
98
|
+
description:
|
|
99
|
+
"Month to get data,if year is not provided, please use current year (in Vietnam timezone) instead of, month is represented with format MM/yyyy",
|
|
100
|
+
})
|
|
101
|
+
.optional(),
|
|
100
102
|
company_name: z.string({ description: "Company name to get data" }),
|
|
101
103
|
},
|
|
102
104
|
async (args) => {
|
|
103
105
|
const { month, company_name } = args;
|
|
104
106
|
return debtCollectionRateTool({
|
|
105
|
-
sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK,
|
|
107
|
+
sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
|
|
106
108
|
monthDate: month,
|
|
107
109
|
companyName: company_name,
|
|
108
110
|
});
|
package/src/tools/lark-tool.ts
CHANGED
|
@@ -16,14 +16,13 @@ const statusKey = "TRẠNG THÁI";
|
|
|
16
16
|
export async function debtCollectionRateTool(options: {
|
|
17
17
|
sendMessageToLark: boolean;
|
|
18
18
|
companyName: string;
|
|
19
|
-
monthDate
|
|
19
|
+
monthDate?: string;
|
|
20
20
|
}): Promise<CallToolResult> {
|
|
21
21
|
const { sendMessageToLark, companyName, monthDate } = options;
|
|
22
|
-
const monthParts = extractMonth(monthDate);
|
|
23
|
-
if (monthParts === null) {
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const { month, year } = monthParts;
|
|
22
|
+
const monthParts = !monthDate ? null : extractMonth(monthDate);
|
|
23
|
+
// if (monthParts === null) {
|
|
24
|
+
// return { content: [{ type: "text", text: `${monthDate} is invalid` }] };
|
|
25
|
+
// }
|
|
27
26
|
const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
|
|
28
27
|
try {
|
|
29
28
|
const records = await fetchDebtCollectionRecords();
|
|
@@ -39,15 +38,19 @@ export async function debtCollectionRateTool(options: {
|
|
|
39
38
|
// console.log(companiesMatchName);
|
|
40
39
|
|
|
41
40
|
// Find by debt reduction month, search fully match
|
|
42
|
-
const foundMonths = companiesMatchName.filter((item) =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
month
|
|
47
|
-
|
|
48
|
-
)
|
|
41
|
+
const foundMonths = companiesMatchName.filter((item) => {
|
|
42
|
+
if (monthParts === null) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const { month } = monthParts;
|
|
46
|
+
return compareReductionDebtMonth(item.fields[debReductionMonthKey], month.toString());
|
|
47
|
+
});
|
|
48
|
+
// const foundMonth = searchLike(
|
|
49
|
+
// month.toString(),
|
|
50
|
+
// companiesMatchName.map((item) => item.fields["KỲ LƯƠNG"])
|
|
51
|
+
// )[0];
|
|
49
52
|
console.log(foundMonths);
|
|
50
|
-
const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
|
|
53
|
+
// const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
|
|
51
54
|
// console.log(finalCompnay);
|
|
52
55
|
|
|
53
56
|
const messages: string[] = [];
|
|
@@ -75,7 +78,7 @@ export async function debtCollectionRateTool(options: {
|
|
|
75
78
|
message_content: messages.join("<hr>"),
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
|
-
return { content: [{ type: "text", text: JSON.stringify(
|
|
81
|
+
return { content: [{ type: "text", text: JSON.stringify(foundMonths) }] };
|
|
79
82
|
// console.log(finalCompnay);
|
|
80
83
|
} catch (e) {
|
|
81
84
|
return { content: [{ type: "text", text: JSON.stringify(e) }] };
|