recurly-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/CHANGELOG.md +61 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +19 -0
- package/dist/bin.js.map +1 -0
- package/dist/client/errors.d.ts +16 -0
- package/dist/client/errors.js +44 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/pagination.d.ts +8 -0
- package/dist/client/pagination.js +33 -0
- package/dist/client/pagination.js.map +1 -0
- package/dist/client/recurly.d.ts +19 -0
- package/dist/client/recurly.js +277 -0
- package/dist/client/recurly.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +99 -0
- package/dist/config.js.map +1 -0
- package/dist/responseGuard.d.ts +1 -0
- package/dist/responseGuard.js +124 -0
- package/dist/responseGuard.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +119 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/accounts.d.ts +217 -0
- package/dist/tools/accounts.js +71 -0
- package/dist/tools/accounts.js.map +1 -0
- package/dist/tools/addOns.d.ts +46 -0
- package/dist/tools/addOns.js +24 -0
- package/dist/tools/addOns.js.map +1 -0
- package/dist/tools/billingInfo.d.ts +57 -0
- package/dist/tools/billingInfo.js +31 -0
- package/dist/tools/billingInfo.js.map +1 -0
- package/dist/tools/businessEntities.d.ts +80 -0
- package/dist/tools/businessEntities.js +32 -0
- package/dist/tools/businessEntities.js.map +1 -0
- package/dist/tools/couponRedemptions.d.ts +135 -0
- package/dist/tools/couponRedemptions.js +57 -0
- package/dist/tools/couponRedemptions.js.map +1 -0
- package/dist/tools/coupons.d.ts +86 -0
- package/dist/tools/coupons.js +37 -0
- package/dist/tools/coupons.js.map +1 -0
- package/dist/tools/creditPayments.d.ts +73 -0
- package/dist/tools/creditPayments.js +28 -0
- package/dist/tools/creditPayments.js.map +1 -0
- package/dist/tools/customFieldDefinitions.d.ts +46 -0
- package/dist/tools/customFieldDefinitions.js +32 -0
- package/dist/tools/customFieldDefinitions.js.map +1 -0
- package/dist/tools/dunningCampaigns.d.ts +42 -0
- package/dist/tools/dunningCampaigns.js +21 -0
- package/dist/tools/dunningCampaigns.js.map +1 -0
- package/dist/tools/exports.d.ts +20 -0
- package/dist/tools/exports.js +21 -0
- package/dist/tools/exports.js.map +1 -0
- package/dist/tools/externalAccounts.d.ts +48 -0
- package/dist/tools/externalAccounts.js +28 -0
- package/dist/tools/externalAccounts.js.map +1 -0
- package/dist/tools/externalInvoices.d.ts +73 -0
- package/dist/tools/externalInvoices.js +28 -0
- package/dist/tools/externalInvoices.js.map +1 -0
- package/dist/tools/externalProducts.d.ts +85 -0
- package/dist/tools/externalProducts.js +34 -0
- package/dist/tools/externalProducts.js.map +1 -0
- package/dist/tools/externalSubscriptions.d.ts +147 -0
- package/dist/tools/externalSubscriptions.js +47 -0
- package/dist/tools/externalSubscriptions.js.map +1 -0
- package/dist/tools/generalLedgerAccounts.d.ts +46 -0
- package/dist/tools/generalLedgerAccounts.js +32 -0
- package/dist/tools/generalLedgerAccounts.js.map +1 -0
- package/dist/tools/giftCards.d.ts +42 -0
- package/dist/tools/giftCards.js +21 -0
- package/dist/tools/giftCards.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +68 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/invoiceTemplates.d.ts +83 -0
- package/dist/tools/invoiceTemplates.js +39 -0
- package/dist/tools/invoiceTemplates.js.map +1 -0
- package/dist/tools/invoices.d.ts +168 -0
- package/dist/tools/invoices.js +58 -0
- package/dist/tools/invoices.js.map +1 -0
- package/dist/tools/items.d.ts +46 -0
- package/dist/tools/items.js +24 -0
- package/dist/tools/items.js.map +1 -0
- package/dist/tools/lineItems.d.ts +93 -0
- package/dist/tools/lineItems.js +37 -0
- package/dist/tools/lineItems.js.map +1 -0
- package/dist/tools/measuredUnits.d.ts +46 -0
- package/dist/tools/measuredUnits.js +24 -0
- package/dist/tools/measuredUnits.js.map +1 -0
- package/dist/tools/performanceObligations.d.ts +42 -0
- package/dist/tools/performanceObligations.js +24 -0
- package/dist/tools/performanceObligations.js.map +1 -0
- package/dist/tools/plans.d.ts +93 -0
- package/dist/tools/plans.js +34 -0
- package/dist/tools/plans.js.map +1 -0
- package/dist/tools/priceSegments.d.ts +42 -0
- package/dist/tools/priceSegments.js +21 -0
- package/dist/tools/priceSegments.js.map +1 -0
- package/dist/tools/request.d.ts +17 -0
- package/dist/tools/request.js +55 -0
- package/dist/tools/request.js.map +1 -0
- package/dist/tools/shared.d.ts +32 -0
- package/dist/tools/shared.js +73 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/shippingAddresses.d.ts +48 -0
- package/dist/tools/shippingAddresses.js +28 -0
- package/dist/tools/shippingAddresses.js.map +1 -0
- package/dist/tools/shippingMethods.d.ts +42 -0
- package/dist/tools/shippingMethods.js +21 -0
- package/dist/tools/shippingMethods.js.map +1 -0
- package/dist/tools/sites.d.ts +46 -0
- package/dist/tools/sites.js +24 -0
- package/dist/tools/sites.js.map +1 -0
- package/dist/tools/subscriptions.d.ts +178 -0
- package/dist/tools/subscriptions.js +68 -0
- package/dist/tools/subscriptions.js.map +1 -0
- package/dist/tools/transactions.d.ts +87 -0
- package/dist/tools/transactions.js +36 -0
- package/dist/tools/transactions.js.map +1 -0
- package/dist/tools/types.d.ts +13 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/usage.d.ts +52 -0
- package/dist/tools/usage.js +33 -0
- package/dist/tools/usage.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { RecurlyApiError, RecurlyNetworkError } from './errors.js';
|
|
2
|
+
// A server-supplied Retry-After of `Fri, 31 Dec 9999 23:59:59 GMT` parses as a
|
|
3
|
+
// ~253-trillion-ms sleep — effectively a stall that holds the API key in
|
|
4
|
+
// memory and blocks the MCP client's tool call. Cap at 60s.
|
|
5
|
+
export const MAX_RETRY_DELAY_MS = 60_000;
|
|
6
|
+
// Reading a body with no size limit lets a malicious or compromised upstream
|
|
7
|
+
// send a multi-GB payload and OOM the Node process. 25 MB comfortably covers
|
|
8
|
+
// the largest realistic Recurly list response and most invoice PDFs.
|
|
9
|
+
export const MAX_RESPONSE_BYTES = 25 * 1024 * 1024;
|
|
10
|
+
// Node's fetch (undici) appends a default `Accept-Language: *` whenever the
|
|
11
|
+
// request sets none. Recurly validates this header strictly and rejects `*`
|
|
12
|
+
// with a 406 ("The Accept-Language header is not valid."). Sending a concrete
|
|
13
|
+
// locale keeps undici from ever falling back to the wildcard. Callers may
|
|
14
|
+
// override it (Recurly uses it to localize transaction error messages).
|
|
15
|
+
export const DEFAULT_ACCEPT_LANGUAGE = 'en-US';
|
|
16
|
+
// Recurly serializes array query parameters as comma-separated values
|
|
17
|
+
// (e.g. `ids=a,b,c`), matching the official client libraries.
|
|
18
|
+
function buildQuery(query) {
|
|
19
|
+
if (!query)
|
|
20
|
+
return '';
|
|
21
|
+
const params = new URLSearchParams();
|
|
22
|
+
for (const [k, v] of Object.entries(query)) {
|
|
23
|
+
if (v === undefined)
|
|
24
|
+
continue;
|
|
25
|
+
if (Array.isArray(v)) {
|
|
26
|
+
if (v.length === 0)
|
|
27
|
+
continue;
|
|
28
|
+
params.set(k, v.join(','));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
params.set(k, String(v));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const s = params.toString();
|
|
35
|
+
return s ? `?${s}` : '';
|
|
36
|
+
}
|
|
37
|
+
function isRetriable(status) {
|
|
38
|
+
return status === 429 || (status >= 500 && status < 600);
|
|
39
|
+
}
|
|
40
|
+
// Recurly returns JSON for everything except invoice PDFs (application/pdf).
|
|
41
|
+
// Treat any non-JSON, non-text content type as binary so it can be base64-wrapped
|
|
42
|
+
// rather than mangled by UTF-8 decoding.
|
|
43
|
+
function isBinaryContentType(contentType) {
|
|
44
|
+
const lower = contentType.toLowerCase();
|
|
45
|
+
if (lower === '')
|
|
46
|
+
return false;
|
|
47
|
+
if (lower.includes('json'))
|
|
48
|
+
return false;
|
|
49
|
+
if (lower.startsWith('text/'))
|
|
50
|
+
return false;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
// Retry-After (RFC 7231 §7.1.3) is either delta-seconds or an HTTP-date.
|
|
54
|
+
// Returns ms to wait, or null if the header is absent or unparseable.
|
|
55
|
+
export function parseRetryAfter(value, now = Date.now()) {
|
|
56
|
+
if (!value)
|
|
57
|
+
return null;
|
|
58
|
+
const trimmed = value.trim();
|
|
59
|
+
if (trimmed === '')
|
|
60
|
+
return null;
|
|
61
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
62
|
+
return Math.max(0, Number(trimmed) * 1000);
|
|
63
|
+
}
|
|
64
|
+
const dateMs = Date.parse(trimmed);
|
|
65
|
+
if (Number.isFinite(dateMs))
|
|
66
|
+
return Math.max(0, dateMs - now);
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
// Equal-jitter exponential backoff: random delay between 50% and 100% of
|
|
70
|
+
// 2^attempt * baseMs. Avoids thundering-herd retries under concurrent load.
|
|
71
|
+
export function backoffMs(attempt, baseMs = 250) {
|
|
72
|
+
const exp = 2 ** attempt * baseMs;
|
|
73
|
+
return exp * 0.5 + Math.random() * exp * 0.5;
|
|
74
|
+
}
|
|
75
|
+
async function sleep(ms) {
|
|
76
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
77
|
+
}
|
|
78
|
+
// Strip security-sensitive headers from user-supplied input and normalize
|
|
79
|
+
// remaining keys to lowercase. Without this, a case-variant `Authorization`
|
|
80
|
+
// header from an LLM survives as a distinct object key and Node's Headers
|
|
81
|
+
// constructor *appends* duplicate-name headers — the wire ends up sending
|
|
82
|
+
// `Authorization: <attacker>, Basic <real_key>`. Stripping host/cookie closes
|
|
83
|
+
// related abuse vectors against the fixed-host destination.
|
|
84
|
+
const RESERVED_HEADERS = new Set(['authorization', 'host', 'cookie']);
|
|
85
|
+
function sanitizeUserHeaders(input) {
|
|
86
|
+
if (!input)
|
|
87
|
+
return {};
|
|
88
|
+
const out = {};
|
|
89
|
+
for (const [k, v] of Object.entries(input)) {
|
|
90
|
+
const lower = k.toLowerCase();
|
|
91
|
+
if (RESERVED_HEADERS.has(lower))
|
|
92
|
+
continue;
|
|
93
|
+
out[lower] = v;
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
// Parse upstream JSON while dropping any literal `__proto__` key. JSON.parse
|
|
98
|
+
// never pollutes the prototype on its own, but a `__proto__` property in the
|
|
99
|
+
// payload would otherwise be copied through our object spreads (responseGuard,
|
|
100
|
+
// pagination) and surface in the output we return to the MCP client. Dropping
|
|
101
|
+
// it via the reviver keeps responses clean without affecting normal fields.
|
|
102
|
+
function parseJsonSafe(text) {
|
|
103
|
+
return JSON.parse(text, (key, value) => (key === '__proto__' ? undefined : value));
|
|
104
|
+
}
|
|
105
|
+
export class RecurlyClient {
|
|
106
|
+
config;
|
|
107
|
+
constructor(config) {
|
|
108
|
+
this.config = config;
|
|
109
|
+
}
|
|
110
|
+
// Recurly uses HTTP Basic auth with the private API key as the username and
|
|
111
|
+
// an empty password.
|
|
112
|
+
authHeader() {
|
|
113
|
+
const token = Buffer.from(`${this.config.apiKey}:`, 'utf8').toString('base64');
|
|
114
|
+
return `Basic ${token}`;
|
|
115
|
+
}
|
|
116
|
+
async request(method, path, options = {}) {
|
|
117
|
+
const url = `${this.config.host}${path}${buildQuery(options.query)}`;
|
|
118
|
+
// `accept-language` is placed before the spread so a caller MAY override it
|
|
119
|
+
// (Recurly localizes some messages by it). `accept` (API version),
|
|
120
|
+
// `user-agent`, and `authorization` are pinned AFTER the spread so no
|
|
121
|
+
// user-supplied header can change the API version, client identity, or
|
|
122
|
+
// credentials.
|
|
123
|
+
const headers = {
|
|
124
|
+
'accept-language': DEFAULT_ACCEPT_LANGUAGE,
|
|
125
|
+
...sanitizeUserHeaders(options.headers),
|
|
126
|
+
accept: `application/vnd.recurly.${this.config.apiVersion}`,
|
|
127
|
+
'user-agent': 'recurly-mcp',
|
|
128
|
+
};
|
|
129
|
+
if (!this.config.apiKey) {
|
|
130
|
+
throw new RecurlyApiError(401, method, path, {
|
|
131
|
+
message: 'RECURLY_API_KEY env var is required',
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
headers.authorization = this.authHeader();
|
|
135
|
+
let attempt = 0;
|
|
136
|
+
while (true) {
|
|
137
|
+
const controller = new AbortController();
|
|
138
|
+
const timer = setTimeout(() => controller.abort(), this.config.timeoutMs);
|
|
139
|
+
// The timer is cleared only in `finally`, so the abort signal covers BOTH
|
|
140
|
+
// the fetch and the body read. A slow/hostile upstream that trickles the
|
|
141
|
+
// response body therefore cannot hang the process past timeoutMs.
|
|
142
|
+
try {
|
|
143
|
+
let response;
|
|
144
|
+
try {
|
|
145
|
+
response = await fetch(url, {
|
|
146
|
+
method,
|
|
147
|
+
headers,
|
|
148
|
+
redirect: 'manual',
|
|
149
|
+
signal: controller.signal,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
if (attempt < this.config.maxRetries) {
|
|
154
|
+
await sleep(backoffMs(attempt));
|
|
155
|
+
attempt++;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
throw new RecurlyNetworkError(method, path, err);
|
|
159
|
+
}
|
|
160
|
+
// Refuse to follow redirects. A 3xx to another origin (or even the same
|
|
161
|
+
// origin) would resend the Authorization header to an unintended target.
|
|
162
|
+
// With redirect:'manual' undici yields an opaqueredirect (or the raw
|
|
163
|
+
// 3xx status); treat either as an error rather than following it.
|
|
164
|
+
if (response.type === 'opaqueredirect' ||
|
|
165
|
+
(response.status >= 300 && response.status < 400)) {
|
|
166
|
+
throw new RecurlyNetworkError(method, path, new Error(`refused to follow redirect (status ${response.status})`));
|
|
167
|
+
}
|
|
168
|
+
if (isRetriable(response.status) && attempt < this.config.maxRetries) {
|
|
169
|
+
const retryAfterMs = parseRetryAfter(response.headers.get('retry-after'));
|
|
170
|
+
const rawDelay = retryAfterMs !== null ? retryAfterMs : backoffMs(attempt);
|
|
171
|
+
const delay = Math.min(MAX_RETRY_DELAY_MS, rawDelay);
|
|
172
|
+
await sleep(delay);
|
|
173
|
+
attempt++;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (response.status === 204)
|
|
177
|
+
return null;
|
|
178
|
+
let bytes;
|
|
179
|
+
try {
|
|
180
|
+
bytes = await readBodyBytesWithLimit(response, MAX_RESPONSE_BYTES);
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
throw new RecurlyApiError(response.status, method, path, {
|
|
184
|
+
message: err instanceof Error ? err.message : String(err),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
188
|
+
if (!response.ok) {
|
|
189
|
+
const text = new TextDecoder('utf-8').decode(bytes);
|
|
190
|
+
let parsed = null;
|
|
191
|
+
if (text.length > 0) {
|
|
192
|
+
try {
|
|
193
|
+
parsed = parseJsonSafe(text);
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
parsed = text;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw new RecurlyApiError(response.status, method, path, parsed);
|
|
200
|
+
}
|
|
201
|
+
if (bytes.length === 0)
|
|
202
|
+
return null;
|
|
203
|
+
if (isBinaryContentType(contentType)) {
|
|
204
|
+
// e.g. invoice PDFs. Return a structured wrapper rather than a mangled
|
|
205
|
+
// string so the caller can decode the bytes losslessly.
|
|
206
|
+
return {
|
|
207
|
+
object: 'binary_file',
|
|
208
|
+
content_type: contentType,
|
|
209
|
+
encoding: 'base64',
|
|
210
|
+
byte_length: bytes.length,
|
|
211
|
+
data: Buffer.from(bytes).toString('base64'),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const text = new TextDecoder('utf-8').decode(bytes);
|
|
215
|
+
try {
|
|
216
|
+
return parseJsonSafe(text);
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return text;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
clearTimeout(timer);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Reads the body via a streaming reader and aborts if it exceeds `max` bytes.
|
|
229
|
+
// Pre-checks Content-Length to fail fast when the server is honest about size.
|
|
230
|
+
// Returns the raw bytes so the caller can JSON-parse text or base64 binary.
|
|
231
|
+
// Exported for direct testing — the production cap (25 MB) is too large to
|
|
232
|
+
// allocate in a unit test, so tests exercise the cap logic with a small max.
|
|
233
|
+
export async function readBodyBytesWithLimit(response, max) {
|
|
234
|
+
const cl = response.headers.get('content-length');
|
|
235
|
+
if (cl !== null) {
|
|
236
|
+
const n = Number(cl);
|
|
237
|
+
if (Number.isFinite(n) && n > max) {
|
|
238
|
+
throw new Error(`response body exceeds ${max} bytes (Content-Length: ${n})`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!response.body)
|
|
242
|
+
return new Uint8Array(0);
|
|
243
|
+
const reader = response.body.getReader();
|
|
244
|
+
const chunks = [];
|
|
245
|
+
let total = 0;
|
|
246
|
+
try {
|
|
247
|
+
while (true) {
|
|
248
|
+
const { done, value } = await reader.read();
|
|
249
|
+
if (done)
|
|
250
|
+
break;
|
|
251
|
+
if (value) {
|
|
252
|
+
total += value.byteLength;
|
|
253
|
+
if (total > max) {
|
|
254
|
+
await reader.cancel();
|
|
255
|
+
throw new Error(`response body exceeds ${max} bytes`);
|
|
256
|
+
}
|
|
257
|
+
chunks.push(value);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
finally {
|
|
262
|
+
try {
|
|
263
|
+
reader.releaseLock();
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// already released by cancel(); ignore
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const merged = new Uint8Array(total);
|
|
270
|
+
let offset = 0;
|
|
271
|
+
for (const chunk of chunks) {
|
|
272
|
+
merged.set(chunk, offset);
|
|
273
|
+
offset += chunk.byteLength;
|
|
274
|
+
}
|
|
275
|
+
return merged;
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=recurly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurly.js","sourceRoot":"","sources":["../../src/client/recurly.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAcnE,+EAA+E;AAC/E,yEAAyE;AACzE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,4EAA4E;AAC5E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAE/C,sEAAsE;AACtE,8DAA8D;AAC9D,SAAS,UAAU,CAAC,KAA8B;IAChD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,IAAI,CAAC,KAAK,SAAS;YAAE,SAAS;QAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YAC7B,MAAM,CAAC,GAA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AAC,MAAM,CAAC;YACP,uCAAuC;QACzC,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Recurly's two API regions. The host is the origin only; paths are appended
|
|
2
|
+
// by the client. RECURLY_HOST overrides this entirely (self-hosted mocks, EU
|
|
3
|
+
// vanity domains, proxies, tests).
|
|
4
|
+
const REGION_HOSTS = {
|
|
5
|
+
us: 'https://v3.recurly.com',
|
|
6
|
+
eu: 'https://v3.eu.recurly.com',
|
|
7
|
+
};
|
|
8
|
+
// The API version this server is built and tested against. Recurly pins
|
|
9
|
+
// behavior to the version sent in the Accept header. Overridable, but the
|
|
10
|
+
// tool paths/params here are modeled on v2021-02-25.
|
|
11
|
+
const DEFAULT_API_VERSION = 'v2021-02-25';
|
|
12
|
+
function parseIntEnv(name, raw, fallback, min, max) {
|
|
13
|
+
if (raw === undefined)
|
|
14
|
+
return fallback;
|
|
15
|
+
const n = Number(raw);
|
|
16
|
+
if (!Number.isFinite(n) || !Number.isInteger(n)) {
|
|
17
|
+
throw new Error(`${name} must be an integer, got: ${raw}`);
|
|
18
|
+
}
|
|
19
|
+
if (n < min) {
|
|
20
|
+
throw new Error(`${name} must be >= ${min}, got: ${n}`);
|
|
21
|
+
}
|
|
22
|
+
if (max !== undefined && n > max) {
|
|
23
|
+
throw new Error(`${name} must be <= ${max}, got: ${n}`);
|
|
24
|
+
}
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
// Validate RECURLY_HOST is a parseable http(s) URL. Without this, a typo or
|
|
28
|
+
// attacker-controlled env (e.g. RECURLY_HOST=http://internal) silently ships
|
|
29
|
+
// the API key to a non-HTTPS host. We warn on http:// rather than reject
|
|
30
|
+
// because local mocks in dev are a legitimate use.
|
|
31
|
+
const HTTP_LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
32
|
+
function parseHost(raw) {
|
|
33
|
+
let url;
|
|
34
|
+
try {
|
|
35
|
+
url = new URL(raw);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new Error(`RECURLY_HOST is not a valid URL: ${raw}`);
|
|
39
|
+
}
|
|
40
|
+
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
41
|
+
throw new Error(`RECURLY_HOST must use http: or https:, got: ${url.protocol}`);
|
|
42
|
+
}
|
|
43
|
+
// The host is an origin only; a path/query/fragment would silently prefix or
|
|
44
|
+
// corrupt every API path. Reject so the misconfiguration fails loudly.
|
|
45
|
+
if (url.pathname !== '/' || url.search !== '' || url.hash !== '') {
|
|
46
|
+
throw new Error(`RECURLY_HOST must be an origin only (no path/query/fragment), got: ${raw}`);
|
|
47
|
+
}
|
|
48
|
+
if (url.protocol === 'http:') {
|
|
49
|
+
// Permit plaintext only for loopback (local mocks/dev). Refuse to ship the
|
|
50
|
+
// API key in the clear to a remote host.
|
|
51
|
+
if (!HTTP_LOOPBACK_HOSTS.has(url.hostname)) {
|
|
52
|
+
throw new Error(`RECURLY_HOST may only use http: for a loopback host (localhost/127.0.0.1/[::1]); ` +
|
|
53
|
+
`refusing to send the API key in plaintext to ${url.hostname}`);
|
|
54
|
+
}
|
|
55
|
+
process.stderr.write('recurly-mcp: warning: RECURLY_HOST uses http: (loopback) — API key sent in plaintext locally\n');
|
|
56
|
+
}
|
|
57
|
+
return raw.replace(/\/+$/, '');
|
|
58
|
+
}
|
|
59
|
+
function resolveHost(hostRaw, regionRaw) {
|
|
60
|
+
if (hostRaw !== undefined && hostRaw !== '')
|
|
61
|
+
return parseHost(hostRaw);
|
|
62
|
+
const region = (regionRaw ?? 'us').toLowerCase();
|
|
63
|
+
const host = REGION_HOSTS[region];
|
|
64
|
+
if (!host) {
|
|
65
|
+
throw new Error(`RECURLY_REGION must be one of: ${Object.keys(REGION_HOSTS).join(', ')}, got: ${regionRaw}`);
|
|
66
|
+
}
|
|
67
|
+
return host;
|
|
68
|
+
}
|
|
69
|
+
// The version is interpolated raw into the Accept header
|
|
70
|
+
// (`application/vnd.recurly.<version>`); reject CR/LF (header injection) and
|
|
71
|
+
// require the documented `vYYYY-MM-DD` shape.
|
|
72
|
+
function parseApiVersion(raw) {
|
|
73
|
+
const value = raw ?? DEFAULT_API_VERSION;
|
|
74
|
+
if (/[\r\n]/.test(value)) {
|
|
75
|
+
throw new Error('RECURLY_API_VERSION must not contain CR or LF');
|
|
76
|
+
}
|
|
77
|
+
if (!/^v\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
78
|
+
throw new Error(`RECURLY_API_VERSION must look like v2021-02-25, got: ${value}`);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
export function loadConfig(env) {
|
|
83
|
+
return {
|
|
84
|
+
apiKey: env.RECURLY_API_KEY ?? '',
|
|
85
|
+
host: resolveHost(env.RECURLY_HOST, env.RECURLY_REGION),
|
|
86
|
+
apiVersion: parseApiVersion(env.RECURLY_API_VERSION),
|
|
87
|
+
// timeoutMs must be positive — `setTimeout(abort, 0)` aborts every request.
|
|
88
|
+
timeoutMs: parseIntEnv('RECURLY_TIMEOUT_MS', env.RECURLY_TIMEOUT_MS, 15000, 1),
|
|
89
|
+
// maxRetries may be zero (disable retries) but not negative; cap at 10 so a
|
|
90
|
+
// misconfiguration can't turn a single tool call into a multi-hour stall.
|
|
91
|
+
maxRetries: parseIntEnv('RECURLY_MAX_RETRIES', env.RECURLY_MAX_RETRIES, 2, 0, 10),
|
|
92
|
+
// Max UTF-8 bytes of a serialized tool result sent to the MCP client. Distinct
|
|
93
|
+
// from the client's MAX_RESPONSE_BYTES (25 MB upstream-body OOM guard). Default
|
|
94
|
+
// 75000 (~19k tokens) stays under the ~25k MCP result cap; floor 1000 keeps the
|
|
95
|
+
// truncation envelopes themselves serviceable.
|
|
96
|
+
maxOutputBytes: parseIntEnv('RECURLY_MAX_OUTPUT_BYTES', env.RECURLY_MAX_OUTPUT_BYTES, 75000, 1000),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AASA,6EAA6E;AAC7E,6EAA6E;AAC7E,mCAAmC;AACnC,MAAM,YAAY,GAA2B;IAC3C,EAAE,EAAE,wBAAwB;IAC5B,EAAE,EAAE,2BAA2B;CAChC,CAAC;AAEF,wEAAwE;AACxE,0EAA0E;AAC1E,qDAAqD;AACrD,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAE1C,SAAS,WAAW,CAClB,IAAY,EACZ,GAAuB,EACvB,QAAgB,EAChB,GAAW,EACX,GAAY;IAEZ,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IACvC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,6BAA6B,GAAG,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,eAAe,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,GAAG,KAAK,SAAS,IAAI,CAAC,GAAG,GA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D,UAAU,EAAE,eAAe,CAAC,GAAG,CAAC,mBAAmB,CAAC;QACpD,4EAA4E;QAC5E,SAAS,EAAE,WAAW,CAAC,oBAAoB,EAAE,GAAG,CAAC,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,4EAA4E;QAC5E,0EAA0E;QAC1E,UAAU,EAAE,WAAW,CAAC,qBAAqB,EAAE,GAAG,CAAC,mBAAmB,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjF,+EAA+E;QAC/E,gFAAgF;QAChF,gFAAgF;QAChF,+CAA+C;QAC/C,cAAc,EAAE,WAAW,CACzB,0BAA0B,EAC1B,GAAG,CAAC,wBAAwB,EAC5B,KAAK,EACL,IAAI,CACL;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shapeResult(result: unknown, maxBytes: number): string;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Caps the size of a tool result before it is serialized to the MCP client.
|
|
2
|
+
// The MCP transport imposes a per-result token budget; an unbounded `list`
|
|
3
|
+
// (up to 200 full Recurly objects) can blow past it, at which point the client
|
|
4
|
+
// spills the result to a file and the model loses inline visibility. This guard
|
|
5
|
+
// keeps every result within `maxBytes` of compact JSON.
|
|
6
|
+
//
|
|
7
|
+
// SEPARATE from the client's MAX_RESPONSE_BYTES (25 MB), which limits the
|
|
8
|
+
// upstream HTTP body for OOM protection. This limits what we EMIT to the client.
|
|
9
|
+
function byteLength(s) {
|
|
10
|
+
return Buffer.byteLength(s, 'utf8');
|
|
11
|
+
}
|
|
12
|
+
function safeStringify(value) {
|
|
13
|
+
// JSON.stringify yields undefined for undefined / functions / symbols.
|
|
14
|
+
const s = JSON.stringify(value);
|
|
15
|
+
return s ?? 'null';
|
|
16
|
+
}
|
|
17
|
+
const TOO_LARGE_REASON = 'response_exceeded_max_bytes';
|
|
18
|
+
// Generous reservation for the list envelope (object/has_more/next/_pagination/
|
|
19
|
+
// _truncated + hint). Correctness does NOT depend on this estimate — truncateList
|
|
20
|
+
// does a final fit check and drops items until the assembled JSON is in budget.
|
|
21
|
+
const LIST_ENVELOPE_HEADROOM = 4096;
|
|
22
|
+
function isListResult(value) {
|
|
23
|
+
return (typeof value === 'object' &&
|
|
24
|
+
value !== null &&
|
|
25
|
+
value.object === 'list' &&
|
|
26
|
+
Array.isArray(value.data));
|
|
27
|
+
}
|
|
28
|
+
function truncationHint(returned, total) {
|
|
29
|
+
return (`Showing the first ${returned} of ${total} items on this page to stay within ` +
|
|
30
|
+
'the size limit. Re-request with a smaller `limit`, add filters (e.g. state, ids, ' +
|
|
31
|
+
'begin_time), or page using the cursor in _pagination.');
|
|
32
|
+
}
|
|
33
|
+
// Fallback when a list's passthrough fields (long cursor/URL, custom keys) alone
|
|
34
|
+
// exceed the budget: drop them entirely so the output still respects `maxBytes`.
|
|
35
|
+
function minimalListEnvelope(total, maxBytes) {
|
|
36
|
+
return {
|
|
37
|
+
object: 'list',
|
|
38
|
+
data: [],
|
|
39
|
+
_truncated: {
|
|
40
|
+
reason: TOO_LARGE_REASON,
|
|
41
|
+
max_bytes: maxBytes,
|
|
42
|
+
returned_items: 0,
|
|
43
|
+
omitted_items: total,
|
|
44
|
+
hint: truncationHint(0, total),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function buildListEnvelope(result, kept, total, maxBytes) {
|
|
49
|
+
// Spread preserves passthrough fields (object/has_more/next/_pagination);
|
|
50
|
+
// `data` is replaced with the kept slice.
|
|
51
|
+
return {
|
|
52
|
+
...result,
|
|
53
|
+
data: kept,
|
|
54
|
+
_truncated: {
|
|
55
|
+
reason: TOO_LARGE_REASON,
|
|
56
|
+
max_bytes: maxBytes,
|
|
57
|
+
returned_items: kept.length,
|
|
58
|
+
omitted_items: total - kept.length,
|
|
59
|
+
hint: truncationHint(kept.length, total),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function truncateList(result, maxBytes) {
|
|
64
|
+
const items = result.data;
|
|
65
|
+
const itemBudget = Math.max(0, maxBytes - LIST_ENVELOPE_HEADROOM);
|
|
66
|
+
const kept = [];
|
|
67
|
+
let used = 0;
|
|
68
|
+
for (const item of items) {
|
|
69
|
+
const size = byteLength(safeStringify(item)) + 1; // +1 ≈ comma separator
|
|
70
|
+
if (used + size > itemBudget)
|
|
71
|
+
break;
|
|
72
|
+
kept.push(item);
|
|
73
|
+
used += size;
|
|
74
|
+
}
|
|
75
|
+
let envelope = buildListEnvelope(result, kept, items.length, maxBytes);
|
|
76
|
+
// Final fit: drop trailing items until the assembled JSON fits. Guarantees
|
|
77
|
+
// correctness regardless of the headroom estimate.
|
|
78
|
+
while (kept.length > 0 && byteLength(safeStringify(envelope)) > maxBytes) {
|
|
79
|
+
kept.pop();
|
|
80
|
+
envelope = buildListEnvelope(result, kept, items.length, maxBytes);
|
|
81
|
+
}
|
|
82
|
+
// If passthrough fields alone blow the budget, fall back to a minimal envelope.
|
|
83
|
+
if (byteLength(safeStringify(envelope)) > maxBytes) {
|
|
84
|
+
return minimalListEnvelope(items.length, maxBytes);
|
|
85
|
+
}
|
|
86
|
+
return envelope;
|
|
87
|
+
}
|
|
88
|
+
const TOO_LARGE_HINT = 'This single resource exceeds the inline size limit and was not returned in full. ' +
|
|
89
|
+
'Fetch a narrower sub-resource or specific record. Invoice PDFs (action=get_pdf) ' +
|
|
90
|
+
'are large by nature.';
|
|
91
|
+
function tooLargeEnvelope(result, maxBytes, actualBytes) {
|
|
92
|
+
const obj = typeof result === 'object' && result !== null ? result : {};
|
|
93
|
+
const inner = {
|
|
94
|
+
reason: TOO_LARGE_REASON,
|
|
95
|
+
max_bytes: maxBytes,
|
|
96
|
+
actual_bytes: actualBytes,
|
|
97
|
+
// Bound the only variable-length fields so the envelope itself always stays
|
|
98
|
+
// within `maxBytes` (mirrors the list path's minimalListEnvelope guarantee).
|
|
99
|
+
object: typeof obj.object === 'string' ? obj.object.slice(0, 200) : typeof result,
|
|
100
|
+
id: typeof obj.id === 'string'
|
|
101
|
+
? obj.id.slice(0, 200)
|
|
102
|
+
: typeof obj.code === 'string'
|
|
103
|
+
? obj.code.slice(0, 200)
|
|
104
|
+
: null,
|
|
105
|
+
hint: TOO_LARGE_HINT,
|
|
106
|
+
};
|
|
107
|
+
// For invoice-PDF style binary wrappers, surface metadata without the base64.
|
|
108
|
+
if (obj.object === 'binary_file') {
|
|
109
|
+
inner.content_type = obj.content_type ?? null;
|
|
110
|
+
inner.byte_length = obj.byte_length ?? null;
|
|
111
|
+
inner.encoding = obj.encoding ?? null;
|
|
112
|
+
}
|
|
113
|
+
return { _response_too_large: inner };
|
|
114
|
+
}
|
|
115
|
+
// Serialize `result` compactly, capping the output at `maxBytes` UTF-8 bytes.
|
|
116
|
+
export function shapeResult(result, maxBytes) {
|
|
117
|
+
const full = safeStringify(result);
|
|
118
|
+
if (byteLength(full) <= maxBytes)
|
|
119
|
+
return full;
|
|
120
|
+
if (isListResult(result))
|
|
121
|
+
return safeStringify(truncateList(result, maxBytes));
|
|
122
|
+
return safeStringify(tooLargeEnvelope(result, maxBytes, byteLength(full)));
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=responseGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseGuard.js","sourceRoot":"","sources":["../src/responseGuard.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2EAA2E;AAC3E,+EAA+E;AAC/E,gFAAgF;AAChF,wDAAwD;AACxD,EAAE;AACF,0EAA0E;AAC1E,iFAAiF;AAEjF,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,uEAAuE;IACvE,MAAM,CAAC,GAAuB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,CAAC,IAAI,MAAM,CAAC;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I,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC9C,IAAI,YAAY,CAAC,MAAM,CAAC;QAAE,OAAO,aAAa,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC/E,OAAO,aAAa,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
type JsonObject = Record<string, unknown>;
|
|
4
|
+
export declare function toMcpInputSchema(schema: z.ZodTypeAny): JsonObject;
|
|
5
|
+
export declare function createServer(env?: NodeJS.ProcessEnv | Record<string, string | undefined>): Promise<Server>;
|
|
6
|
+
export declare function startStdioServer(): Promise<void>;
|
|
7
|
+
export {};
|