@getcheddar/cheddar-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cheddar (chdr)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # Cheddar MCP Server
2
+
3
+ A Model Context Protocol (MCP) server for integrating with the Cheddar Payment Platform. This server provides AI assistants with tools to manage customers, payment methods, subscriptions, and generate checkout integration code.
4
+
5
+ ## Features
6
+
7
+ - **Customer Management**: Create, read, and update customers
8
+ - **Payment Methods**: Tokenize cards and manage payment methods (PCI-compliant)
9
+ - **Subscriptions**: View subscription details and manage promotions
10
+ - **Checkout Integration**: Generate hosted checkout URLs and embedded form code
11
+ - **Code Generation**: Produce framework-specific integration code (React, Vue, Next.js, Vanilla JS)
12
+ - **Webhook Handling**: Validate and configure webhook endpoints
13
+
14
+ ## Installation
15
+
16
+ ### Option 1: Run with npx (Recommended)
17
+
18
+ ```bash
19
+ npx @chdr/cheddar-mcp
20
+ ```
21
+
22
+ ### Option 2: Install globally
23
+
24
+ ```bash
25
+ npm install -g @chdr/cheddar-mcp
26
+ cheddar-mcp
27
+ ```
28
+
29
+ ### Option 3: Docker
30
+
31
+ ```bash
32
+ docker run -i --rm \
33
+ -e CHEDDAR_API_URL=https://api.cheddar.com \
34
+ -e CHEDDAR_ACCESS_TOKEN=your_token \
35
+ chdr/cheddar-mcp
36
+ ```
37
+
38
+ ## Configuration
39
+
40
+ Set the following environment variables:
41
+
42
+ | Variable | Required | Description |
43
+ | ----------------------- | -------- | ---------------------------------------------------------- |
44
+ | `CHEDDAR_API_URL` | Yes | The Cheddar API base URL (e.g., `https://api.cheddar.com`) |
45
+ | `CHEDDAR_ACCESS_TOKEN` | Yes\* | Your OAuth2 access token |
46
+ | `CHEDDAR_CLIENT_ID` | Yes\* | Your OAuth2 client ID |
47
+ | `CHEDDAR_CLIENT_SECRET` | Yes\* | Your OAuth2 client secret |
48
+
49
+ \*Either `CHEDDAR_ACCESS_TOKEN` OR all OAuth2 credentials are required.
50
+
51
+ ### Getting Credentials
52
+
53
+ 1. Log into your Cheddar dashboard
54
+ 2. Go to Settings > API Keys
55
+ 3. Generate OAuth2 credentials
56
+ 4. Use the Client ID and Client Secret to obtain an access token
57
+
58
+ ## Usage with Claude Desktop
59
+
60
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS or `%APPDATA%/Claude/claude_desktop_config.json` on Windows):
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "cheddar": {
66
+ "command": "npx",
67
+ "args": ["-y", "@chdr/cheddar-mcp"],
68
+ "env": {
69
+ "CHEDDAR_API_URL": "https://api.cheddar.com",
70
+ "CHEDDAR_ACCESS_TOKEN": "your-access-token"
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ ## Usage with Cursor
78
+
79
+ 1. Open Cursor Settings
80
+ 2. Navigate to Features > MCP
81
+ 3. Add a new MCP server with:
82
+ - Name: `cheddar`
83
+ - Command: `npx -y @chdr/cheddar-mcp`
84
+ - Set environment variables in your shell or prepend them
85
+
86
+ ## Available Tools
87
+
88
+ ### Customer Management
89
+
90
+ | Tool | Description |
91
+ | ------------------------- | --------------------------------- |
92
+ | `cheddar_customer_get` | Retrieve a customer by ID or code |
93
+ | `cheddar_customer_create` | Create a new customer |
94
+ | `cheddar_customer_update` | Update customer information |
95
+
96
+ ### Payment Methods
97
+
98
+ | Tool | Description |
99
+ | -------------------------------------------- | ---------------------------------------- |
100
+ | `cheddar_payment_method_get` | Retrieve a payment method by ID |
101
+ | `cheddar_payment_method_get_customer` | Get customer from payment method |
102
+ | `cheddar_payment_method_get_gateway_account` | Get gateway account for payment method |
103
+ | `cheddar_payment_token_create` | Tokenize card data (PCI-compliant) |
104
+ | `cheddar_payment_method_add_to_customer` | Add tokenized payment method to customer |
105
+
106
+ ### Subscriptions & Plans
107
+
108
+ | Tool | Description |
109
+ | ----------------------------------------- | ------------------------------------ |
110
+ | `cheddar_subscription_get` | Retrieve subscription by ID |
111
+ | `cheddar_subscription_get_customer` | Get customer from subscription |
112
+ | `cheddar_subscription_get_plan` | Get plan from subscription |
113
+ | `cheddar_subscription_get_payment_method` | Get payment method from subscription |
114
+ | `cheddar_subscription_delete_promotion` | Remove promotion from subscription |
115
+ | `cheddar_plan_get` | Retrieve plan by ID or code |
116
+ | `cheddar_gateway_account_get` | Get gateway account details |
117
+
118
+ ### Checkout Integration
119
+
120
+ | Tool | Description |
121
+ | -------------------------------------------- | ------------------------------------ |
122
+ | `cheddar_checkout_generate_hosted_url` | Generate hosted checkout page URL |
123
+ | `cheddar_checkout_generate_embedded_form` | Generate embedded checkout form code |
124
+ | `cheddar_checkout_generate_integration_code` | Generate framework-specific code |
125
+ | `cheddar_checkout_validate_webhook` | Validate webhook signature |
126
+ | `cheddar_checkout_configure_webhook` | Generate webhook handler code |
127
+
128
+ ## Example Usage
129
+
130
+ ### Get a Customer
131
+
132
+ ```
133
+ Use the cheddar_customer_get tool with ID "cust_12345"
134
+ ```
135
+
136
+ ### Create a Payment Method Token
137
+
138
+ ```
139
+ Use the cheddar_payment_token_create tool with:
140
+ - cardNumber: "4111111111111111"
141
+ - expirationDate: "12/25"
142
+ - cvv: "123"
143
+ - cardholderName: "John Doe"
144
+ ```
145
+
146
+ ### Generate React Integration
147
+
148
+ ```
149
+ Use the cheddar_checkout_generate_integration_code tool with:
150
+ - framework: "react"
151
+ - integrationType: "embedded"
152
+ - features: ["card", "subscriptions"]
153
+ - styling: "tailwind"
154
+ ```
155
+
156
+ ## Development
157
+
158
+ ```bash
159
+ # Clone the repository
160
+ git clone https://github.com/chdr/cheddar-ai-tools.git
161
+ cd cheddar-ai-tools/packages/cheddar-mcp
162
+
163
+ # Install dependencies
164
+ npm install
165
+
166
+ # Build
167
+ npm run build
168
+
169
+ # Run in development mode
170
+ npm run dev
171
+
172
+ # Test
173
+ npm test
174
+ ```
175
+
176
+ ## License
177
+
178
+ MIT © Cheddar (chdr)
179
+
180
+ ## Support
181
+
182
+ - Documentation: https://docs.cheddar.com
183
+ - Support: support@cheddar.com
184
+ - Issues: https://github.com/chdr/cheddar-ai-tools/issues
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,87 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
+ import { CheddarApiClient } from "./lib/cheddar-client.js";
5
+ import { customerTools, handleCustomerTool } from "./tools/customers.js";
6
+ import { paymentMethodTools, handlePaymentMethodTool } from "./tools/payment-methods.js";
7
+ import { subscriptionTools, handleSubscriptionTool } from "./tools/subscriptions.js";
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;
48
+ try {
49
+ // Route to appropriate handler based on tool name prefix
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}`);
63
+ }
64
+ catch (error) {
65
+ const errorMessage = error instanceof Error ? error.message : String(error);
66
+ return {
67
+ content: [
68
+ {
69
+ type: "text",
70
+ text: `Error: ${errorMessage}`,
71
+ },
72
+ ],
73
+ isError: true,
74
+ };
75
+ }
76
+ });
77
+ // Start server
78
+ async function main() {
79
+ const transport = new StdioServerTransport();
80
+ await server.connect(transport);
81
+ console.error("Cheddar MCP server running on stdio");
82
+ }
83
+ main().catch((error) => {
84
+ console.error("Fatal error:", error);
85
+ process.exit(1);
86
+ });
87
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAExE,iCAAiC;AACjC,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,sBAAsB;IAC7D,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;IAC7C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,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,CAAC,CAAC,CAAC"}
@@ -0,0 +1,111 @@
1
+ export interface CheddarConfig {
2
+ apiUrl: string;
3
+ clientId?: string;
4
+ clientSecret?: string;
5
+ accessToken?: string;
6
+ }
7
+ export interface Customer {
8
+ id: string;
9
+ code: string;
10
+ firstName?: string;
11
+ lastName?: string;
12
+ email?: string;
13
+ company?: string;
14
+ notes?: string;
15
+ taxRate?: string;
16
+ isTaxExempt?: boolean;
17
+ taxNumber?: string;
18
+ createdDatetime: string;
19
+ }
20
+ export interface PaymentMethod {
21
+ id: string;
22
+ type: "CreditCard" | "PayPalPreapproval" | "PayPalBillingAgreement" | "External";
23
+ gatewayAccountId: string;
24
+ isPrimary: boolean;
25
+ isActive: boolean;
26
+ createdDatetime: string;
27
+ card?: {
28
+ lastFour: string;
29
+ cardType?: string;
30
+ expirationDate?: string;
31
+ };
32
+ paypal?: {
33
+ email?: string;
34
+ };
35
+ }
36
+ export interface PaymentMethodToken {
37
+ token: string;
38
+ expiresAt: string;
39
+ }
40
+ export interface Subscription {
41
+ id: string;
42
+ customerId: string;
43
+ planId: string;
44
+ paymentMethodId?: string;
45
+ status: "active" | "canceled" | "expired" | "pending";
46
+ startDate?: string;
47
+ endDate?: string;
48
+ nextBillDate?: string;
49
+ createdDatetime: string;
50
+ }
51
+ export interface Plan {
52
+ id: string;
53
+ code: string;
54
+ name?: string;
55
+ description?: string;
56
+ isActive: boolean;
57
+ setupChargeAmount?: string;
58
+ recurringChargeAmount?: string;
59
+ trialDays?: number;
60
+ billingFrequency?: string;
61
+ billingFrequencyQuantity?: number;
62
+ billingFrequencyUnit?: string;
63
+ createdDatetime: string;
64
+ }
65
+ export interface Product {
66
+ id: string;
67
+ code: string;
68
+ name?: string;
69
+ country?: string;
70
+ currency?: string;
71
+ createdDatetime: string;
72
+ }
73
+ export interface GatewayAccount {
74
+ id: string;
75
+ gateway: string;
76
+ isActive: boolean;
77
+ isPrimary: boolean;
78
+ createdDatetime: string;
79
+ }
80
+ export declare class CheddarApiClient {
81
+ private config;
82
+ private baseUrl;
83
+ constructor(config: CheddarConfig);
84
+ private getAuthHeaders;
85
+ private request;
86
+ getCustomer(id: string): Promise<Customer>;
87
+ createCustomer(customerData: Partial<Customer>): Promise<Customer>;
88
+ updateCustomer(id: string, updates: Partial<Customer>): Promise<Customer>;
89
+ getPaymentMethod(id: string): Promise<PaymentMethod>;
90
+ getPaymentMethodCustomer(id: string): Promise<Customer>;
91
+ getPaymentMethodGatewayAccount(id: string): Promise<GatewayAccount>;
92
+ createPaymentMethodToken(paymentData: {
93
+ cardNumber: string;
94
+ expirationDate: string;
95
+ cvv: string;
96
+ cardholderName?: string;
97
+ }): Promise<PaymentMethodToken>;
98
+ addPaymentMethodToCustomer(customerId: string, token: string): Promise<PaymentMethod>;
99
+ getSubscription(id: string): Promise<Subscription>;
100
+ getSubscriptionCustomer(id: string): Promise<Customer>;
101
+ getSubscriptionPlan(id: string): Promise<Plan>;
102
+ getSubscriptionPaymentMethod(id: string): Promise<PaymentMethod>;
103
+ deleteSubscriptionPromotion(customerId: string): Promise<void>;
104
+ getProduct(): Promise<Product>;
105
+ getPlan(id: string): Promise<Plan>;
106
+ getGatewayAccount(id: string): Promise<GatewayAccount>;
107
+ ping(): Promise<{
108
+ ack: number;
109
+ }>;
110
+ }
111
+ //# sourceMappingURL=cheddar-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cheddar-client.d.ts","sourceRoot":"","sources":["../../src/lib/cheddar-client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CA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AAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpD,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIvD,8BAA8B,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAInE,wBAAwB,CAAC,WAAW,EAAE;QAC1C,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAWzB,0BAA0B,CAC9B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,aAAa,CAAC;IAUnB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIlD,uBAAuB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAItD,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,4BAA4B,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIhE,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9D,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAM9B,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlC,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMtD,IAAI,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAGvC"}
@@ -0,0 +1,101 @@
1
+ // Cheddar API Client - wraps the REST API for the MCP server
2
+ export class CheddarApiClient {
3
+ config;
4
+ baseUrl;
5
+ constructor(config) {
6
+ this.config = config;
7
+ this.baseUrl = config.apiUrl.replace(/\/$/, "");
8
+ }
9
+ async getAuthHeaders() {
10
+ // If access token is provided directly, use it
11
+ if (this.config.accessToken) {
12
+ return {
13
+ Authorization: `Bearer ${this.config.accessToken}`,
14
+ "Content-Type": "application/json",
15
+ };
16
+ }
17
+ // Otherwise, implement OAuth2 token fetch
18
+ // Note: In production, you'd want to cache and refresh tokens
19
+ throw new Error("OAuth2 token refresh not yet implemented. Please provide CHEDDAR_ACCESS_TOKEN.");
20
+ }
21
+ async request(method, path, body) {
22
+ const headers = await this.getAuthHeaders();
23
+ const url = `${this.baseUrl}${path}`;
24
+ const response = await fetch(url, {
25
+ method,
26
+ headers,
27
+ body: body ? JSON.stringify(body) : undefined,
28
+ });
29
+ if (!response.ok) {
30
+ const errorText = await response.text();
31
+ throw new Error(`Cheddar API error (${response.status}): ${errorText}`);
32
+ }
33
+ return response.json();
34
+ }
35
+ // ==================== Customer Operations ====================
36
+ async getCustomer(id) {
37
+ return this.request("GET", `/customer/${encodeURIComponent(id)}`);
38
+ }
39
+ async createCustomer(customerData) {
40
+ return this.request("POST", "/customer", customerData);
41
+ }
42
+ async updateCustomer(id, updates) {
43
+ return this.request("PATCH", `/customer/${encodeURIComponent(id)}`, updates);
44
+ }
45
+ // ==================== Payment Method Operations ====================
46
+ async getPaymentMethod(id) {
47
+ return this.request("GET", `/payment-method/${encodeURIComponent(id)}`);
48
+ }
49
+ async getPaymentMethodCustomer(id) {
50
+ return this.request("GET", `/payment-method/${encodeURIComponent(id)}/customer`);
51
+ }
52
+ async getPaymentMethodGatewayAccount(id) {
53
+ return this.request("GET", `/payment-method/${encodeURIComponent(id)}/gateway-account`);
54
+ }
55
+ async createPaymentMethodToken(paymentData) {
56
+ return this.request("POST", "/payment-method-token", {
57
+ creditCard: {
58
+ cardNumber: paymentData.cardNumber,
59
+ expirationDate: paymentData.expirationDate,
60
+ cvv: paymentData.cvv,
61
+ cardholderName: paymentData.cardholderName,
62
+ },
63
+ });
64
+ }
65
+ async addPaymentMethodToCustomer(customerId, token) {
66
+ return this.request("POST", `/customer/${encodeURIComponent(customerId)}/payment-method`, { token });
67
+ }
68
+ // ==================== Subscription Operations ====================
69
+ async getSubscription(id) {
70
+ return this.request("GET", `/subscription/${encodeURIComponent(id)}`);
71
+ }
72
+ async getSubscriptionCustomer(id) {
73
+ return this.request("GET", `/subscription/${encodeURIComponent(id)}/customer`);
74
+ }
75
+ async getSubscriptionPlan(id) {
76
+ return this.request("GET", `/subscription/${encodeURIComponent(id)}/plan`);
77
+ }
78
+ async getSubscriptionPaymentMethod(id) {
79
+ return this.request("GET", `/subscription/${encodeURIComponent(id)}/payment-method`);
80
+ }
81
+ async deleteSubscriptionPromotion(customerId) {
82
+ await this.request("DELETE", `/customer/${encodeURIComponent(customerId)}/subscription/promotion`);
83
+ }
84
+ // ==================== Product Operations ====================
85
+ async getProduct() {
86
+ return this.request("GET", "/product");
87
+ }
88
+ // ==================== Plan Operations ====================
89
+ async getPlan(id) {
90
+ return this.request("GET", `/plan/${encodeURIComponent(id)}`);
91
+ }
92
+ // ==================== Gateway Account Operations ====================
93
+ async getGatewayAccount(id) {
94
+ return this.request("GET", `/gateway-account/${encodeURIComponent(id)}`);
95
+ }
96
+ // ==================== Health Check ====================
97
+ async ping() {
98
+ return this.request("GET", "/ping");
99
+ }
100
+ }
101
+ //# sourceMappingURL=cheddar-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cheddar-client.js","sourceRoot":"","sources":["../../src/lib/cheddar-client.ts"],"names":[],"mappings":"AAAA,6DAA6D;AA0F7D,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAgB;IACtB,OAAO,CAAS;IAExB,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,+CAA+C;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"}
@@ -0,0 +1,10 @@
1
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import { CheddarApiClient } from "../lib/cheddar-client.js";
3
+ export declare const checkoutTools: Tool[];
4
+ export declare function handleCheckoutTool(client: CheddarApiClient, name: string, args: Record<string, unknown> | undefined): Promise<{
5
+ content: Array<{
6
+ type: string;
7
+ text: string;
8
+ }>;
9
+ }>;
10
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/tools/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,IAAI,EA0I/B,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,gBAAgB,EACxB,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,CAsK7D"}