@getcheddar/cheddar-mcp 1.0.5 → 2.0.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/README.md +49 -337
- package/bin/cheddar-mcp.mjs +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -52
- 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 +8 -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/README.md
CHANGED
|
@@ -1,379 +1,91 @@
|
|
|
1
|
-
# Cheddar MCP Server
|
|
1
|
+
# Cheddar MCP Server (legacy API)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Model Context Protocol server that calls the **legacy Cheddar merchant API** documented at [https://docs.getcheddar.com/](https://docs.getcheddar.com/) using **HTTP Basic** authentication (`Authorization: Basic …`).
|
|
4
4
|
|
|
5
|
-
**
|
|
6
|
-
**Version:** 1.0.5
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Two Modes of Operation
|
|
11
|
-
|
|
12
|
-
The MCP server works in two modes depending on whether you provide API credentials:
|
|
13
|
-
|
|
14
|
-
### Mode A: Code Generation Only (No Auth Required)
|
|
15
|
-
|
|
16
|
-
**Use this mode to:**
|
|
17
|
-
|
|
18
|
-
- Generate integration code (React, Vue, Next.js, etc.)
|
|
19
|
-
- Create checkout forms and hosted page URLs
|
|
20
|
-
- Configure webhooks and validation logic
|
|
21
|
-
- Get code recommendations and best practices
|
|
22
|
-
|
|
23
|
-
**No API credentials needed!** These tools work out of the box:
|
|
24
|
-
|
|
25
|
-
| Tool | Description |
|
|
26
|
-
| -------------------------------------------- | ------------------------------------------------ |
|
|
27
|
-
| `cheddar_checkout_generate_hosted_url` | Generate hosted checkout page URLs |
|
|
28
|
-
| `cheddar_checkout_generate_embedded_form` | Generate embedded checkout form code |
|
|
29
|
-
| `cheddar_checkout_generate_integration_code` | Generate complete framework-specific integration |
|
|
30
|
-
| `cheddar_checkout_configure_webhook` | Generate webhook handler code |
|
|
31
|
-
| `cheddar_checkout_validate_webhook` | Validate webhook signatures |
|
|
32
|
-
|
|
33
|
-
**Quick Start (No Auth):**
|
|
34
|
-
|
|
35
|
-
```json
|
|
36
|
-
{
|
|
37
|
-
"mcpServers": {
|
|
38
|
-
"cheddar": {
|
|
39
|
-
"command": "npx",
|
|
40
|
-
"args": ["-y", "@getcheddar/cheddar-mcp@1.0.5"]
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
```
|
|
5
|
+
This package **does not** use `https://api.*` OAuth2 / Bearer REST.
|
|
45
6
|
|
|
46
|
-
**
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
Create a React checkout page for my SaaS using Cheddar payments.
|
|
50
|
-
- Collect customer email and name
|
|
51
|
-
- Accept credit card payments securely
|
|
52
|
-
- Subscribe customers to a "Pro Plan"
|
|
53
|
-
- Handle errors gracefully
|
|
54
|
-
|
|
55
|
-
Use cheddar_checkout_generate_integration_code with framework "react".
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
### Mode B: Full API Access (Auth Required)
|
|
61
|
-
|
|
62
|
-
**Use this mode to:**
|
|
63
|
-
|
|
64
|
-
- Query actual customer data from your Cheddar account
|
|
65
|
-
- Create and update customers, subscriptions, payment methods
|
|
66
|
-
- Manage billing and plan changes
|
|
67
|
-
- Access real-time subscription status
|
|
68
|
-
|
|
69
|
-
**Requires Cheddar API credentials.** These tools need authentication:
|
|
70
|
-
|
|
71
|
-
| Tool | Description |
|
|
72
|
-
| ------------------------------ | ---------------------------------- |
|
|
73
|
-
| `cheddar_customer_get` | Retrieve customer by ID or code |
|
|
74
|
-
| `cheddar_customer_create` | Create a new customer |
|
|
75
|
-
| `cheddar_customer_update` | Update customer information |
|
|
76
|
-
| `cheddar_payment_method_get` | Retrieve payment method by ID |
|
|
77
|
-
| `cheddar_payment_token_create` | Tokenize card data (PCI-compliant) |
|
|
78
|
-
| `cheddar_subscription_get` | Retrieve subscription details |
|
|
79
|
-
| `cheddar_plan_get` | Retrieve plan information |
|
|
80
|
-
|
|
81
|
-
**Setup with Auth:**
|
|
82
|
-
|
|
83
|
-
1. **Sign up for Cheddar:** https://getcheddar.com/signup
|
|
84
|
-
2. **Get your credentials:**
|
|
85
|
-
- **Username:** Your Cheddar account email
|
|
86
|
-
- **Secret Key:** Top navbar → Configuration → Product Settings → Secret Key
|
|
87
|
-
|
|
88
|
-
3. **Configure MCP:**
|
|
89
|
-
|
|
90
|
-
```json
|
|
91
|
-
{
|
|
92
|
-
"mcpServers": {
|
|
93
|
-
"cheddar": {
|
|
94
|
-
"command": "npx",
|
|
95
|
-
"args": ["-y", "@getcheddar/cheddar-mcp@1.0.5"],
|
|
96
|
-
"env": {
|
|
97
|
-
"CHEDDAR_API_URL": "https://api.getcheddar.com",
|
|
98
|
-
"CHEDDAR_USERNAME": "your-email@example.com",
|
|
99
|
-
"CHEDDAR_SECRET_KEY": "your-secret-key-here"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
```
|
|
7
|
+
**Package:** `@getcheddar/cheddar-mcp`
|
|
8
|
+
**Version:** 2.0.0
|
|
105
9
|
|
|
106
|
-
|
|
10
|
+
## Requirements
|
|
107
11
|
|
|
108
|
-
|
|
12
|
+
- Node.js **18+**
|
|
13
|
+
- A Cheddar **product site** base URL (same host you use for admin/checkout, e.g. `https://yoursubdomain.chargevault.com`)
|
|
14
|
+
- **Product code** (`productCode` in URLs)
|
|
15
|
+
- An **authorized user email** and **password** *or* the product **API key** (“secret key” from Configuration → Settings) as the Basic password ([auth docs](https://docs.getcheddar.com/#authentication))
|
|
109
16
|
|
|
110
|
-
|
|
111
|
-
{
|
|
112
|
-
"mcpServers": {
|
|
113
|
-
"cheddar": {
|
|
114
|
-
"command": "npx",
|
|
115
|
-
"args": ["-y", "@getcheddar/cheddar-mcp@1.0.5"],
|
|
116
|
-
"env": {
|
|
117
|
-
"CHEDDAR_API_URL": "https://api.getcheddar.com",
|
|
118
|
-
"CHEDDAR_ACCESS_TOKEN": "your-oauth2-access-token"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
```
|
|
17
|
+
## Environment variables
|
|
124
18
|
|
|
125
|
-
|
|
19
|
+
| Variable | Required | Description |
|
|
20
|
+
|----------|----------|-------------|
|
|
21
|
+
| `CHEDDAR_BASE_URL` | **Yes** | Origin of your product app, no trailing slash (e.g. `https://cvences.chargevault.com`). |
|
|
22
|
+
| `CHEDDAR_PRODUCT_CODE` | **Yes** | Your product’s `productCode` segment in legacy URLs. |
|
|
23
|
+
| `CHEDDAR_USERNAME` | **Yes** | Email of an API-enabled user on that product. |
|
|
24
|
+
| `CHEDDAR_PASSWORD` | One of | That user’s login password. |
|
|
25
|
+
| `CHEDDAR_PRODUCT_API_KEY` | One of | Product secret key from admin settings; used as Basic **password** if `CHEDDAR_PASSWORD` is unset. |
|
|
26
|
+
| `CHEDDAR_SKIP_PREFLIGHT` | No | If set to `1`, skip startup `GET /xml/plans/get/...` check. |
|
|
126
27
|
|
|
127
|
-
|
|
128
|
-
Get customer details for customer code "cust_12345" and show me their subscription status and payment methods.
|
|
28
|
+
## Install & run
|
|
129
29
|
|
|
130
|
-
|
|
30
|
+
```bash
|
|
31
|
+
cd packages/cheddar-mcp
|
|
32
|
+
npm install
|
|
33
|
+
npm run build
|
|
131
34
|
```
|
|
132
35
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
| ---------------------- | --------- | -------------------------------------------------------- |
|
|
139
|
-
| `CHEDDAR_API_URL` | Auth only | REST API base URL. Default: `https://api.getcheddar.com` |
|
|
140
|
-
| `CHEDDAR_USERNAME` | Auth only | Your Cheddar account email address |
|
|
141
|
-
| `CHEDDAR_SECRET_KEY` | Auth only | Secret Key from Product Settings |
|
|
142
|
-
| `CHEDDAR_ACCESS_TOKEN` | Auth only | OAuth2 Bearer token (alternative to username/secret) |
|
|
143
|
-
|
|
144
|
-
**Note:** If no auth credentials are provided, the server runs in **code generation mode only** and will return clear error messages if you try to use data access tools.
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
## Usage with Claude Desktop
|
|
149
|
-
|
|
150
|
-
Add to your Claude Desktop configuration:
|
|
151
|
-
|
|
152
|
-
**For code generation (no auth):**
|
|
36
|
+
```bash
|
|
37
|
+
export CHEDDAR_BASE_URL=https://your-product-host.example
|
|
38
|
+
export CHEDDAR_PRODUCT_CODE=YOUR_PRODUCT_CODE
|
|
39
|
+
export CHEDDAR_USERNAME=api-user@example.com
|
|
40
|
+
export CHEDDAR_PRODUCT_API_KEY=your_secret_key
|
|
153
41
|
|
|
154
|
-
|
|
155
|
-
{
|
|
156
|
-
"mcpServers": {
|
|
157
|
-
"cheddar": {
|
|
158
|
-
"command": "npx",
|
|
159
|
-
"args": ["-y", "@getcheddar/cheddar-mcp@1.0.5"]
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
42
|
+
node dist/index.js
|
|
163
43
|
```
|
|
164
44
|
|
|
165
|
-
|
|
45
|
+
Or with `npx` after publish:
|
|
166
46
|
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
"mcpServers": {
|
|
170
|
-
"cheddar": {
|
|
171
|
-
"command": "npx",
|
|
172
|
-
"args": ["-y", "@getcheddar/cheddar-mcp@1.0.5"],
|
|
173
|
-
"env": {
|
|
174
|
-
"CHEDDAR_API_URL": "https://api.getcheddar.com",
|
|
175
|
-
"CHEDDAR_USERNAME": "your-email@example.com",
|
|
176
|
-
"CHEDDAR_SECRET_KEY": "your-secret-key"
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
47
|
+
```bash
|
|
48
|
+
npx -y @getcheddar/cheddar-mcp
|
|
181
49
|
```
|
|
182
50
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
## Usage with Cursor
|
|
186
|
-
|
|
187
|
-
1. Open Cursor Settings
|
|
188
|
-
2. Navigate to **Features → MCP**
|
|
189
|
-
3. Add a new MCP server:
|
|
190
|
-
|
|
191
|
-
**For code generation:**
|
|
192
|
-
|
|
193
|
-
- **Name:** `cheddar`
|
|
194
|
-
- **Command:** `npx`
|
|
195
|
-
- **Arguments:** `-y`, `@getcheddar/cheddar-mcp@1.0.5`
|
|
196
|
-
|
|
197
|
-
**For full API access:**
|
|
198
|
-
|
|
199
|
-
- **Name:** `cheddar`
|
|
200
|
-
- **Command:** `npx`
|
|
201
|
-
- **Arguments:** `-y`, `@getcheddar/cheddar-mcp@1.0.5`
|
|
202
|
-
- **Environment:** Set `CHEDDAR_USERNAME` and `CHEDDAR_SECRET_KEY`
|
|
203
|
-
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
## Usage with Lovable.dev
|
|
207
|
-
|
|
208
|
-
### Step 1: Get Credentials (for full API access, optional)
|
|
209
|
-
|
|
210
|
-
1. Sign up at https://getcheddar.com/signup
|
|
211
|
-
2. Configure your product
|
|
212
|
-
3. Get your Secret Key: Top navbar → Configuration → Product Settings → Secret Key
|
|
51
|
+
## Tools
|
|
213
52
|
|
|
214
|
-
|
|
53
|
+
| Tool | Legacy endpoint (conceptually) |
|
|
54
|
+
|------|--------------------------------|
|
|
55
|
+
| `cheddar_customer_get` | `GET /xml/customers/get/productCode/.../code/…` or `/id/…` |
|
|
56
|
+
| `cheddar_customers_search` | `GET /xml/customers/search/productCode/...` (requests `format=json` when supported) |
|
|
57
|
+
| `cheddar_customer_create` | `POST /xml/customers/new/productCode/...` (form body) |
|
|
58
|
+
| `cheddar_customer_update` | `POST /xml/customers/edit/productCode/.../code/...` |
|
|
59
|
+
| `cheddar_plans_get` | `GET /xml/plans/get/productCode/...` (optional `planCode`) |
|
|
215
60
|
|
|
216
|
-
|
|
61
|
+
Responses are returned as **JSON text**: XML from the API is parsed to a plain object where possible.
|
|
217
62
|
|
|
218
|
-
|
|
63
|
+
## Claude Desktop example
|
|
219
64
|
|
|
220
65
|
```json
|
|
221
66
|
{
|
|
222
67
|
"mcpServers": {
|
|
223
68
|
"cheddar": {
|
|
224
|
-
"command": "
|
|
225
|
-
"args": ["
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
**Option 2: Full API Access**
|
|
232
|
-
|
|
233
|
-
```json
|
|
234
|
-
{
|
|
235
|
-
"mcpServers": {
|
|
236
|
-
"cheddar": {
|
|
237
|
-
"command": "npx",
|
|
238
|
-
"args": ["-y", "@getcheddar/cheddar-mcp@1.0.5"],
|
|
69
|
+
"command": "node",
|
|
70
|
+
"args": ["/absolute/path/to/cheddar-mcp/dist/index.js"],
|
|
239
71
|
"env": {
|
|
240
|
-
"
|
|
241
|
-
"
|
|
242
|
-
"
|
|
72
|
+
"CHEDDAR_BASE_URL": "https://your-product-host.example",
|
|
73
|
+
"CHEDDAR_PRODUCT_CODE": "YOUR_PRODUCT_CODE",
|
|
74
|
+
"CHEDDAR_USERNAME": "api-user@example.com",
|
|
75
|
+
"CHEDDAR_PRODUCT_API_KEY": "your_secret_key"
|
|
243
76
|
}
|
|
244
77
|
}
|
|
245
78
|
}
|
|
246
79
|
}
|
|
247
80
|
```
|
|
248
81
|
|
|
249
|
-
### Step 3: Try These Prompts
|
|
250
|
-
|
|
251
|
-
**For code generation (no auth needed):**
|
|
252
|
-
|
|
253
|
-
```
|
|
254
|
-
Create a complete payment integration for my React app:
|
|
255
|
-
1. A pricing page with 3 tiers (Basic, Pro, Enterprise)
|
|
256
|
-
2. Checkout flow using Cheddar's embedded form
|
|
257
|
-
3. Webhook handler for subscription events
|
|
258
|
-
4. Use Tailwind CSS for styling
|
|
259
|
-
|
|
260
|
-
Start with cheddar_checkout_generate_integration_code.
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
**For data access (requires auth):**
|
|
264
|
-
|
|
265
|
-
```
|
|
266
|
-
Build a customer dashboard showing:
|
|
267
|
-
- Customer profile from Cheddar
|
|
268
|
-
- Current subscription plan
|
|
269
|
-
- Payment methods on file
|
|
270
|
-
- Recent invoices
|
|
271
|
-
|
|
272
|
-
Use cheddar_customer_get and related tools.
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
## Testing
|
|
278
|
-
|
|
279
|
-
### Sandbox Environment
|
|
280
|
-
|
|
281
|
-
Use the sandbox for testing before going live:
|
|
282
|
-
|
|
283
|
-
```json
|
|
284
|
-
{
|
|
285
|
-
"env": {
|
|
286
|
-
"CHEDDAR_API_URL": "https://sandbox.getcheddar.com",
|
|
287
|
-
"CHEDDAR_USERNAME": "your-sandbox-email",
|
|
288
|
-
"CHEDDAR_SECRET_KEY": "your-sandbox-secret"
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### Test Card Numbers
|
|
294
|
-
|
|
295
|
-
- `4111111111111111` - Visa (success)
|
|
296
|
-
- `4000000000000002` - Declined
|
|
297
|
-
|
|
298
|
-
---
|
|
299
|
-
|
|
300
|
-
## Complete Tool Reference
|
|
301
|
-
|
|
302
|
-
### Code Generation Tools (No Auth Required)
|
|
303
|
-
|
|
304
|
-
| Tool | Description |
|
|
305
|
-
| -------------------------------------------- | -------------------------------------------- |
|
|
306
|
-
| `cheddar_checkout_generate_hosted_url` | Generate hosted checkout page URLs |
|
|
307
|
-
| `cheddar_checkout_generate_embedded_form` | Generate embedded checkout form code |
|
|
308
|
-
| `cheddar_checkout_generate_integration_code` | Generate framework-specific integration code |
|
|
309
|
-
| `cheddar_checkout_configure_webhook` | Generate webhook handler code |
|
|
310
|
-
| `cheddar_checkout_validate_webhook` | Validate webhook signatures |
|
|
311
|
-
|
|
312
|
-
### Data Access Tools (Auth Required)
|
|
313
|
-
|
|
314
|
-
| Tool | Description |
|
|
315
|
-
| -------------------------------------------- | ---------------------------------------- |
|
|
316
|
-
| `cheddar_customer_get` | Retrieve a customer by ID or code |
|
|
317
|
-
| `cheddar_customer_create` | Create a new customer |
|
|
318
|
-
| `cheddar_customer_update` | Update customer information |
|
|
319
|
-
| `cheddar_payment_method_get` | Retrieve a payment method by ID |
|
|
320
|
-
| `cheddar_payment_method_get_customer` | Get customer from payment method |
|
|
321
|
-
| `cheddar_payment_method_get_gateway_account` | Get gateway account for payment method |
|
|
322
|
-
| `cheddar_payment_token_create` | Tokenize card data (PCI-compliant) |
|
|
323
|
-
| `cheddar_payment_method_add_to_customer` | Add tokenized payment method to customer |
|
|
324
|
-
| `cheddar_subscription_get` | Retrieve subscription by ID |
|
|
325
|
-
| `cheddar_subscription_get_customer` | Get customer from subscription |
|
|
326
|
-
| `cheddar_subscription_get_plan` | Get plan from subscription |
|
|
327
|
-
| `cheddar_subscription_get_payment_method` | Get payment method from subscription |
|
|
328
|
-
| `cheddar_subscription_delete_promotion` | Remove promotion from subscription |
|
|
329
|
-
| `cheddar_plan_get` | Retrieve plan by ID or code |
|
|
330
|
-
| `cheddar_gateway_account_get` | Get gateway account details |
|
|
331
|
-
|
|
332
|
-
---
|
|
333
|
-
|
|
334
|
-
## Docker Usage
|
|
335
|
-
|
|
336
|
-
Build and run with Docker:
|
|
337
|
-
|
|
338
|
-
```bash
|
|
339
|
-
# Build
|
|
340
|
-
docker build -t cheddar-mcp ./packages/cheddar-mcp
|
|
341
|
-
|
|
342
|
-
# Run (code generation only)
|
|
343
|
-
docker run -i --rm cheddar-mcp
|
|
344
|
-
|
|
345
|
-
# Run with auth
|
|
346
|
-
docker run -i --rm \
|
|
347
|
-
-e CHEDDAR_API_URL=https://api.getcheddar.com \
|
|
348
|
-
-e CHEDDAR_USERNAME=your-email \
|
|
349
|
-
-e CHEDDAR_SECRET_KEY=your-secret \
|
|
350
|
-
cheddar-mcp
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
82
|
## Development
|
|
356
83
|
|
|
357
84
|
```bash
|
|
358
|
-
# Clone the repository
|
|
359
|
-
git clone https://github.com/chdr/cheddar-ai-tools.git
|
|
360
|
-
cd cheddar-ai-tools/packages/cheddar-mcp
|
|
361
|
-
|
|
362
|
-
# Install dependencies
|
|
363
|
-
npm install
|
|
364
|
-
|
|
365
|
-
# Build
|
|
366
85
|
npm run build
|
|
367
|
-
|
|
368
|
-
# Run in development mode
|
|
369
|
-
npm run dev
|
|
370
|
-
|
|
371
|
-
# Test
|
|
372
86
|
npm test
|
|
373
87
|
```
|
|
374
88
|
|
|
375
|
-
---
|
|
376
|
-
|
|
377
89
|
## License
|
|
378
90
|
|
|
379
91
|
MIT © Cheddar (chdr)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import "dotenv/config";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,84 +1,86 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
1
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import {
|
|
5
|
+
import { LegacyApiError, LegacyCheddarClient } from "./lib/legacy-client.js";
|
|
5
6
|
import { customerTools, handleCustomerTool } from "./tools/customers.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
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");
|
|
7
|
+
import { planTools, handlePlanTool } from "./tools/plans.js";
|
|
8
|
+
const baseUrl = (process.env.CHEDDAR_BASE_URL || "").replace(/\/+$/, "");
|
|
9
|
+
const productCode = process.env.CHEDDAR_PRODUCT_CODE || "";
|
|
10
|
+
const username = process.env.CHEDDAR_USERNAME || "";
|
|
11
|
+
const password = process.env.CHEDDAR_PASSWORD || process.env.CHEDDAR_PRODUCT_API_KEY || "";
|
|
12
|
+
if (!baseUrl || !productCode || !username || !password) {
|
|
13
|
+
console.error("Missing config. Set CHEDDAR_BASE_URL, CHEDDAR_PRODUCT_CODE, CHEDDAR_USERNAME, and CHEDDAR_PASSWORD or CHEDDAR_PRODUCT_API_KEY.");
|
|
19
14
|
process.exit(1);
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
...checkoutTools,
|
|
29
|
-
];
|
|
30
|
-
// Create MCP server
|
|
16
|
+
const client = new LegacyCheddarClient({
|
|
17
|
+
baseUrl,
|
|
18
|
+
productCode,
|
|
19
|
+
username,
|
|
20
|
+
password,
|
|
21
|
+
});
|
|
22
|
+
const ALL_TOOLS = [...customerTools, ...planTools];
|
|
31
23
|
const server = new Server({
|
|
32
24
|
name: "cheddar-mcp",
|
|
33
|
-
version: "0.
|
|
25
|
+
version: "2.0.0",
|
|
34
26
|
}, {
|
|
35
27
|
capabilities: {
|
|
36
28
|
tools: {},
|
|
37
29
|
},
|
|
38
30
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ALL_TOOLS }));
|
|
32
|
+
function toolErrorMessage(error) {
|
|
33
|
+
if (error instanceof LegacyApiError) {
|
|
34
|
+
return `Cheddar API error (HTTP ${error.status}). See server logs for details.`;
|
|
35
|
+
}
|
|
36
|
+
if (error instanceof Error) {
|
|
37
|
+
return error.message;
|
|
38
|
+
}
|
|
39
|
+
return String(error);
|
|
40
|
+
}
|
|
46
41
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
47
42
|
const { name, arguments: args } = request.params;
|
|
48
43
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return await handleCustomerTool(cheddarClient, name, args);
|
|
52
|
-
}
|
|
53
|
-
if (name.startsWith("cheddar_payment_")) {
|
|
54
|
-
return await handlePaymentMethodTool(cheddarClient, name, args);
|
|
44
|
+
if (name.startsWith("cheddar_customer")) {
|
|
45
|
+
return await handleCustomerTool(client, name, args);
|
|
55
46
|
}
|
|
56
|
-
if (name.startsWith("
|
|
57
|
-
return await
|
|
58
|
-
}
|
|
59
|
-
if (name.startsWith("cheddar_checkout_")) {
|
|
60
|
-
return await handleCheckoutTool(cheddarClient, name, args);
|
|
47
|
+
if (name.startsWith("cheddar_plans_")) {
|
|
48
|
+
return await handlePlanTool(client, name, args);
|
|
61
49
|
}
|
|
62
50
|
throw new Error(`Unknown tool: ${name}`);
|
|
63
51
|
}
|
|
64
52
|
catch (error) {
|
|
65
|
-
|
|
53
|
+
if (error instanceof LegacyApiError) {
|
|
54
|
+
console.error("[cheddar-mcp] LegacyApiError body:", typeof error.body === "string" ? error.body.slice(0, 4000) : JSON.stringify(error.body).slice(0, 4000));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
console.error("[cheddar-mcp] Tool error:", error);
|
|
58
|
+
}
|
|
66
59
|
return {
|
|
67
|
-
content: [
|
|
68
|
-
{
|
|
69
|
-
type: "text",
|
|
70
|
-
text: `Error: ${errorMessage}`,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
60
|
+
content: [{ type: "text", text: `Error: ${toolErrorMessage(error)}` }],
|
|
73
61
|
isError: true,
|
|
74
62
|
};
|
|
75
63
|
}
|
|
76
64
|
});
|
|
77
|
-
// Start server
|
|
78
65
|
async function main() {
|
|
66
|
+
if (!process.env.CHEDDAR_SKIP_PREFLIGHT) {
|
|
67
|
+
try {
|
|
68
|
+
await client.ping();
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
72
|
+
console.error(`Cheddar legacy API preflight failed: ${msg}`);
|
|
73
|
+
if (err instanceof LegacyApiError) {
|
|
74
|
+
console.error("[cheddar-mcp] Preflight response body:", typeof err.body === "string"
|
|
75
|
+
? err.body.slice(0, 4000)
|
|
76
|
+
: JSON.stringify(err.body).slice(0, 4000));
|
|
77
|
+
}
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
79
81
|
const transport = new StdioServerTransport();
|
|
80
82
|
await server.connect(transport);
|
|
81
|
-
console.error("Cheddar MCP
|
|
83
|
+
console.error("Cheddar MCP (legacy HTTP Basic) running on stdio");
|
|
82
84
|
}
|
|
83
85
|
main().catch((error) => {
|
|
84
86
|
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,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,g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
+
/** 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 @@
|
|
|
1
|
+
{"version":3,"file":"legacy-client.d.ts","sourceRoot":"","sources":["../../src/lib/legacy-client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAgBD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAElB,GAAG,EAAE,mBAAmB;YAMtB,SAAS;IAiBvB;;OAEG;IACG,GAAG,CAAC,oBAAoB,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBzF;;OAEG;IACG,QAAQ,CAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBxF,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/D,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAOjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASnD;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