gm-mcp 1.1.27 → 1.1.28

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/index.js CHANGED
@@ -20,6 +20,7 @@ const tools_1 = require("./tools");
20
20
  const zod_1 = __importDefault(require("zod"));
21
21
  const env_1 = require("./env");
22
22
  const lark_tool_1 = require("./tools/lark-tool");
23
+ const product_type_1 = require("./services/constants/product-type");
23
24
  exports.server = new mcp_js_1.McpServer({
24
25
  name: "mcp-server",
25
26
  version: "1.0.0",
@@ -69,44 +70,70 @@ exports.server.tool("statistic_salary_x3_in_range", "Get statistic salary x3 wit
69
70
  sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
70
71
  });
71
72
  }));
72
- exports.server.registerTool("debt_collection", {
73
- description: "The company's debt collection information",
74
- inputSchema: {
75
- company_name: zod_1.default.string({ description: "Company name to get data" }),
76
- month: zod_1.default
77
- .string()
78
- .optional()
79
- .describe("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"),
80
- },
73
+ exports.server.tool("debt_collection", "The company's debt collection information", {
74
+ company_name: zod_1.default.string({ description: "Company name to get data" }),
75
+ }, (args) => __awaiter(void 0, void 0, void 0, function* () {
76
+ const { company_name } = args;
77
+ return (0, lark_tool_1.debtCollectionRateTool)({
78
+ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
79
+ companyName: company_name,
80
+ productType: product_type_1.PRODUCT_TYPE.EWA_02_03,
81
+ });
82
+ }));
83
+ exports.server.tool("debt_collection_with_month", "The company's debt collection information with month", {
84
+ month: zod_1.default
85
+ .string()
86
+ .describe("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"),
87
+ company_name: zod_1.default.string({ description: "Company name to get data" }),
88
+ }, (args) => __awaiter(void 0, void 0, void 0, function* () {
89
+ const { month, company_name } = args;
90
+ return (0, lark_tool_1.debtCollectionRateTool)({
91
+ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
92
+ monthDate: month,
93
+ companyName: company_name,
94
+ productType: product_type_1.PRODUCT_TYPE.EWA_02_03,
95
+ });
96
+ }));
97
+ exports.server.tool("debt_collection_ewa_02", "The company's debt collection information with EWA 02 - 03 product type", {
98
+ company_name: zod_1.default.string({ description: "Company name to get data" }),
99
+ }, (args) => __awaiter(void 0, void 0, void 0, function* () {
100
+ const { company_name } = args;
101
+ return (0, lark_tool_1.debtCollectionRateTool)({
102
+ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
103
+ companyName: company_name,
104
+ productType: product_type_1.PRODUCT_TYPE.EWA_02_03,
105
+ });
106
+ }));
107
+ exports.server.tool("debt_collection_ewa_04", "The company's debt collection information with EWA 04 product type", {
108
+ company_name: zod_1.default.string({ description: "Company name to get data" }),
109
+ }, (args) => __awaiter(void 0, void 0, void 0, function* () {
110
+ const { company_name } = args;
111
+ return (0, lark_tool_1.debtCollectionRateTool)({
112
+ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
113
+ companyName: company_name,
114
+ productType: product_type_1.PRODUCT_TYPE.EWA_04,
115
+ });
116
+ }));
117
+ exports.server.tool("debt_collection_x3", "The company's debt collection information with Lương X3 product type", {
118
+ company_name: zod_1.default.string({ description: "Company name to get data" }),
119
+ }, (args) => __awaiter(void 0, void 0, void 0, function* () {
120
+ const { company_name } = args;
121
+ return (0, lark_tool_1.debtCollectionRateTool)({
122
+ sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
123
+ companyName: company_name,
124
+ productType: product_type_1.PRODUCT_TYPE.X3,
125
+ });
126
+ }));
127
+ exports.server.tool("debt_collection_x3", "The company's debt collection information with Lương X3 - EVF product type", {
128
+ company_name: zod_1.default.string({ description: "Company name to get data" }),
81
129
  }, (args) => __awaiter(void 0, void 0, void 0, function* () {
82
130
  const { company_name } = args;
83
131
  return (0, lark_tool_1.debtCollectionRateTool)({
84
132
  sendMessageToLark: (0, env_1.getEnv)().SEND_MESSAGE_TO_LARK === "true",
85
- // monthDate: month || "",
86
133
  companyName: company_name,
134
+ productType: product_type_1.PRODUCT_TYPE.X3_EVF,
87
135
  });
88
136
  }));
89
- // server.tool(
90
- // "debt_collection_with_month",
91
- // "The company's debt collection information with month",
92
- // {
93
- // month: z
94
- // .string()
95
- // .optional()
96
- // .describe(
97
- // "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"
98
- // ),
99
- // company_name: z.string({ description: "Company name to get data" }),
100
- // },
101
- // async (args) => {
102
- // const { month, company_name } = args;
103
- // return debtCollectionRateTool({
104
- // sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
105
- // monthDate: month,
106
- // companyName: company_name,
107
- // });
108
- // }
109
- // );
110
137
  function bootstap() {
111
138
  (0, env_1.ensureEnvVariables)();
112
139
  const transport = new stdio_js_1.StdioServerTransport();
@@ -0,0 +1,6 @@
1
+ export declare const PRODUCT_TYPE: {
2
+ readonly EWA_02_03: "EWA 02 - 03";
3
+ readonly EWA_04: "EWA 04";
4
+ readonly X3: "Lương X3";
5
+ readonly X3_EVF: "Lương X3 - EVF";
6
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PRODUCT_TYPE = void 0;
4
+ exports.PRODUCT_TYPE = {
5
+ EWA_02_03: "EWA 02 - 03",
6
+ EWA_04: "EWA 04",
7
+ X3: "Lương X3",
8
+ X3_EVF: "Lương X3 - EVF",
9
+ };
package/dist/test.js CHANGED
@@ -8,33 +8,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const v3_1 = __importDefault(require("zod/v3"));
16
12
  const env_1 = require("./env");
17
- const zod_to_json_schema_1 = require("zod-to-json-schema");
13
+ const lark_tool_1 = require("./tools/lark-tool");
14
+ const product_type_1 = require("./services/constants/product-type");
18
15
  function setupTest() {
19
16
  return __awaiter(this, void 0, void 0, function* () {
20
17
  (0, env_1.ensureEnvVariables)();
21
- const mySchema = v3_1.default
22
- .object({
23
- myString: v3_1.default.string().min(5),
24
- month: v3_1.default
25
- .string()
26
- .optional()
27
- .describe("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"),
28
- })
29
- .describe("My neat object schema");
30
- const res1 = (0, zod_to_json_schema_1.zodToJsonSchema)(mySchema);
31
- console.log(res1);
32
18
  // const r = await fetchDebtCollectionRecords();
33
19
  // console.log(r.length);
34
20
  // const compnay = "BGG";
35
21
  // const month = "12/2025";
36
- // const res = await debtCollectionRateTool({ sendMessageToLark: true, companyName: 'SHYANG', monthDate: '07/2025' });
37
- // console.log(res);
22
+ const res = yield (0, lark_tool_1.debtCollectionRateTool)({
23
+ sendMessageToLark: true,
24
+ companyName: "Tkg",
25
+ // monthDate: "8/2025",
26
+ productType: product_type_1.PRODUCT_TYPE.X3_EVF,
27
+ });
28
+ console.log(res);
38
29
  // const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
39
30
  // try {
40
31
  // const records = await fetchReportRecords({ view_id: "vewI23hNnx", field_names: fieldNames });
@@ -3,4 +3,5 @@ export declare function debtCollectionRateTool(options: {
3
3
  sendMessageToLark: boolean;
4
4
  companyName: string;
5
5
  monthDate?: string;
6
+ productType?: string;
6
7
  }): Promise<CallToolResult>;
@@ -25,7 +25,7 @@ const statusKey = "TRẠNG THÁI";
25
25
  function debtCollectionRateTool(options) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  var _c, _d;
28
- const { sendMessageToLark, companyName, monthDate } = options;
28
+ const { sendMessageToLark, companyName, monthDate, productType } = options;
29
29
  const monthParts = !monthDate ? null : (0, helpers_1.extractMonth)(monthDate);
30
30
  // if (monthParts === null) {
31
31
  // return { content: [{ type: "text", text: `${monthDate} is invalid` }] };
@@ -43,24 +43,33 @@ function debtCollectionRateTool(options) {
43
43
  const companiesMatchName = records.filter((item) => item.fields[companyKey] === foundName);
44
44
  // console.log(companiesMatchName);
45
45
  // Find by debt reduction month, search fully match
46
- const foundMonths = companiesMatchName.filter((item) => {
46
+ // Then find by product
47
+ const foundRecords = companiesMatchName
48
+ .filter((item) => {
47
49
  if (monthParts === null) {
48
50
  return true;
49
51
  }
50
52
  const { month } = monthParts;
51
53
  return compareReductionDebtMonth(item.fields[debReductionMonthKey], month.toString());
54
+ })
55
+ .filter((item) => {
56
+ var _c;
57
+ if (!productType) {
58
+ return true;
59
+ }
60
+ return ((_c = item.fields[productKey]) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === productType.toLowerCase();
52
61
  });
53
62
  // const foundMonth = searchLike(
54
63
  // month.toString(),
55
64
  // companiesMatchName.map((item) => item.fields["KỲ LƯƠNG"])
56
65
  // )[0];
57
- console.log(foundMonths);
66
+ console.log(foundRecords);
58
67
  // const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
59
68
  // console.log(finalCompnay);
60
69
  const messages = [];
61
- for (const item of foundMonths) {
70
+ for (const item of foundRecords) {
62
71
  messages.push([
63
- item.fields[productKey] || "N/A",
72
+ item.fields[debReductionMonthKey] || "N/A",
64
73
  typeof item.fields[debtCollectionRateKey] === "undefined"
65
74
  ? "N/A"
66
75
  : round(Number(item.fields[debtCollectionRateKey])) + "%",
@@ -83,11 +92,11 @@ function debtCollectionRateTool(options) {
83
92
  // return {} as any;
84
93
  if (sendMessageToLark) {
85
94
  yield (0, lark_service_1.sendReportOpsGroup)({
86
- title: `Tỉ lệ thu nợ - ${foundName}`,
95
+ title: ['Tỉ lệ thu nợ', foundName, productType].filter(Boolean).join(' - '),
87
96
  message_content: messages.join("<hr>"),
88
97
  });
89
98
  }
90
- return { content: [{ type: "text", text: JSON.stringify(foundMonths) }] };
99
+ return { content: [{ type: "text", text: JSON.stringify(foundRecords) }] };
91
100
  // console.log(finalCompnay);
92
101
  }
93
102
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-mcp",
3
- "version": "1.1.27",
3
+ "version": "1.1.28",
4
4
  "description": "Mcp server for Gm",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  import z from "zod";
14
14
  import { ensureEnvVariables, getEnv } from "./env";
15
15
  import { debtCollectionRateTool } from "./tools/lark-tool";
16
+ import { PRODUCT_TYPE } from "./services/constants/product-type";
16
17
 
17
18
  export const server = new McpServer(
18
19
  {
@@ -89,51 +90,107 @@ server.tool(
89
90
  }
90
91
  );
91
92
 
92
- server.registerTool(
93
+ server.tool(
93
94
  "debt_collection",
95
+ "The company's debt collection information",
94
96
  {
95
- description: "The company's debt collection information",
96
- inputSchema: {
97
- company_name: z.string({ description: "Company name to get data" }),
98
- month: z
99
- .string()
100
- .optional()
101
- .describe(
102
- "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"
103
- ),
104
- },
97
+ company_name: z.string({ description: "Company name to get data" }),
98
+ },
99
+ async (args) => {
100
+ const { company_name } = args;
101
+ return debtCollectionRateTool({
102
+ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
103
+ companyName: company_name,
104
+ productType: PRODUCT_TYPE.EWA_02_03,
105
+ });
106
+ }
107
+ );
108
+
109
+ server.tool(
110
+ "debt_collection_with_month",
111
+ "The company's debt collection information with month",
112
+ {
113
+ month: z
114
+ .string()
115
+ .describe(
116
+ "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"
117
+ ),
118
+ company_name: z.string({ description: "Company name to get data" }),
119
+ },
120
+ async (args) => {
121
+ const { month, company_name } = args;
122
+ return debtCollectionRateTool({
123
+ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
124
+ monthDate: month,
125
+ companyName: company_name,
126
+ productType: PRODUCT_TYPE.EWA_02_03,
127
+ });
128
+ }
129
+ );
130
+
131
+ server.tool(
132
+ "debt_collection_ewa_02",
133
+ "The company's debt collection information with EWA 02 - 03 product type",
134
+ {
135
+ company_name: z.string({ description: "Company name to get data" }),
136
+ },
137
+ async (args) => {
138
+ const { company_name } = args;
139
+ return debtCollectionRateTool({
140
+ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
141
+ companyName: company_name,
142
+ productType: PRODUCT_TYPE.EWA_02_03,
143
+ });
144
+ }
145
+ );
146
+
147
+ server.tool(
148
+ "debt_collection_ewa_04",
149
+ "The company's debt collection information with EWA 04 product type",
150
+ {
151
+ company_name: z.string({ description: "Company name to get data" }),
152
+ },
153
+ async (args) => {
154
+ const { company_name } = args;
155
+ return debtCollectionRateTool({
156
+ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
157
+ companyName: company_name,
158
+ productType: PRODUCT_TYPE.EWA_04,
159
+ });
160
+ }
161
+ );
162
+
163
+ server.tool(
164
+ "debt_collection_x3",
165
+ "The company's debt collection information with Lương X3 product type",
166
+ {
167
+ company_name: z.string({ description: "Company name to get data" }),
105
168
  },
106
169
  async (args) => {
107
170
  const { company_name } = args;
108
171
  return debtCollectionRateTool({
109
172
  sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
110
- // monthDate: month || "",
111
173
  companyName: company_name,
174
+ productType: PRODUCT_TYPE.X3,
112
175
  });
113
176
  }
114
177
  );
115
178
 
116
- // server.tool(
117
- // "debt_collection_with_month",
118
- // "The company's debt collection information with month",
119
- // {
120
- // month: z
121
- // .string()
122
- // .optional()
123
- // .describe(
124
- // "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"
125
- // ),
126
- // company_name: z.string({ description: "Company name to get data" }),
127
- // },
128
- // async (args) => {
129
- // const { month, company_name } = args;
130
- // return debtCollectionRateTool({
131
- // sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
132
- // monthDate: month,
133
- // companyName: company_name,
134
- // });
135
- // }
136
- // );
179
+ server.tool(
180
+ "debt_collection_x3",
181
+ "The company's debt collection information with Lương X3 - EVF product type",
182
+ {
183
+ company_name: z.string({ description: "Company name to get data" }),
184
+ },
185
+ async (args) => {
186
+ const { company_name } = args;
187
+ return debtCollectionRateTool({
188
+ sendMessageToLark: getEnv().SEND_MESSAGE_TO_LARK === "true",
189
+ companyName: company_name,
190
+ productType: PRODUCT_TYPE.X3_EVF,
191
+ });
192
+ }
193
+ );
137
194
 
138
195
  function bootstap() {
139
196
  ensureEnvVariables();
@@ -0,0 +1,6 @@
1
+ export const PRODUCT_TYPE = {
2
+ EWA_02_03: "EWA 02 - 03",
3
+ EWA_04: "EWA 04",
4
+ X3: "Lương X3",
5
+ X3_EVF: "Lương X3 - EVF",
6
+ } as const;
package/src/test.ts CHANGED
@@ -13,32 +13,23 @@ import {
13
13
  } from "./tools";
14
14
  import { debtCollectionRateTool } from "./tools/lark-tool";
15
15
  import { zodToJsonSchema } from "zod-to-json-schema";
16
+ import { PRODUCT_TYPE } from "./services/constants/product-type";
16
17
 
17
18
  async function setupTest() {
18
19
  ensureEnvVariables();
19
20
 
20
- const mySchema = z
21
- .object({
22
- myString: z.string().min(5),
23
- month: z
24
- .string()
25
- .optional()
26
- .describe(
27
- "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"
28
- ),
29
- })
30
- .describe("My neat object schema");
31
-
32
- const res1 = zodToJsonSchema(mySchema);
33
- console.log(res1);
34
-
35
21
  // const r = await fetchDebtCollectionRecords();
36
22
  // console.log(r.length);
37
23
 
38
24
  // const compnay = "BGG";
39
25
  // const month = "12/2025";
40
- // const res = await debtCollectionRateTool({ sendMessageToLark: true, companyName: 'SHYANG', monthDate: '07/2025' });
41
- // console.log(res);
26
+ const res = await debtCollectionRateTool({
27
+ sendMessageToLark: true,
28
+ companyName: "Tkg",
29
+ // monthDate: "8/2025",
30
+ productType: PRODUCT_TYPE.X3_EVF,
31
+ });
32
+ console.log(res);
42
33
 
43
34
  // const fieldNames = REPORT_COLUMS.map((item) => item.field_name);
44
35
  // try {
@@ -17,8 +17,9 @@ export async function debtCollectionRateTool(options: {
17
17
  sendMessageToLark: boolean;
18
18
  companyName: string;
19
19
  monthDate?: string;
20
+ productType?: string;
20
21
  }): Promise<CallToolResult> {
21
- const { sendMessageToLark, companyName, monthDate } = options;
22
+ const { sendMessageToLark, companyName, monthDate, productType } = options;
22
23
  const monthParts = !monthDate ? null : extractMonth(monthDate);
23
24
  // if (monthParts === null) {
24
25
  // return { content: [{ type: "text", text: `${monthDate} is invalid` }] };
@@ -38,31 +39,38 @@ export async function debtCollectionRateTool(options: {
38
39
  // console.log(companiesMatchName);
39
40
 
40
41
  // Find by debt reduction month, search fully match
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
- });
42
+ // Then find by product
43
+ const foundRecords = companiesMatchName
44
+ .filter((item) => {
45
+ if (monthParts === null) {
46
+ return true;
47
+ }
48
+ const { month } = monthParts;
49
+ return compareReductionDebtMonth(item.fields[debReductionMonthKey], month.toString());
50
+ })
51
+ .filter((item) => {
52
+ if (!productType) {
53
+ return true;
54
+ }
55
+ return (item.fields[productKey] as string)?.toLowerCase() === productType.toLowerCase();
56
+ });
48
57
  // const foundMonth = searchLike(
49
58
  // month.toString(),
50
59
  // companiesMatchName.map((item) => item.fields["KỲ LƯƠNG"])
51
60
  // )[0];
52
- console.log(foundMonths);
61
+ console.log(foundRecords);
53
62
  // const finalCompnay = companiesMatchName.find((item) => item.fields["KỲ LƯƠNG"] === foundMonth);
54
63
  // console.log(finalCompnay);
55
64
 
56
65
  const messages: string[] = [];
57
- for (const item of foundMonths) {
66
+ for (const item of foundRecords) {
58
67
  messages.push(
59
68
  [
60
- item.fields[productKey] || "N/A",
69
+ item.fields[debReductionMonthKey] || "N/A",
61
70
  typeof item.fields[debtCollectionRateKey] === "undefined"
62
71
  ? "N/A"
63
72
  : round(Number(item.fields[debtCollectionRateKey])) + "%",
64
73
  item?.fields[statusKey]?.[0]?.text || "N/A",
65
-
66
74
  ].join(" | ")
67
75
  );
68
76
  // messages.push(
@@ -84,11 +92,11 @@ export async function debtCollectionRateTool(options: {
84
92
 
85
93
  if (sendMessageToLark) {
86
94
  await sendReportOpsGroup({
87
- title: `Tỉ lệ thu nợ - ${foundName}`,
95
+ title: ['Tỉ lệ thu nợ', foundName,productType].filter(Boolean).join(' - '),
88
96
  message_content: messages.join("<hr>"),
89
97
  });
90
98
  }
91
- return { content: [{ type: "text", text: JSON.stringify(foundMonths) }] };
99
+ return { content: [{ type: "text", text: JSON.stringify(foundRecords) }] };
92
100
  // console.log(finalCompnay);
93
101
  } catch (e) {
94
102
  return { content: [{ type: "text", text: JSON.stringify(e) }] };