@theyahia/paymongo-mcp 1.0.1 → 1.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 +21 -21
- package/README.md +157 -50
- package/dist/client.d.ts +45 -2
- package/dist/client.js +159 -28
- package/dist/client.js.map +1 -1
- package/dist/index.js +58 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/tool.d.ts +28 -0
- package/dist/lib/tool.js +19 -0
- package/dist/lib/tool.js.map +1 -0
- package/dist/tools/__tests__/client.test.d.ts +1 -0
- package/dist/tools/__tests__/client.test.js +196 -0
- package/dist/tools/__tests__/client.test.js.map +1 -0
- package/dist/tools/__tests__/live-guard.test.d.ts +1 -0
- package/dist/tools/__tests__/live-guard.test.js +50 -0
- package/dist/tools/__tests__/live-guard.test.js.map +1 -0
- package/dist/tools/__tests__/new-tools.test.d.ts +1 -0
- package/dist/tools/__tests__/new-tools.test.js +217 -0
- package/dist/tools/__tests__/new-tools.test.js.map +1 -0
- package/dist/tools/__tests__/tool.test.d.ts +1 -0
- package/dist/tools/__tests__/tool.test.js +27 -0
- package/dist/tools/__tests__/tool.test.js.map +1 -0
- package/dist/tools/create-checkout.d.ts +3 -1
- package/dist/tools/create-checkout.js +35 -11
- package/dist/tools/create-checkout.js.map +1 -1
- package/dist/tools/create-payment-intent.d.ts +3 -1
- package/dist/tools/create-payment-intent.js +24 -7
- package/dist/tools/create-payment-intent.js.map +1 -1
- package/dist/tools/create-payment.d.ts +3 -1
- package/dist/tools/create-payment.js +21 -7
- package/dist/tools/create-payment.js.map +1 -1
- package/dist/tools/create-refund.d.ts +5 -3
- package/dist/tools/create-refund.js +28 -7
- package/dist/tools/create-refund.js.map +1 -1
- package/dist/tools/create-source.d.ts +4 -2
- package/dist/tools/create-source.js +24 -9
- package/dist/tools/create-source.js.map +1 -1
- package/dist/tools/customers.d.ts +45 -0
- package/dist/tools/customers.js +87 -0
- package/dist/tools/customers.js.map +1 -0
- package/dist/tools/get-checkout.d.ts +2 -0
- package/dist/tools/get-checkout.js +11 -4
- package/dist/tools/get-checkout.js.map +1 -1
- package/dist/tools/get-payment-intent.d.ts +2 -0
- package/dist/tools/get-payment-intent.js +11 -4
- package/dist/tools/get-payment-intent.js.map +1 -1
- package/dist/tools/get-source.d.ts +2 -0
- package/dist/tools/get-source.js +11 -4
- package/dist/tools/get-source.js.map +1 -1
- package/dist/tools/links.d.ts +42 -0
- package/dist/tools/links.js +92 -0
- package/dist/tools/links.js.map +1 -0
- package/dist/tools/list-payments.d.ts +4 -2
- package/dist/tools/list-payments.js +19 -6
- package/dist/tools/list-payments.js.map +1 -1
- package/dist/tools/payment-methods.d.ts +70 -0
- package/dist/tools/payment-methods.js +65 -0
- package/dist/tools/payment-methods.js.map +1 -0
- package/dist/tools/refunds.d.ts +25 -0
- package/dist/tools/refunds.js +55 -0
- package/dist/tools/refunds.js.map +1 -0
- package/dist/tools/webhooks.d.ts +61 -0
- package/dist/tools/webhooks.js +165 -0
- package/dist/tools/webhooks.js.map +1 -0
- package/package.json +36 -56
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 theYahia
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 theYahia
|
|
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
CHANGED
|
@@ -1,50 +1,157 @@
|
|
|
1
|
-
# paymongo-mcp
|
|
2
|
-
|
|
3
|
-
MCP server for PayMongo
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
|
13
|
-
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
# paymongo-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for [PayMongo](https://www.paymongo.com/) — the Philippine payment
|
|
4
|
+
gateway. Exposes payment intents, sources, payments, refunds, checkout sessions,
|
|
5
|
+
**payment links**, **webhooks**, **payment methods**, and **customers** as MCP
|
|
6
|
+
tools via Basic Auth.
|
|
7
|
+
|
|
8
|
+
## Tools (24)
|
|
9
|
+
|
|
10
|
+
### Payments
|
|
11
|
+
|
|
12
|
+
| Tool | Description |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `create_payment_intent` | Create a payment intent |
|
|
15
|
+
| `get_payment_intent` | Get a payment intent by ID |
|
|
16
|
+
| `create_source` | Create a GCash/GrabPay source |
|
|
17
|
+
| `get_source` | Get a source by ID |
|
|
18
|
+
| `create_payment` | Charge a source to create a payment |
|
|
19
|
+
| `list_payments` | List payments (cursor pagination) |
|
|
20
|
+
|
|
21
|
+
### Refunds
|
|
22
|
+
|
|
23
|
+
| Tool | Description |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `create_refund` | Refund a payment |
|
|
26
|
+
| `get_refund` | Get a refund by ID |
|
|
27
|
+
| `list_refunds` | List refunds (cursor pagination) |
|
|
28
|
+
|
|
29
|
+
### Checkout & Links
|
|
30
|
+
|
|
31
|
+
| Tool | Description |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `create_checkout` | Create a hosted checkout session |
|
|
34
|
+
| `get_checkout` | Get a checkout session by ID |
|
|
35
|
+
| `create_link` | Create a no-code Payment Link |
|
|
36
|
+
| `get_link` | Get a link by ID or reference number |
|
|
37
|
+
| `archive_link` | Archive / unarchive a link |
|
|
38
|
+
|
|
39
|
+
### Webhooks
|
|
40
|
+
|
|
41
|
+
| Tool | Description |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `create_webhook` | Register a webhook endpoint |
|
|
44
|
+
| `list_webhooks` | List webhooks |
|
|
45
|
+
| `get_webhook` | Get a webhook by ID |
|
|
46
|
+
| `update_webhook` | Update URL/events, enable/disable |
|
|
47
|
+
| `verify_webhook_signature` | Verify the `Paymongo-Signature` header locally (no API call) |
|
|
48
|
+
|
|
49
|
+
### Payment Methods & Customers
|
|
50
|
+
|
|
51
|
+
| Tool | Description |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `create_payment_method` | Create a payment method (e.g. a card) |
|
|
54
|
+
| `get_payment_method` | Get a payment method by ID |
|
|
55
|
+
| `create_customer` | Create a customer |
|
|
56
|
+
| `get_customer` | Get a customer by ID |
|
|
57
|
+
| `list_customers` | List customers (cursor pagination) |
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"mcpServers": {
|
|
64
|
+
"paymongo": {
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "@theyahia/paymongo-mcp"],
|
|
67
|
+
"env": {
|
|
68
|
+
"PAYMONGO_SECRET_KEY": "<YOUR_PAYMONGO_SECRET_KEY>"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Environment Variables
|
|
76
|
+
|
|
77
|
+
| Variable | Required | Description |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `PAYMONGO_SECRET_KEY` | Yes | Secret API key from the PayMongo dashboard (`sk_test_…` or `sk_live_…`). |
|
|
80
|
+
| `PAYMONGO_ALLOW_LIVE` | No | Must be `"true"` to allow money-moving tools when a **live** key is used (see Safety). |
|
|
81
|
+
|
|
82
|
+
The server reads the secret key **lazily** — it can start and list its tools
|
|
83
|
+
without a key set, so a missing key surfaces as a tool-call error rather than a
|
|
84
|
+
startup crash.
|
|
85
|
+
|
|
86
|
+
## Amounts
|
|
87
|
+
|
|
88
|
+
All amounts are **integers in centavos** (the smallest currency unit):
|
|
89
|
+
`10000` = ₱100.00. PayMongo's minimum is typically `2000` (₱20.00) and varies by
|
|
90
|
+
method.
|
|
91
|
+
|
|
92
|
+
## Safety: test vs live keys
|
|
93
|
+
|
|
94
|
+
PayMongo keys are either **test** (`sk_test_…`) or **live** (`sk_live_…`). To
|
|
95
|
+
prevent an AI agent from accidentally moving real money, the money-moving tools
|
|
96
|
+
(`create_payment`, `create_refund`, `create_payment_intent`, `create_source`,
|
|
97
|
+
`create_checkout`, `create_link`, `create_payment_method`) are **refused** when a
|
|
98
|
+
live key is configured unless you opt in with:
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
PAYMONGO_ALLOW_LIVE=true
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Read-only tools (`get_*`, `list_*`) always work. Tools are also tagged with MCP
|
|
105
|
+
annotations (`readOnlyHint` / `destructiveHint`) so clients can auto-approve
|
|
106
|
+
reads and warn on destructive actions.
|
|
107
|
+
|
|
108
|
+
## Webhooks
|
|
109
|
+
|
|
110
|
+
Create a webhook to receive async payment events (e.g. `source.chargeable`,
|
|
111
|
+
`payment.paid`):
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
create_webhook { "url": "https://your.app/paymongo/hook", "events": ["payment.paid", "source.chargeable"] }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The response includes a per-webhook **signing secret** (`whsk_…`). Store it. When
|
|
118
|
+
PayMongo POSTs an event, verify the `Paymongo-Signature` header **before**
|
|
119
|
+
trusting the body — pass the raw request body, the header value, and the signing
|
|
120
|
+
secret to `verify_webhook_signature`:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
verify_webhook_signature {
|
|
124
|
+
"payload": "<raw request body, exactly as received>",
|
|
125
|
+
"signature_header": "t=...,te=...,li=...",
|
|
126
|
+
"webhook_signing_secret": "whsk_...",
|
|
127
|
+
"mode": "test"
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
It computes `HMAC-SHA256(timestamp + "." + body)` and compares it (timing-safe)
|
|
132
|
+
against the `te` (test) or `li` (live) segment. This tool runs entirely locally
|
|
133
|
+
and needs no API key. Pass `tolerance_seconds` to also reject stale timestamps
|
|
134
|
+
(replay protection).
|
|
135
|
+
|
|
136
|
+
## Demo Prompts
|
|
137
|
+
|
|
138
|
+
- "Create a payment intent for 100 PHP"
|
|
139
|
+
- "Create a GCash source for 50 PHP with success/fail redirect URLs"
|
|
140
|
+
- "Create a payment link for 250 PHP for 'Consulting fee'"
|
|
141
|
+
- "List recent payments"
|
|
142
|
+
- "Refund 25 PHP from payment pay_123"
|
|
143
|
+
- "Register a webhook at https://example.com/hook for payment.paid"
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm ci
|
|
149
|
+
npm run typecheck # tsc --noEmit
|
|
150
|
+
npm run build # tsc -> dist/
|
|
151
|
+
npm test # vitest
|
|
152
|
+
npm run dev # run from source with tsx
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
|
+
/** A single error object as returned by the PayMongo API (`errors[]`). */
|
|
2
|
+
export interface PayMongoApiError {
|
|
3
|
+
code?: string;
|
|
4
|
+
detail?: string;
|
|
5
|
+
source?: {
|
|
6
|
+
pointer?: string;
|
|
7
|
+
attribute?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Error thrown when PayMongo returns a non-2xx response or a guard trips. */
|
|
11
|
+
export declare class PayMongoError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly errors?: PayMongoApiError[];
|
|
14
|
+
constructor(message: string, status: number, errors?: PayMongoApiError[]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Turn a raw PayMongo error response into a readable {@link PayMongoError}.
|
|
18
|
+
* Parses the `{ errors: [{ code, detail, source }] }` shape into
|
|
19
|
+
* `code: detail (pointer)` segments. Falls back to the raw text for non-JSON
|
|
20
|
+
* bodies. The message ALWAYS starts with `PayMongo HTTP <status>` so callers
|
|
21
|
+
* (and tests) can rely on that prefix regardless of branch.
|
|
22
|
+
*
|
|
23
|
+
* Note: we only surface the documented `errors[]` fields — never the echoed
|
|
24
|
+
* request `attributes` — to avoid leaking sensitive request data (e.g. card
|
|
25
|
+
* numbers) back through error messages.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatPayMongoError(status: number, rawText: string): PayMongoError;
|
|
28
|
+
export interface RequestOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Marks this call as a money-moving operation (creates a charge, refund,
|
|
31
|
+
* payment intent/source/checkout/link, or attaches real card data). When the
|
|
32
|
+
* configured secret key is a LIVE key (`sk_live_`) and `PAYMONGO_ALLOW_LIVE`
|
|
33
|
+
* is not `true`, the request is refused before any network call.
|
|
34
|
+
*/
|
|
35
|
+
moneyMoving?: boolean;
|
|
36
|
+
}
|
|
1
37
|
export declare class PayMongoClient {
|
|
2
|
-
private secretKey;
|
|
38
|
+
private readonly secretKey;
|
|
39
|
+
/** True when the configured secret key is a live key (`sk_live_`). */
|
|
40
|
+
readonly isLive: boolean;
|
|
41
|
+
private readonly allowLive;
|
|
3
42
|
constructor();
|
|
4
43
|
private get authHeader();
|
|
5
|
-
|
|
44
|
+
private assertLiveAllowed;
|
|
45
|
+
request(method: string, path: string, body?: unknown, opts?: RequestOptions): Promise<unknown>;
|
|
6
46
|
}
|
|
47
|
+
export declare function getClient(): PayMongoClient;
|
|
48
|
+
/** Test-only: drop the cached client so a new key/env is picked up. */
|
|
49
|
+
export declare function __resetClientForTests(): void;
|
package/dist/client.js
CHANGED
|
@@ -1,45 +1,176 @@
|
|
|
1
1
|
const BASE_URL = "https://api.paymongo.com/v1";
|
|
2
|
-
const
|
|
2
|
+
const TIMEOUT_MS = 15_000;
|
|
3
|
+
const MAX_RETRIES = 2;
|
|
4
|
+
/** Error thrown when PayMongo returns a non-2xx response or a guard trips. */
|
|
5
|
+
export class PayMongoError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
errors;
|
|
8
|
+
constructor(message, status, errors) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "PayMongoError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.errors = errors;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Turn a raw PayMongo error response into a readable {@link PayMongoError}.
|
|
17
|
+
* Parses the `{ errors: [{ code, detail, source }] }` shape into
|
|
18
|
+
* `code: detail (pointer)` segments. Falls back to the raw text for non-JSON
|
|
19
|
+
* bodies. The message ALWAYS starts with `PayMongo HTTP <status>` so callers
|
|
20
|
+
* (and tests) can rely on that prefix regardless of branch.
|
|
21
|
+
*
|
|
22
|
+
* Note: we only surface the documented `errors[]` fields — never the echoed
|
|
23
|
+
* request `attributes` — to avoid leaking sensitive request data (e.g. card
|
|
24
|
+
* numbers) back through error messages.
|
|
25
|
+
*/
|
|
26
|
+
export function formatPayMongoError(status, rawText) {
|
|
27
|
+
const prefix = `PayMongo HTTP ${status}`;
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = JSON.parse(rawText);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// body was not JSON — fall through to the raw-text fallback below
|
|
34
|
+
}
|
|
35
|
+
if (parsed?.errors && Array.isArray(parsed.errors) && parsed.errors.length > 0) {
|
|
36
|
+
const details = parsed.errors
|
|
37
|
+
.map((e) => {
|
|
38
|
+
const code = e.code ? `${e.code}: ` : "";
|
|
39
|
+
const detail = e.detail ?? "unknown error";
|
|
40
|
+
const pointer = e.source?.pointer ?? e.source?.attribute;
|
|
41
|
+
return pointer ? `${code}${detail} (${pointer})` : `${code}${detail}`;
|
|
42
|
+
})
|
|
43
|
+
.join("; ");
|
|
44
|
+
return new PayMongoError(`${prefix}: ${details}`, status, parsed.errors);
|
|
45
|
+
}
|
|
46
|
+
const trimmed = rawText?.trim();
|
|
47
|
+
return new PayMongoError(trimmed ? `${prefix}: ${trimmed}` : prefix, status);
|
|
48
|
+
}
|
|
3
49
|
export class PayMongoClient {
|
|
4
50
|
secretKey;
|
|
51
|
+
/** True when the configured secret key is a live key (`sk_live_`). */
|
|
52
|
+
isLive;
|
|
53
|
+
allowLive;
|
|
5
54
|
constructor() {
|
|
6
55
|
this.secretKey = process.env.PAYMONGO_SECRET_KEY ?? "";
|
|
7
56
|
if (!this.secretKey) {
|
|
8
|
-
throw new
|
|
9
|
-
"Get your key at https://dashboard.paymongo.com/");
|
|
57
|
+
throw new PayMongoError("Environment variable PAYMONGO_SECRET_KEY is required. " +
|
|
58
|
+
"Get your key at https://dashboard.paymongo.com/", 401);
|
|
10
59
|
}
|
|
60
|
+
this.isLive = this.secretKey.startsWith("sk_live_");
|
|
61
|
+
this.allowLive = process.env.PAYMONGO_ALLOW_LIVE === "true";
|
|
11
62
|
}
|
|
12
63
|
get authHeader() {
|
|
13
64
|
return "Basic " + Buffer.from(this.secretKey + ":").toString("base64");
|
|
14
65
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
method,
|
|
21
|
-
headers: {
|
|
22
|
-
"Authorization": this.authHeader,
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
"Accept": "application/json",
|
|
25
|
-
},
|
|
26
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
27
|
-
signal: controller.signal,
|
|
28
|
-
});
|
|
29
|
-
clearTimeout(timer);
|
|
30
|
-
if (!response.ok) {
|
|
31
|
-
const text = await response.text();
|
|
32
|
-
throw new Error(`PayMongo HTTP ${response.status}: ${text}`);
|
|
33
|
-
}
|
|
34
|
-
return response.json();
|
|
66
|
+
assertLiveAllowed(method, path) {
|
|
67
|
+
if (this.isLive && !this.allowLive) {
|
|
68
|
+
throw new PayMongoError(`Refusing a money-moving operation (${method} ${path}) with a LIVE secret key (sk_live_). ` +
|
|
69
|
+
"This safety guard prevents accidental real-money charges or refunds. " +
|
|
70
|
+
"Set PAYMONGO_ALLOW_LIVE=true to enable live operations.", 403);
|
|
35
71
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
72
|
+
}
|
|
73
|
+
async request(method, path, body, opts = {}) {
|
|
74
|
+
if (opts.moneyMoving)
|
|
75
|
+
this.assertLiveAllowed(method, path);
|
|
76
|
+
const isGet = method.toUpperCase() === "GET";
|
|
77
|
+
let attempt = 0;
|
|
78
|
+
while (true) {
|
|
79
|
+
const controller = new AbortController();
|
|
80
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
81
|
+
try {
|
|
82
|
+
const response = await fetch(`${BASE_URL}${path}`, {
|
|
83
|
+
method,
|
|
84
|
+
headers: {
|
|
85
|
+
Authorization: this.authHeader,
|
|
86
|
+
"Content-Type": "application/json",
|
|
87
|
+
Accept: "application/json",
|
|
88
|
+
},
|
|
89
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
90
|
+
signal: controller.signal,
|
|
91
|
+
});
|
|
92
|
+
clearTimeout(timer);
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
// Retry policy: 429 always; 5xx for GET only (a POST may have
|
|
95
|
+
// succeeded server-side — retrying without idempotency keys risks a
|
|
96
|
+
// double charge).
|
|
97
|
+
const retryable = response.status === 429 || (isGet && response.status >= 500);
|
|
98
|
+
if (retryable && attempt < MAX_RETRIES) {
|
|
99
|
+
const delay = parseRetryAfter(response.headers.get("retry-after")) ??
|
|
100
|
+
backoffDelay(attempt);
|
|
101
|
+
attempt++;
|
|
102
|
+
await sleep(delay);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const text = await response.text();
|
|
106
|
+
throw formatPayMongoError(response.status, text);
|
|
107
|
+
}
|
|
108
|
+
// Decode the success body. A decode failure is NOT transient — wrap it
|
|
109
|
+
// as a PayMongoError so it isn't caught by the network-retry branch.
|
|
110
|
+
try {
|
|
111
|
+
return await response.json();
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
throw new PayMongoError(`PayMongo HTTP ${response.status}: response body was not valid JSON.`, response.status);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
clearTimeout(timer);
|
|
119
|
+
if (error instanceof PayMongoError)
|
|
120
|
+
throw error;
|
|
121
|
+
const isAbort = error instanceof DOMException && error.name === "AbortError";
|
|
122
|
+
// Transient network/timeout errors: retry GET only. Compute the delay
|
|
123
|
+
// before incrementing so both retry paths follow the same backoff curve.
|
|
124
|
+
if (isGet && attempt < MAX_RETRIES) {
|
|
125
|
+
const delay = backoffDelay(attempt);
|
|
126
|
+
attempt++;
|
|
127
|
+
await sleep(delay);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (isAbort) {
|
|
131
|
+
throw new PayMongoError(`PayMongo HTTP 408: request timeout (${TIMEOUT_MS / 1000}s).`, 408);
|
|
132
|
+
}
|
|
133
|
+
// Keep the documented "PayMongo HTTP <status>" prefix even for
|
|
134
|
+
// transport-layer failures (status 0 = no HTTP response received).
|
|
135
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
136
|
+
throw new PayMongoError(`PayMongo HTTP 0: network error — ${message}`, 0);
|
|
40
137
|
}
|
|
41
|
-
throw error;
|
|
42
138
|
}
|
|
43
139
|
}
|
|
44
140
|
}
|
|
141
|
+
/** Exponential backoff with a 4s cap: ~1s, 2s, (capped) 4s. */
|
|
142
|
+
function backoffDelay(attempt) {
|
|
143
|
+
return Math.min(1000 * 2 ** attempt, 4000);
|
|
144
|
+
}
|
|
145
|
+
/** Parse a `Retry-After` header (delta-seconds or HTTP-date), clamped to 0–10s. */
|
|
146
|
+
function parseRetryAfter(header) {
|
|
147
|
+
if (!header)
|
|
148
|
+
return undefined;
|
|
149
|
+
const asSeconds = Number(header);
|
|
150
|
+
if (!Number.isNaN(asSeconds)) {
|
|
151
|
+
return Math.min(Math.max(asSeconds, 0), 10) * 1000;
|
|
152
|
+
}
|
|
153
|
+
const asDate = Date.parse(header);
|
|
154
|
+
if (!Number.isNaN(asDate)) {
|
|
155
|
+
return Math.min(Math.max(asDate - Date.now(), 0), 10_000);
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
function sleep(ms) {
|
|
160
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
161
|
+
}
|
|
162
|
+
// --- Lazy singleton -------------------------------------------------------
|
|
163
|
+
// The client is constructed on first use (NOT at import time) so the server
|
|
164
|
+
// can list its tools without a key set; a missing key then surfaces as a
|
|
165
|
+
// tool-call error rather than crashing the process during `tools/list`.
|
|
166
|
+
let cached = null;
|
|
167
|
+
export function getClient() {
|
|
168
|
+
if (!cached)
|
|
169
|
+
cached = new PayMongoClient();
|
|
170
|
+
return cached;
|
|
171
|
+
}
|
|
172
|
+
/** Test-only: drop the cached client so a new key/env is picked up. */
|
|
173
|
+
export function __resetClientForTests() {
|
|
174
|
+
cached = null;
|
|
175
|
+
}
|
|
45
176
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,6BAA6B,CAAC;AAC/C,MAAM,OAAO,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,6BAA6B,CAAC;AAC/C,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,MAAM,WAAW,GAAG,CAAC,CAAC;AAStB,8EAA8E;AAC9E,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAAS;IACf,MAAM,CAAsB;IAErC,YAAY,OAAe,EAAE,MAAc,EAAE,MAA2B;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAc,EAAE,OAAe;IACjE,MAAM,MAAM,GAAG,iBAAiB,MAAM,EAAE,CAAC;IAEzC,IAAI,MAAmD,CAAC;IACxD,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAoC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;IACpE,CAAC;IAED,IAAI,MAAM,EAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/E,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM;aAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,IAA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M,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;AACxE,IAAI,MAAM,GAA0B,IAAI,CAAC;AAEzC,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,MAAM;QAAE,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;IAC3C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,qBAAqB;IACnC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
import { tool } from "./lib/tool.js";
|
|
6
|
+
import { createPaymentIntentTool } from "./tools/create-payment-intent.js";
|
|
7
|
+
import { getPaymentIntentTool } from "./tools/get-payment-intent.js";
|
|
8
|
+
import { createSourceTool } from "./tools/create-source.js";
|
|
9
|
+
import { getSourceTool } from "./tools/get-source.js";
|
|
10
|
+
import { createPaymentTool } from "./tools/create-payment.js";
|
|
11
|
+
import { listPaymentsTool } from "./tools/list-payments.js";
|
|
12
|
+
import { createRefundTool } from "./tools/create-refund.js";
|
|
13
|
+
import { createCheckoutTool } from "./tools/create-checkout.js";
|
|
14
|
+
import { getCheckoutTool } from "./tools/get-checkout.js";
|
|
15
|
+
import { linksDescriptors } from "./tools/links.js";
|
|
16
|
+
import { webhooksDescriptors } from "./tools/webhooks.js";
|
|
17
|
+
import { paymentMethodsDescriptors } from "./tools/payment-methods.js";
|
|
18
|
+
import { customersDescriptors } from "./tools/customers.js";
|
|
19
|
+
import { refundsDescriptors } from "./tools/refunds.js";
|
|
20
|
+
const FALLBACK_VERSION = "1.1.0";
|
|
21
|
+
/** Read the package version at runtime (dist/index.js → ../package.json). */
|
|
22
|
+
function getVersion() {
|
|
23
|
+
try {
|
|
24
|
+
const require = createRequire(import.meta.url);
|
|
25
|
+
const pkg = require("../package.json");
|
|
26
|
+
return pkg.version ?? FALLBACK_VERSION;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return FALLBACK_VERSION;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const tools = [
|
|
33
|
+
createPaymentIntentTool,
|
|
34
|
+
getPaymentIntentTool,
|
|
35
|
+
createSourceTool,
|
|
36
|
+
getSourceTool,
|
|
37
|
+
createPaymentTool,
|
|
38
|
+
listPaymentsTool,
|
|
39
|
+
createRefundTool,
|
|
40
|
+
createCheckoutTool,
|
|
41
|
+
getCheckoutTool,
|
|
42
|
+
...linksDescriptors,
|
|
43
|
+
...webhooksDescriptors,
|
|
44
|
+
...paymentMethodsDescriptors,
|
|
45
|
+
...customersDescriptors,
|
|
46
|
+
...refundsDescriptors,
|
|
47
|
+
];
|
|
48
|
+
const server = new McpServer({ name: "paymongo-mcp", version: getVersion() });
|
|
49
|
+
for (const t of tools) {
|
|
50
|
+
server.registerTool(t.name, {
|
|
51
|
+
title: t.title,
|
|
52
|
+
description: t.description,
|
|
53
|
+
inputSchema: t.inputSchema,
|
|
54
|
+
annotations: t.annotations,
|
|
55
|
+
}, tool(t.handler));
|
|
56
|
+
}
|
|
23
57
|
async function main() {
|
|
24
58
|
const transport = new StdioServerTransport();
|
|
25
59
|
await server.connect(transport);
|
|
26
|
-
console.error(
|
|
60
|
+
console.error(`[paymongo-mcp] Server started. ${tools.length} tools available.`);
|
|
27
61
|
}
|
|
28
|
-
main().catch((error) => {
|
|
62
|
+
main().catch((error) => {
|
|
63
|
+
console.error("[paymongo-mcp] Error:", error);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
});
|
|
29
66
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,IAAI,EAAuB,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD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