@hisaabo/mcp 0.1.0
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/.turbo/turbo-build.log +14 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/README.md +155 -0
- package/dist/bin/index.js +2682 -0
- package/dist/bin/index.js.map +1 -0
- package/dist/index.js +2681 -0
- package/package.json +26 -0
- package/src/client.ts +1315 -0
- package/src/index.ts +64 -0
- package/src/lib/errors.ts +49 -0
- package/src/lib/pagination.ts +35 -0
- package/src/resources/index.ts +211 -0
- package/src/server.ts +55 -0
- package/src/tools/bankAccount.ts +200 -0
- package/src/tools/dashboard.ts +110 -0
- package/src/tools/expense.ts +175 -0
- package/src/tools/gst.ts +90 -0
- package/src/tools/import.ts +298 -0
- package/src/tools/invoice.ts +256 -0
- package/src/tools/item.ts +262 -0
- package/src/tools/party.ts +266 -0
- package/src/tools/payment.ts +222 -0
- package/src/tools/reports.ts +246 -0
- package/src/tools/shipment.ts +222 -0
- package/src/tools/store.ts +177 -0
- package/src/tools/target.ts +143 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sales target tools — create and track sales goals for team members.
|
|
3
|
+
*
|
|
4
|
+
* Tools registered:
|
|
5
|
+
* target_list — list all sales targets (admin view)
|
|
6
|
+
* target_create — create a new sales target for a seller
|
|
7
|
+
* target_progress — get progress for a specific target
|
|
8
|
+
* target_my — get the current user's active targets with progress
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import type { HisaaboClient } from "../client.js";
|
|
14
|
+
import { wrapTool } from "../lib/errors.js";
|
|
15
|
+
|
|
16
|
+
const TARGET_TYPES = ["order_count", "order_value", "item_quantity"] as const;
|
|
17
|
+
const PERIOD_TYPES = ["daily", "weekly", "monthly", "quarterly", "custom"] as const;
|
|
18
|
+
|
|
19
|
+
export function registerTargetTools(server: McpServer, client: HisaaboClient) {
|
|
20
|
+
|
|
21
|
+
server.tool(
|
|
22
|
+
"target_list",
|
|
23
|
+
[
|
|
24
|
+
"List sales targets for the active business (admin/viewer view).",
|
|
25
|
+
"Filter by user, period type, or active targets only.",
|
|
26
|
+
"Set with_progress=true to include real-time progress (current vs target, percentage, on-track status).",
|
|
27
|
+
"Use user_id to see targets for a specific seller.",
|
|
28
|
+
].join(" "),
|
|
29
|
+
{
|
|
30
|
+
user_id: z.string().uuid().optional()
|
|
31
|
+
.describe("Filter targets assigned to a specific user UUID."),
|
|
32
|
+
period_type: z.enum(PERIOD_TYPES).optional()
|
|
33
|
+
.describe("Filter by period: 'daily', 'weekly', 'monthly', 'quarterly', or 'custom'."),
|
|
34
|
+
active: z.boolean().optional()
|
|
35
|
+
.describe("If true, return only targets whose period includes today (active targets)."),
|
|
36
|
+
with_progress: z.boolean().default(false)
|
|
37
|
+
.describe("If true, compute and return real-time progress for each target. Adds latency."),
|
|
38
|
+
},
|
|
39
|
+
wrapTool(async (input) => {
|
|
40
|
+
const targets = await client.target.list({
|
|
41
|
+
userId: input.user_id,
|
|
42
|
+
periodType: input.period_type,
|
|
43
|
+
active: input.active,
|
|
44
|
+
withProgress: input.with_progress,
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
content: [{
|
|
48
|
+
type: "text" as const,
|
|
49
|
+
text: JSON.stringify(targets, null, 2),
|
|
50
|
+
}],
|
|
51
|
+
};
|
|
52
|
+
})
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
server.tool(
|
|
56
|
+
"target_create",
|
|
57
|
+
[
|
|
58
|
+
"Create a sales target for a seller. Requires admin role.",
|
|
59
|
+
"target_type options: 'order_count' (number of invoices), 'order_value' (total revenue), 'item_quantity' (units sold of a specific item).",
|
|
60
|
+
"For 'item_quantity' targets, item_id is required.",
|
|
61
|
+
"period_start and period_end define the target window. Use period_type to categorize (daily/weekly/monthly/quarterly/custom).",
|
|
62
|
+
"Example: set a monthly revenue target of ₹1,00,000 for a seller.",
|
|
63
|
+
].join(" "),
|
|
64
|
+
{
|
|
65
|
+
user_id: z.string().uuid()
|
|
66
|
+
.describe("UUID of the seller this target is assigned to."),
|
|
67
|
+
target_type: z.enum(TARGET_TYPES)
|
|
68
|
+
.describe("'order_count' = number of invoices, 'order_value' = total revenue amount, 'item_quantity' = units of a specific item sold."),
|
|
69
|
+
target_value: z.string().regex(/^\d+(\.\d{1,2})?$/)
|
|
70
|
+
.describe("Target value as decimal string: e.g. '100000.00' for ₹1 lakh revenue, or '50' for 50 orders."),
|
|
71
|
+
item_id: z.string().uuid().optional().nullable()
|
|
72
|
+
.describe("Required for 'item_quantity' targets — the specific item UUID to track."),
|
|
73
|
+
period_type: z.enum(PERIOD_TYPES)
|
|
74
|
+
.describe("Categorization: 'daily', 'weekly', 'monthly', 'quarterly', or 'custom'."),
|
|
75
|
+
period_start: z.string().datetime()
|
|
76
|
+
.describe("Start of the target period (ISO 8601)."),
|
|
77
|
+
period_end: z.string().datetime()
|
|
78
|
+
.describe("End of the target period (ISO 8601). Must be after period_start."),
|
|
79
|
+
notes: z.string().max(500).optional().nullable()
|
|
80
|
+
.describe("Optional notes about this target, e.g. 'Q1 FY2025 target'."),
|
|
81
|
+
},
|
|
82
|
+
wrapTool(async (input) => {
|
|
83
|
+
const target = await client.target.create({
|
|
84
|
+
userId: input.user_id,
|
|
85
|
+
targetType: input.target_type,
|
|
86
|
+
targetValue: input.target_value,
|
|
87
|
+
itemId: input.item_id,
|
|
88
|
+
periodType: input.period_type,
|
|
89
|
+
periodStart: input.period_start,
|
|
90
|
+
periodEnd: input.period_end,
|
|
91
|
+
notes: input.notes,
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
content: [{
|
|
95
|
+
type: "text" as const,
|
|
96
|
+
text: JSON.stringify(target, null, 2),
|
|
97
|
+
}],
|
|
98
|
+
};
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
server.tool(
|
|
103
|
+
"target_progress",
|
|
104
|
+
[
|
|
105
|
+
"Get real-time progress for a specific sales target.",
|
|
106
|
+
"Returns current achievement, target value, percentage, remaining amount, and whether the seller is on track.",
|
|
107
|
+
"Also shows timeline: days total, days elapsed, days remaining.",
|
|
108
|
+
"'onTrack' is true if current progress is >= what it should be based on time elapsed.",
|
|
109
|
+
].join(" "),
|
|
110
|
+
{
|
|
111
|
+
target_id: z.string().uuid()
|
|
112
|
+
.describe("Target UUID from target_list."),
|
|
113
|
+
},
|
|
114
|
+
wrapTool(async (input) => {
|
|
115
|
+
const result = await client.target.getProgress(input.target_id);
|
|
116
|
+
return {
|
|
117
|
+
content: [{
|
|
118
|
+
type: "text" as const,
|
|
119
|
+
text: JSON.stringify(result, null, 2),
|
|
120
|
+
}],
|
|
121
|
+
};
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
server.tool(
|
|
126
|
+
"target_my",
|
|
127
|
+
[
|
|
128
|
+
"Get the current user's active sales targets with real-time progress.",
|
|
129
|
+
"Returns targets whose period includes today, with progress data for each.",
|
|
130
|
+
"Sellers use this to check their own performance without needing admin access.",
|
|
131
|
+
].join(" "),
|
|
132
|
+
{},
|
|
133
|
+
wrapTool(async (_input) => {
|
|
134
|
+
const targets = await client.target.myTargets();
|
|
135
|
+
return {
|
|
136
|
+
content: [{
|
|
137
|
+
type: "text" as const,
|
|
138
|
+
text: JSON.stringify(targets, null, 2),
|
|
139
|
+
}],
|
|
140
|
+
};
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
}
|