@sellhapi/mcp 0.1.4 → 0.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/server.js +2 -0
- package/dist/tools/commerce.js +28 -0
- package/dist/tools/invoices.d.ts +7 -0
- package/dist/tools/invoices.js +80 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -13,6 +13,7 @@ const commerce_js_1 = require("./tools/commerce.js");
|
|
|
13
13
|
const content_js_1 = require("./tools/content.js");
|
|
14
14
|
const intelligence_js_1 = require("./tools/intelligence.js");
|
|
15
15
|
const analytics_js_1 = require("./tools/analytics.js");
|
|
16
|
+
const invoices_js_1 = require("./tools/invoices.js");
|
|
16
17
|
const index_js_1 = require("./resources/index.js");
|
|
17
18
|
function createMcpServer() {
|
|
18
19
|
const server = new mcp_js_1.McpServer({
|
|
@@ -24,6 +25,7 @@ function createMcpServer() {
|
|
|
24
25
|
(0, content_js_1.registerContentTools)(server);
|
|
25
26
|
(0, intelligence_js_1.registerIntelligenceTools)(server);
|
|
26
27
|
(0, analytics_js_1.registerAnalyticsTools)(server);
|
|
28
|
+
(0, invoices_js_1.registerInvoiceTools)(server);
|
|
27
29
|
(0, index_js_1.registerResources)(server);
|
|
28
30
|
return server;
|
|
29
31
|
}
|
package/dist/tools/commerce.js
CHANGED
|
@@ -72,6 +72,34 @@ function registerCommerceTools(server) {
|
|
|
72
72
|
const data = await (0, client_js_1.get)("/api/mcp/appointments/services");
|
|
73
73
|
return JSON.stringify(data.services, null, 2);
|
|
74
74
|
}));
|
|
75
|
+
// ── Discounts ─────────────────────────────────────────────────────────────
|
|
76
|
+
server.registerTool("list_discounts", {
|
|
77
|
+
title: "List Discounts",
|
|
78
|
+
description: "List all active discounts for this vendor. Returns id, name, code, discountType, value, scope, usage count, and expiry. Use this to check existing discounts before creating new ones.",
|
|
79
|
+
annotations: { readOnlyHint: true },
|
|
80
|
+
}, async () => (0, util_js_1.safeCall)(async () => {
|
|
81
|
+
const data = await (0, client_js_1.get)("/api/mcp/discounts");
|
|
82
|
+
return JSON.stringify(data.discounts, null, 2);
|
|
83
|
+
}));
|
|
84
|
+
server.registerTool("create_discount", {
|
|
85
|
+
title: "Create Discount",
|
|
86
|
+
description: "Create a discount code or automatic discount. For percentage discounts, value is 1–100 (e.g. 20 = 20% off). For fixed discounts, value is in kobo (₦1 = 100 kobo) — the API converts to Naira internally. minimumOrderKobo is also in kobo. scope 'all_products' applies sitewide. 'specific_products' and 'specific_categories' require editing via the dashboard after creation. code is optional — omit for automatic (no-code) discounts.",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
name: v4_1.z.string().describe("Internal discount name e.g. 'Lagos Launch 20% Off'"),
|
|
89
|
+
discountType: v4_1.z.enum(["percentage", "fixed"]).describe("percentage = % off, fixed = fixed Naira amount off"),
|
|
90
|
+
value: v4_1.z.number().describe("For percentage: 1–100. For fixed: amount in kobo (₦1 = 100 kobo)."),
|
|
91
|
+
code: v4_1.z.string().optional().describe("Discount code customers enter at checkout (e.g. 'LAUNCH20'). Omit for automatic discount."),
|
|
92
|
+
description: v4_1.z.string().optional().describe("Internal description"),
|
|
93
|
+
scope: v4_1.z.enum(["all_products", "specific_products", "specific_categories"]).optional().default("all_products").describe("Which products this applies to. specific_products/specific_categories require assigning products in the dashboard after creation."),
|
|
94
|
+
usageLimit: v4_1.z.number().int().min(1).optional().describe("Maximum total uses. Omit for unlimited."),
|
|
95
|
+
minimumOrderKobo: v4_1.z.number().int().min(0).optional().describe("Minimum cart total in kobo to qualify for this discount."),
|
|
96
|
+
expiresAt: v4_1.z.string().optional().describe("Expiry datetime — ISO 8601 string. Omit for no expiry."),
|
|
97
|
+
startsAt: v4_1.z.string().optional().describe("Start datetime — ISO 8601 string. Omit to activate immediately."),
|
|
98
|
+
},
|
|
99
|
+
}, async (input) => (0, util_js_1.safeCall)(async () => {
|
|
100
|
+
const data = await (0, client_js_1.post)("/api/mcp/discounts", input);
|
|
101
|
+
return JSON.stringify(data, null, 2);
|
|
102
|
+
}));
|
|
75
103
|
// ── Categories ────────────────────────────────────────────────────────────
|
|
76
104
|
server.registerTool("list_categories", {
|
|
77
105
|
title: "List Categories",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invoice tools — create and list custom, service, and appointment invoices.
|
|
3
|
+
* All three invoice types are vendor-initiated: the vendor creates the invoice
|
|
4
|
+
* and sends the payment link to the customer.
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
export declare function registerInvoiceTools(server: McpServer): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Invoice tools — create and list custom, service, and appointment invoices.
|
|
4
|
+
* All three invoice types are vendor-initiated: the vendor creates the invoice
|
|
5
|
+
* and sends the payment link to the customer.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.registerInvoiceTools = registerInvoiceTools;
|
|
9
|
+
const v4_1 = require("zod/v4");
|
|
10
|
+
const client_js_1 = require("../client.js");
|
|
11
|
+
const util_js_1 = require("../util.js");
|
|
12
|
+
function registerInvoiceTools(server) {
|
|
13
|
+
// ── List all invoices ─────────────────────────────────────────────────────
|
|
14
|
+
server.registerTool("list_invoices", {
|
|
15
|
+
title: "List Invoices",
|
|
16
|
+
description: "List all invoices across all types (custom, service, appointment). Returns the most recent 50 of each type with id, type, status, isPaid, recipient, link, and createdAt. Use this to check existing invoices before creating new ones.",
|
|
17
|
+
annotations: { readOnlyHint: true },
|
|
18
|
+
}, async () => (0, util_js_1.safeCall)(async () => {
|
|
19
|
+
const data = await (0, client_js_1.get)("/api/mcp/invoices");
|
|
20
|
+
return JSON.stringify(data, null, 2);
|
|
21
|
+
}));
|
|
22
|
+
// ── Create custom invoice ─────────────────────────────────────────────────
|
|
23
|
+
server.registerTool("create_custom_invoice", {
|
|
24
|
+
title: "Create Custom Invoice",
|
|
25
|
+
description: "Create a free-form invoice with custom line items for any recipient. Returns a payment link (/ci/:id) that you can share with the customer. Line item prices are in kobo (₦1 = 100 kobo). Recipient must have at least an email or phone.",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
title: v4_1.z.string().describe("Invoice title e.g. 'Website Design Project'"),
|
|
28
|
+
lineItems: v4_1.z.array(v4_1.z.object({
|
|
29
|
+
description: v4_1.z.string().describe("Line item description e.g. 'Logo Design'"),
|
|
30
|
+
qty: v4_1.z.number().int().min(1).describe("Quantity"),
|
|
31
|
+
unitPriceKobo: v4_1.z.number().int().min(0).describe("Unit price in kobo"),
|
|
32
|
+
})).min(1).describe("Invoice line items — at least one required"),
|
|
33
|
+
recipient: v4_1.z.object({
|
|
34
|
+
name: v4_1.z.string().describe("Recipient full name"),
|
|
35
|
+
email: v4_1.z.string().optional().describe("Recipient email"),
|
|
36
|
+
phone: v4_1.z.string().optional().describe("Recipient phone (Nigerian format, e.g. 08012345678)"),
|
|
37
|
+
}).describe("Invoice recipient — must have at least email or phone"),
|
|
38
|
+
notes: v4_1.z.string().optional().describe("Internal notes or payment terms shown on the invoice"),
|
|
39
|
+
},
|
|
40
|
+
}, async (input) => (0, util_js_1.safeCall)(async () => {
|
|
41
|
+
const data = await (0, client_js_1.post)("/api/mcp/invoices/custom", input);
|
|
42
|
+
return JSON.stringify(data, null, 2);
|
|
43
|
+
}));
|
|
44
|
+
// ── Create service invoice ────────────────────────────────────────────────
|
|
45
|
+
server.registerTool("create_service_invoice", {
|
|
46
|
+
title: "Create Service Invoice",
|
|
47
|
+
description: "Create an invoice for a specific service listing. Call list_service_listings first to get a valid serviceListingId. Returns a payment link (/service-invoices/:id) the customer can pay online. The price you set overrides the listing's default price — use this for custom quotes.",
|
|
48
|
+
inputSchema: {
|
|
49
|
+
serviceListingId: v4_1.z.string().uuid().describe("Service listing ID from list_service_listings"),
|
|
50
|
+
priceKobo: v4_1.z.number().int().min(0).describe("Invoice price in kobo (can differ from listing's base price)"),
|
|
51
|
+
recipient: v4_1.z.object({
|
|
52
|
+
name: v4_1.z.string().describe("Recipient full name"),
|
|
53
|
+
email: v4_1.z.string().optional().describe("Recipient email"),
|
|
54
|
+
phone: v4_1.z.string().optional().describe("Recipient phone (Nigerian format)"),
|
|
55
|
+
}).describe("Invoice recipient — must have at least email or phone"),
|
|
56
|
+
notes: v4_1.z.string().optional().describe("Notes or scope of work for this engagement"),
|
|
57
|
+
},
|
|
58
|
+
}, async (input) => (0, util_js_1.safeCall)(async () => {
|
|
59
|
+
const data = await (0, client_js_1.post)("/api/mcp/invoices/service", input);
|
|
60
|
+
return JSON.stringify(data, null, 2);
|
|
61
|
+
}));
|
|
62
|
+
// ── Create appointment invoice ────────────────────────────────────────────
|
|
63
|
+
server.registerTool("create_appointment_invoice", {
|
|
64
|
+
title: "Create Appointment Invoice",
|
|
65
|
+
description: "Create an invoice for an appointment service (schedule-later mode). The customer pays first via the payment link (/appointment-invoices/:id), then you assign a specific time slot from the Appointments dashboard. Call list_appointment_services first to get a valid serviceId.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
serviceId: v4_1.z.string().uuid().describe("Appointment service ID from list_appointment_services"),
|
|
68
|
+
priceKobo: v4_1.z.number().int().min(0).describe("Invoice price in kobo"),
|
|
69
|
+
recipient: v4_1.z.object({
|
|
70
|
+
name: v4_1.z.string().describe("Recipient full name"),
|
|
71
|
+
email: v4_1.z.string().optional().describe("Recipient email"),
|
|
72
|
+
phone: v4_1.z.string().optional().describe("Recipient phone (Nigerian format)"),
|
|
73
|
+
}).describe("Invoice recipient — must have at least email or phone"),
|
|
74
|
+
notes: v4_1.z.string().optional().describe("Additional notes for the appointment"),
|
|
75
|
+
},
|
|
76
|
+
}, async (input) => (0, util_js_1.safeCall)(async () => {
|
|
77
|
+
const data = await (0, client_js_1.post)("/api/mcp/invoices/appointment", input);
|
|
78
|
+
return JSON.stringify(data, null, 2);
|
|
79
|
+
}));
|
|
80
|
+
}
|