@getcheddar/cheddar-mcp 1.0.5 → 2.0.1
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/README.md +56 -330
- package/bin/cheddar-mcp.mjs +5 -0
- package/dist/core.d.ts +17 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +79 -0
- package/dist/core.js.map +1 -0
- package/dist/http.d.ts +6 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +65 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -75
- package/dist/index.js.map +1 -1
- package/dist/lib/legacy-client.d.ts +44 -0
- package/dist/lib/legacy-client.d.ts.map +1 -0
- package/dist/lib/legacy-client.js +149 -0
- package/dist/lib/legacy-client.js.map +1 -0
- package/dist/tools/customers.d.ts +2 -2
- package/dist/tools/customers.d.ts.map +1 -1
- package/dist/tools/customers.js +103 -103
- package/dist/tools/customers.js.map +1 -1
- package/dist/tools/plans.d.ts +10 -0
- package/dist/tools/plans.d.ts.map +1 -0
- package/dist/tools/plans.js +26 -0
- package/dist/tools/plans.js.map +1 -0
- package/package.json +10 -7
- package/dist/lib/cheddar-client.d.ts +0 -111
- package/dist/lib/cheddar-client.d.ts.map +0 -1
- package/dist/lib/cheddar-client.js +0 -101
- package/dist/lib/cheddar-client.js.map +0 -1
- package/dist/tools/checkout.d.ts +0 -10
- package/dist/tools/checkout.d.ts.map +0 -1
- package/dist/tools/checkout.js +0 -641
- package/dist/tools/checkout.js.map +0 -1
- package/dist/tools/payment-methods.d.ts +0 -10
- package/dist/tools/payment-methods.d.ts.map +0 -1
- package/dist/tools/payment-methods.js +0 -162
- package/dist/tools/payment-methods.js.map +0 -1
- package/dist/tools/subscriptions.d.ts +0 -10
- package/dist/tools/subscriptions.d.ts.map +0 -1
- package/dist/tools/subscriptions.js +0 -191
- package/dist/tools/subscriptions.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,84 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "dotenv/config";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { checkoutTools, handleCheckoutTool } from "./tools/checkout.js";
|
|
9
|
-
// Configuration from environment
|
|
10
|
-
const config = {
|
|
11
|
-
apiUrl: process.env.CHEDDAR_API_URL || "https://api.chdr.dev",
|
|
12
|
-
clientId: process.env.CHEDDAR_CLIENT_ID || "",
|
|
13
|
-
clientSecret: process.env.CHEDDAR_CLIENT_SECRET || "",
|
|
14
|
-
accessToken: process.env.CHEDDAR_ACCESS_TOKEN || "",
|
|
15
|
-
};
|
|
16
|
-
// Validate required config
|
|
17
|
-
if (!config.accessToken && (!config.clientId || !config.clientSecret)) {
|
|
18
|
-
console.error("Error: CHEDDAR_ACCESS_TOKEN or both CHEDDAR_CLIENT_ID and CHEDDAR_CLIENT_SECRET must be set");
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
// Initialize Cheddar API client
|
|
22
|
-
const cheddarClient = new CheddarApiClient(config);
|
|
23
|
-
// Combine all tools
|
|
24
|
-
const ALL_TOOLS = [
|
|
25
|
-
...customerTools,
|
|
26
|
-
...paymentMethodTools,
|
|
27
|
-
...subscriptionTools,
|
|
28
|
-
...checkoutTools,
|
|
29
|
-
];
|
|
30
|
-
// Create MCP server
|
|
31
|
-
const server = new Server({
|
|
32
|
-
name: "cheddar-mcp",
|
|
33
|
-
version: "0.1.0",
|
|
34
|
-
}, {
|
|
35
|
-
capabilities: {
|
|
36
|
-
tools: {},
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
// Handler for listing available tools
|
|
40
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
41
|
-
return {
|
|
42
|
-
tools: ALL_TOOLS,
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
// Handler for tool execution
|
|
46
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
47
|
-
const { name, arguments: args } = request.params;
|
|
3
|
+
import { LegacyApiError } from "./lib/legacy-client.js";
|
|
4
|
+
import { createCheddarMcpServer, MCP_PACKAGE_VERSION, runPreflight, } from "./core.js";
|
|
5
|
+
async function main() {
|
|
6
|
+
let server;
|
|
7
|
+
let client;
|
|
48
8
|
try {
|
|
49
|
-
|
|
50
|
-
if (name.startsWith("cheddar_customer_")) {
|
|
51
|
-
return await handleCustomerTool(cheddarClient, name, args);
|
|
52
|
-
}
|
|
53
|
-
if (name.startsWith("cheddar_payment_")) {
|
|
54
|
-
return await handlePaymentMethodTool(cheddarClient, name, args);
|
|
55
|
-
}
|
|
56
|
-
if (name.startsWith("cheddar_subscription_")) {
|
|
57
|
-
return await handleSubscriptionTool(cheddarClient, name, args);
|
|
58
|
-
}
|
|
59
|
-
if (name.startsWith("cheddar_checkout_")) {
|
|
60
|
-
return await handleCheckoutTool(cheddarClient, name, args);
|
|
61
|
-
}
|
|
62
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
9
|
+
({ server, client } = createCheddarMcpServer(MCP_PACKAGE_VERSION));
|
|
63
10
|
}
|
|
64
|
-
catch (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
11
|
+
catch (e) {
|
|
12
|
+
console.error(e instanceof Error ? e.message : String(e));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
await runPreflight(client);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
20
|
+
console.error(`Cheddar legacy API preflight failed: ${msg}`);
|
|
21
|
+
if (err instanceof LegacyApiError) {
|
|
22
|
+
console.error("[cheddar-mcp] Preflight response body:", typeof err.body === "string"
|
|
23
|
+
? err.body.slice(0, 4000)
|
|
24
|
+
: JSON.stringify(err.body).slice(0, 4000));
|
|
25
|
+
}
|
|
26
|
+
process.exit(1);
|
|
75
27
|
}
|
|
76
|
-
});
|
|
77
|
-
// Start server
|
|
78
|
-
async function main() {
|
|
79
28
|
const transport = new StdioServerTransport();
|
|
80
29
|
await server.connect(transport);
|
|
81
|
-
console.error("Cheddar MCP
|
|
30
|
+
console.error("Cheddar MCP (legacy HTTP Basic) running on stdio");
|
|
82
31
|
}
|
|
83
32
|
main().catch((error) => {
|
|
84
33
|
console.error("Fatal error:", error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,KAAK,UAAU,IAAI;IACjB,IAAI,MAAM,CAAC;IACX,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,wCAAwC,GAAG,EAAE,CAAC,CAAC;QAC7D,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CACX,wCAAwC,EACxC,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;gBAC1B,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;gBACzB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAC5C,CAAC;QACJ,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACpE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface LegacyCheddarConfig {
|
|
2
|
+
/** Product site origin, e.g. https://yoursubdomain.chargevault.com (no trailing slash) */
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
productCode: string;
|
|
5
|
+
/** HTTP Basic username (authorized user email) */
|
|
6
|
+
username: string;
|
|
7
|
+
/** HTTP Basic password (user password or product API key) */
|
|
8
|
+
password: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class LegacyCheddarClient {
|
|
11
|
+
private readonly base;
|
|
12
|
+
private readonly productCode;
|
|
13
|
+
private readonly auth;
|
|
14
|
+
constructor(cfg: LegacyCheddarConfig);
|
|
15
|
+
private parseBody;
|
|
16
|
+
/**
|
|
17
|
+
* GET legacy XML (or JSON if the endpoint supports `format=json`).
|
|
18
|
+
*/
|
|
19
|
+
get(pathWithLeadingSlash: string, query?: Record<string, string>): Promise<unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* POST `application/x-www-form-urlencoded` (legacy API style).
|
|
22
|
+
*/
|
|
23
|
+
postForm(pathWithLeadingSlash: string, fields: Record<string, string>): Promise<unknown>;
|
|
24
|
+
ping(): Promise<unknown>;
|
|
25
|
+
getCustomer(by: "code" | "id", value: string): Promise<unknown>;
|
|
26
|
+
searchCustomers(params: Record<string, string>): Promise<unknown>;
|
|
27
|
+
getPlans(planCode?: string): Promise<unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* Flat object keys become form keys; nested objects use bracket notation (subscription[planCode]).
|
|
30
|
+
*/
|
|
31
|
+
createCustomer(fields: Record<string, unknown>): Promise<unknown>;
|
|
32
|
+
updateCustomer(customerCode: string, fields: Record<string, unknown>): Promise<unknown>;
|
|
33
|
+
}
|
|
34
|
+
export declare class LegacyApiError extends Error {
|
|
35
|
+
readonly status: number;
|
|
36
|
+
readonly body: unknown;
|
|
37
|
+
constructor(status: number, body: unknown);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Flattens `{ firstName: "a", subscription: { planCode: "FREE" } }` into
|
|
41
|
+
* `firstName`, `subscription[planCode]` for legacy form posts.
|
|
42
|
+
*/
|
|
43
|
+
export declare function flattenFormFields(obj: Record<string, unknown>, prefix?: string): Record<string, string>;
|
|
44
|
+
//# sourceMappingURL=legacy-client.d.ts.map
|
|
@@ -0,0 +1 @@
|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,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAO9F;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM1C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,SAAK,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { XMLParser } from "fast-xml-parser";
|
|
2
|
+
function trimSlash(s) {
|
|
3
|
+
return s.replace(/\/+$/, "");
|
|
4
|
+
}
|
|
5
|
+
function basicAuthHeader(username, password) {
|
|
6
|
+
const token = Buffer.from(`${username}:${password}`, "utf8").toString("base64");
|
|
7
|
+
return `Basic ${token}`;
|
|
8
|
+
}
|
|
9
|
+
const xmlParser = new XMLParser({
|
|
10
|
+
ignoreAttributes: false,
|
|
11
|
+
attributeNamePrefix: "@_",
|
|
12
|
+
});
|
|
13
|
+
export class LegacyCheddarClient {
|
|
14
|
+
base;
|
|
15
|
+
productCode;
|
|
16
|
+
auth;
|
|
17
|
+
constructor(cfg) {
|
|
18
|
+
this.base = trimSlash(cfg.baseUrl);
|
|
19
|
+
this.productCode = encodeURIComponent(cfg.productCode);
|
|
20
|
+
this.auth = basicAuthHeader(cfg.username, cfg.password);
|
|
21
|
+
}
|
|
22
|
+
async parseBody(res) {
|
|
23
|
+
const text = await res.text();
|
|
24
|
+
const ct = res.headers.get("content-type") || "";
|
|
25
|
+
if (ct.includes("json") || (text.startsWith("{") && text.endsWith("}"))) {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(text);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
/* fall through */
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return xmlParser.parse(text);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return { _raw: text };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* GET legacy XML (or JSON if the endpoint supports `format=json`).
|
|
42
|
+
*/
|
|
43
|
+
async get(pathWithLeadingSlash, query) {
|
|
44
|
+
const q = new URLSearchParams(query);
|
|
45
|
+
const qs = q.toString();
|
|
46
|
+
const url = `${this.base}${pathWithLeadingSlash}${qs ? `?${qs}` : ""}`;
|
|
47
|
+
const res = await fetch(url, {
|
|
48
|
+
method: "GET",
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: this.auth,
|
|
51
|
+
Accept: "application/xml, application/json;q=0.9, text/xml;q=0.8, */*;q=0.1",
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const body = await this.parseBody(res);
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
throw new LegacyApiError(res.status, body);
|
|
57
|
+
}
|
|
58
|
+
return body;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* POST `application/x-www-form-urlencoded` (legacy API style).
|
|
62
|
+
*/
|
|
63
|
+
async postForm(pathWithLeadingSlash, fields) {
|
|
64
|
+
const url = `${this.base}${pathWithLeadingSlash}`;
|
|
65
|
+
const body = new URLSearchParams(fields);
|
|
66
|
+
const res = await fetch(url, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: this.auth,
|
|
70
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
71
|
+
Accept: "application/xml, application/json;q=0.9, text/xml;q=0.8, */*;q=0.1",
|
|
72
|
+
},
|
|
73
|
+
body,
|
|
74
|
+
});
|
|
75
|
+
const parsed = await this.parseBody(res);
|
|
76
|
+
if (!res.ok) {
|
|
77
|
+
throw new LegacyApiError(res.status, parsed);
|
|
78
|
+
}
|
|
79
|
+
return parsed;
|
|
80
|
+
}
|
|
81
|
+
async ping() {
|
|
82
|
+
return this.get(`/xml/plans/get/productCode/${this.productCode}`);
|
|
83
|
+
}
|
|
84
|
+
async getCustomer(by, value) {
|
|
85
|
+
const v = encodeURIComponent(value);
|
|
86
|
+
return this.get(`/xml/customers/get/productCode/${this.productCode}/${by}/${v}`);
|
|
87
|
+
}
|
|
88
|
+
async searchCustomers(params) {
|
|
89
|
+
return this.get(`/xml/customers/search/productCode/${this.productCode}`, {
|
|
90
|
+
...params,
|
|
91
|
+
format: "json",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async getPlans(planCode) {
|
|
95
|
+
if (planCode) {
|
|
96
|
+
return this.get(`/xml/plans/get/productCode/${this.productCode}/code/${encodeURIComponent(planCode)}`);
|
|
97
|
+
}
|
|
98
|
+
return this.get(`/xml/plans/get/productCode/${this.productCode}`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Flat object keys become form keys; nested objects use bracket notation (subscription[planCode]).
|
|
102
|
+
*/
|
|
103
|
+
async createCustomer(fields) {
|
|
104
|
+
const flat = flattenFormFields(fields);
|
|
105
|
+
return this.postForm(`/xml/customers/new/productCode/${this.productCode}`, flat);
|
|
106
|
+
}
|
|
107
|
+
async updateCustomer(customerCode, fields) {
|
|
108
|
+
const flat = flattenFormFields(fields);
|
|
109
|
+
return this.postForm(`/xml/customers/edit/productCode/${this.productCode}/code/${encodeURIComponent(customerCode)}`, flat);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export class LegacyApiError extends Error {
|
|
113
|
+
status;
|
|
114
|
+
body;
|
|
115
|
+
constructor(status, body) {
|
|
116
|
+
super(`Cheddar legacy API request failed (HTTP ${status}).`);
|
|
117
|
+
this.name = "LegacyApiError";
|
|
118
|
+
this.status = status;
|
|
119
|
+
this.body = body;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Flattens `{ firstName: "a", subscription: { planCode: "FREE" } }` into
|
|
124
|
+
* `firstName`, `subscription[planCode]` for legacy form posts.
|
|
125
|
+
*/
|
|
126
|
+
export function flattenFormFields(obj, prefix = "") {
|
|
127
|
+
const out = {};
|
|
128
|
+
for (const [k, val] of Object.entries(obj)) {
|
|
129
|
+
if (val === undefined || val === null)
|
|
130
|
+
continue;
|
|
131
|
+
const key = prefix ? `${prefix}[${k}]` : k;
|
|
132
|
+
if (typeof val === "object" && !Array.isArray(val)) {
|
|
133
|
+
Object.assign(out, flattenFormFields(val, key));
|
|
134
|
+
}
|
|
135
|
+
else if (Array.isArray(val)) {
|
|
136
|
+
val.forEach((item, i) => {
|
|
137
|
+
out[`${key}[${i}]`] = String(item);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else if (typeof val === "boolean") {
|
|
141
|
+
out[key] = val ? "1" : "0";
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
out[key] = String(val);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=legacy-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-client.js","sourceRoot":"","sources":["../../src/lib/legacy-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,eAAe,CAAC,QAAgB,EAAE,QAAgB;IACzD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChF,OAAO,SAAS,KAAK,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,SAAS,GAAG,IAAI,SAA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I,OAAO,GAAG,KAAK,SAAS,EAAE,CAAC;YACpC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { LegacyCheddarClient } from "../lib/legacy-client.js";
|
|
3
3
|
export declare const customerTools: Tool[];
|
|
4
|
-
export declare function handleCustomerTool(client:
|
|
4
|
+
export declare function handleCustomerTool(client: LegacyCheddarClient, name: string, args: Record<string, unknown> | undefined): Promise<{
|
|
5
5
|
content: Array<{
|
|
6
6
|
type: string;
|
|
7
7
|
text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,eAAO,MAAM,aAAa,EAAE,IAAI,EAkG/B,CAAC;AAQF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACxC,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA6C7D"}
|
package/dist/tools/customers.js
CHANGED
|
@@ -1,59 +1,67 @@
|
|
|
1
1
|
export const customerTools = [
|
|
2
2
|
{
|
|
3
3
|
name: "cheddar_customer_get",
|
|
4
|
-
description: "
|
|
4
|
+
description: "Fetch one customer via the legacy Cheddar API (HTTP Basic). Use customer code or CG customer id.",
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: "object",
|
|
7
7
|
properties: {
|
|
8
|
-
|
|
8
|
+
lookup: {
|
|
9
9
|
type: "string",
|
|
10
|
-
|
|
10
|
+
enum: ["code", "id"],
|
|
11
|
+
description: "Whether `value` is the customer code or internal id",
|
|
12
|
+
},
|
|
13
|
+
value: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "Customer code or id",
|
|
11
16
|
},
|
|
12
17
|
},
|
|
13
|
-
required: ["
|
|
18
|
+
required: ["lookup", "value"],
|
|
14
19
|
},
|
|
15
20
|
},
|
|
16
21
|
{
|
|
17
|
-
name: "
|
|
18
|
-
description: "
|
|
22
|
+
name: "cheddar_customers_search",
|
|
23
|
+
description: "Search customers (legacy API). Supports text search and common filters; see GetCheddar docs for query parameters.",
|
|
19
24
|
inputSchema: {
|
|
20
25
|
type: "object",
|
|
21
26
|
properties: {
|
|
22
|
-
|
|
27
|
+
search: { type: "string", description: "Free-text search" },
|
|
28
|
+
subscriptionStatus: {
|
|
23
29
|
type: "string",
|
|
24
|
-
|
|
30
|
+
enum: ["activeOnly", "canceledOnly"],
|
|
25
31
|
},
|
|
26
|
-
|
|
32
|
+
orderBy: {
|
|
27
33
|
type: "string",
|
|
28
|
-
|
|
34
|
+
enum: ["name", "company", "plan", "billingDatetime", "createdDatetime"],
|
|
29
35
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
type: "string",
|
|
36
|
-
description: "
|
|
36
|
+
orderByDirection: { type: "string", enum: ["asc", "desc"] },
|
|
37
|
+
createdAfterDate: { type: "string", description: "YYYY-MM-DD" },
|
|
38
|
+
createdBeforeDate: { type: "string", description: "YYYY-MM-DD" },
|
|
39
|
+
planCode: {
|
|
40
|
+
type: "array",
|
|
41
|
+
items: { type: "string" },
|
|
42
|
+
description: "Filter by one or more plan codes",
|
|
37
43
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "cheddar_customer_create",
|
|
49
|
+
description: "Create a customer (legacy POST). Pass top-level fields and optional `subscription` per [GetCheddar docs](https://docs.getcheddar.com/). Prefer hosted checkout or `gatewayToken` flows for card data—do not send raw PAN/CVV through this tool.",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
code: { type: "string", description: "Required unique customer code" },
|
|
54
|
+
firstName: { type: "string" },
|
|
55
|
+
lastName: { type: "string" },
|
|
56
|
+
email: { type: "string" },
|
|
57
|
+
company: { type: "string" },
|
|
58
|
+
notes: { type: "string" },
|
|
59
|
+
taxRate: { type: "string" },
|
|
60
|
+
isTaxExempt: { type: "boolean" },
|
|
61
|
+
taxNumber: { type: "string" },
|
|
62
|
+
subscription: {
|
|
63
|
+
type: "object",
|
|
64
|
+
description: "Nested subscription fields allowed by the legacy API (e.g. planCode). Avoid raw card numbers; use processor tokenization or hosted collection.",
|
|
57
65
|
},
|
|
58
66
|
},
|
|
59
67
|
required: ["code"],
|
|
@@ -61,90 +69,82 @@ export const customerTools = [
|
|
|
61
69
|
},
|
|
62
70
|
{
|
|
63
71
|
name: "cheddar_customer_update",
|
|
64
|
-
description: "Update
|
|
72
|
+
description: "Update customer + subscription (legacy POST /customers/edit). Provide customer `code` and fields to change. Prefer token/hosted flows over raw card data.",
|
|
65
73
|
inputSchema: {
|
|
66
74
|
type: "object",
|
|
67
75
|
properties: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
email: {
|
|
81
|
-
type: "string",
|
|
82
|
-
description: "Customer's email address",
|
|
83
|
-
},
|
|
84
|
-
company: {
|
|
85
|
-
type: "string",
|
|
86
|
-
description: "Customer's company name",
|
|
87
|
-
},
|
|
88
|
-
notes: {
|
|
89
|
-
type: "string",
|
|
90
|
-
description: "Internal notes about the customer",
|
|
91
|
-
},
|
|
92
|
-
taxRate: {
|
|
93
|
-
type: "string",
|
|
94
|
-
description: "Tax rate to apply to this customer",
|
|
95
|
-
},
|
|
96
|
-
isTaxExempt: {
|
|
97
|
-
type: "boolean",
|
|
98
|
-
description: "Whether the customer is tax exempt",
|
|
99
|
-
},
|
|
100
|
-
taxNumber: {
|
|
101
|
-
type: "string",
|
|
102
|
-
description: "Tax/VAT number for the customer",
|
|
76
|
+
code: { type: "string", description: "Customer code to edit" },
|
|
77
|
+
firstName: { type: "string" },
|
|
78
|
+
lastName: { type: "string" },
|
|
79
|
+
email: { type: "string" },
|
|
80
|
+
company: { type: "string" },
|
|
81
|
+
notes: { type: "string" },
|
|
82
|
+
taxRate: { type: "string" },
|
|
83
|
+
isTaxExempt: { type: "boolean" },
|
|
84
|
+
taxNumber: { type: "string" },
|
|
85
|
+
subscription: {
|
|
86
|
+
type: "object",
|
|
87
|
+
description: "Subscription fields per legacy API docs; avoid sending full card numbers through the MCP.",
|
|
103
88
|
},
|
|
104
89
|
},
|
|
105
|
-
required: ["
|
|
90
|
+
required: ["code"],
|
|
106
91
|
},
|
|
107
92
|
},
|
|
108
93
|
];
|
|
94
|
+
function jsonResult(data) {
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
109
99
|
export async function handleCustomerTool(client, name, args) {
|
|
100
|
+
const a = args || {};
|
|
110
101
|
switch (name) {
|
|
111
102
|
case "cheddar_customer_get": {
|
|
112
|
-
const {
|
|
113
|
-
const
|
|
114
|
-
return
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
const { lookup, value } = a;
|
|
104
|
+
const data = await client.getCustomer(lookup, value);
|
|
105
|
+
return jsonResult(data);
|
|
106
|
+
}
|
|
107
|
+
case "cheddar_customers_search": {
|
|
108
|
+
const params = {};
|
|
109
|
+
if (a.search)
|
|
110
|
+
params.search = String(a.search);
|
|
111
|
+
if (a.subscriptionStatus)
|
|
112
|
+
params.subscriptionStatus = String(a.subscriptionStatus);
|
|
113
|
+
if (a.orderBy)
|
|
114
|
+
params.orderBy = String(a.orderBy);
|
|
115
|
+
if (a.orderByDirection)
|
|
116
|
+
params.orderByDirection = String(a.orderByDirection);
|
|
117
|
+
if (a.createdAfterDate)
|
|
118
|
+
params.createdAfterDate = String(a.createdAfterDate);
|
|
119
|
+
if (a.createdBeforeDate)
|
|
120
|
+
params.createdBeforeDate = String(a.createdBeforeDate);
|
|
121
|
+
if (Array.isArray(a.planCode)) {
|
|
122
|
+
a.planCode.forEach((c, i) => {
|
|
123
|
+
params[`planCode[${i}]`] = c;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const data = await client.searchCustomers(params);
|
|
127
|
+
return jsonResult(data);
|
|
122
128
|
}
|
|
123
129
|
case "cheddar_customer_create": {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
};
|
|
130
|
+
const { code, subscription, ...rest } = a;
|
|
131
|
+
const fields = { code, ...rest };
|
|
132
|
+
if (subscription)
|
|
133
|
+
fields.subscription = subscription;
|
|
134
|
+
const data = await client.createCustomer(fields);
|
|
135
|
+
return jsonResult(data);
|
|
133
136
|
}
|
|
134
137
|
case "cheddar_customer_update": {
|
|
135
|
-
const {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
};
|
|
138
|
+
const { code, ...updates } = a;
|
|
139
|
+
const { subscription, ...rest } = updates;
|
|
140
|
+
const fields = { ...rest };
|
|
141
|
+
if (subscription)
|
|
142
|
+
fields.subscription = subscription;
|
|
143
|
+
const data = await client.updateCustomer(code, fields);
|
|
144
|
+
return jsonResult(data);
|
|
145
145
|
}
|
|
146
146
|
default:
|
|
147
|
-
throw new Error(`Unknown
|
|
147
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
//# sourceMappingURL=customers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/tools/customers.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,kGAAkG;QACpG,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;oBACpB,WA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