shabaaspay-mcp-server 1.0.6 → 1.0.7
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/dist/api/client.d.ts +7 -11
- package/dist/api/client.js +4 -30
- package/dist/mcp-handler/discovery.js +7 -17
- package/dist/mcp-handler/mcp.js +0 -10
- package/dist/mcp-handler/server-card.js +5 -68
- package/dist/mcp-handler/tools/implementations.d.ts +1 -5
- package/dist/mcp-handler/tools/implementations.js +3 -129
- package/dist/mcp-handler/tools/index.js +1 -7
- package/dist/tools/auth.js +1 -8
- package/dist/tools/index.d.ts +41 -74
- package/dist/tools/index.js +1 -2
- package/dist/tools/merchant-operations.d.ts +31 -28
- package/dist/tools/payment-agreements.d.ts +6 -27
- package/dist/tools/payment-agreements.js +0 -50
- package/dist/tools/payment-initiations.d.ts +4 -4
- package/dist/types/index.d.ts +41 -64
- package/dist/types/index.js +10 -31
- package/package.json +1 -1
- package/readme.md +175 -27
- package/server.json +2 -2
package/dist/api/client.d.ts
CHANGED
|
@@ -30,11 +30,6 @@ export declare class ShabaasApiClient {
|
|
|
30
30
|
token: string;
|
|
31
31
|
fetchedAt: string;
|
|
32
32
|
}>;
|
|
33
|
-
getTodaysEarnings(options?: RequestAuthOptions): Promise<ApiResponse>;
|
|
34
|
-
listActivePaymentAgreements(params?: {
|
|
35
|
-
page?: number;
|
|
36
|
-
status?: string;
|
|
37
|
-
}, options?: RequestAuthOptions): Promise<ApiResponse>;
|
|
38
33
|
getPaymentAgreement(id: string, options?: RequestAuthOptions): Promise<ApiResponse>;
|
|
39
34
|
createPaymentAgreement(data: {
|
|
40
35
|
name: string;
|
|
@@ -83,15 +78,16 @@ export declare class ShabaasApiClient {
|
|
|
83
78
|
number_of_transactions_permitted: number;
|
|
84
79
|
}, options?: RequestAuthOptions): Promise<ApiResponse>;
|
|
85
80
|
generateInvoice(data: {
|
|
81
|
+
uuid: string;
|
|
86
82
|
phone_number?: string;
|
|
87
83
|
invoice: {
|
|
88
84
|
amount: string | number;
|
|
89
|
-
description
|
|
90
|
-
bill_to
|
|
91
|
-
address
|
|
92
|
-
receiver_abn
|
|
93
|
-
ref_no
|
|
94
|
-
gst_included
|
|
85
|
+
description: string;
|
|
86
|
+
bill_to: string;
|
|
87
|
+
address: string;
|
|
88
|
+
receiver_abn: string;
|
|
89
|
+
ref_no: string;
|
|
90
|
+
gst_included: boolean;
|
|
95
91
|
gst_does_not_apply?: boolean;
|
|
96
92
|
email?: string;
|
|
97
93
|
};
|
package/dist/api/client.js
CHANGED
|
@@ -119,26 +119,6 @@ class ShabaasApiClient {
|
|
|
119
119
|
const token = await this.getTokenForRequest(options?.requestUuid);
|
|
120
120
|
return { token, fetchedAt: new Date().toISOString() };
|
|
121
121
|
}
|
|
122
|
-
async getTodaysEarnings(options) {
|
|
123
|
-
return await this.withAuthRetry(async (token) => {
|
|
124
|
-
const response = await this.client.get('/api/public/todays_earnings', {
|
|
125
|
-
headers: { Authorization: token },
|
|
126
|
-
});
|
|
127
|
-
return response.data;
|
|
128
|
-
}, options?.requestUuid);
|
|
129
|
-
}
|
|
130
|
-
async listActivePaymentAgreements(params = {}, options) {
|
|
131
|
-
return await this.withAuthRetry(async (token) => {
|
|
132
|
-
const query = new URLSearchParams();
|
|
133
|
-
if (params.page != null)
|
|
134
|
-
query.set('page', String(params.page));
|
|
135
|
-
if (params.status != null)
|
|
136
|
-
query.set('status', params.status);
|
|
137
|
-
const qs = query.toString();
|
|
138
|
-
const response = await this.client.get(`/api/public/payment_agreements${qs ? `?${qs}` : ''}`, { headers: { Authorization: token } });
|
|
139
|
-
return response.data;
|
|
140
|
-
}, options?.requestUuid);
|
|
141
|
-
}
|
|
142
122
|
async getPaymentAgreement(id, options) {
|
|
143
123
|
return await this.withAuthRetry(async (token) => {
|
|
144
124
|
const response = await this.client.get(`/api/public/payment_agreement?id=${encodeURIComponent(id)}`, { headers: { Authorization: token } });
|
|
@@ -271,16 +251,10 @@ class ShabaasApiClient {
|
|
|
271
251
|
}, options?.requestUuid);
|
|
272
252
|
}
|
|
273
253
|
async generateInvoice(data, options) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
const response = await this.client.post('/api/public/generate_invoice', {
|
|
279
|
-
api_key: apiKey,
|
|
280
|
-
phone_number: data.phone_number,
|
|
281
|
-
invoice: data.invoice,
|
|
282
|
-
});
|
|
283
|
-
return response.data;
|
|
254
|
+
return await this.withAuthRetry(async (token) => {
|
|
255
|
+
const response = await this.client.post('/api/public/generate_invoice', data, { headers: { Authorization: token } });
|
|
256
|
+
return response.data;
|
|
257
|
+
}, options?.requestUuid);
|
|
284
258
|
}
|
|
285
259
|
async getPaymentLink(data, options) {
|
|
286
260
|
return await this.withAuthRetry(async (token) => {
|
|
@@ -353,38 +353,28 @@ async function listTools(env) {
|
|
|
353
353
|
...sharedExecution,
|
|
354
354
|
openapi_operation: { method: 'post', path: '/api/public/generate_invoice' },
|
|
355
355
|
output_openapi_schema_ref: 'inline: { message, data: { checkout_url } }',
|
|
356
|
-
required_arguments: ['invoice'],
|
|
357
|
-
optional_arguments: [
|
|
358
|
-
'phone_number',
|
|
359
|
-
'include_raw',
|
|
360
|
-
'invoice.description',
|
|
361
|
-
'invoice.bill_to',
|
|
362
|
-
'invoice.address',
|
|
363
|
-
'invoice.receiver_abn',
|
|
364
|
-
'invoice.ref_no',
|
|
365
|
-
'invoice.gst_included',
|
|
366
|
-
'invoice.gst_does_not_apply',
|
|
367
|
-
'invoice.email',
|
|
368
|
-
],
|
|
356
|
+
required_arguments: ['uuid', 'invoice'],
|
|
357
|
+
optional_arguments: ['phone_number', 'include_raw'],
|
|
369
358
|
argument_hints: {
|
|
370
|
-
|
|
359
|
+
uuid: 'Merchant checkout username.',
|
|
371
360
|
},
|
|
372
361
|
example: {
|
|
373
362
|
tool: 'generate_invoice',
|
|
374
363
|
arguments: {
|
|
375
|
-
|
|
364
|
+
uuid: 'merchant_slug_or_secret',
|
|
365
|
+
invoice: { amount: '50.00', description: 'Invoice 1001', bill_to: 'Customer', address: 'Address', receiver_abn: 'ABN', ref_no: '1001', gst_included: true },
|
|
376
366
|
},
|
|
377
367
|
},
|
|
378
368
|
decision_guidance: {
|
|
379
369
|
when_to_use: 'Use to generate invoice checkout URL for external collection flow.',
|
|
380
|
-
preconditions: ['invoice payload'],
|
|
370
|
+
preconditions: ['uuid and invoice payload'],
|
|
381
371
|
retryable_errors: ['AUTH_MISSING_OR_INVALID'],
|
|
382
372
|
non_retryable_errors: ['INVALID_REQUEST', 'VALIDATION_OR_BUSINESS_RULE'],
|
|
383
373
|
next_best_tool_on_failure: null,
|
|
384
374
|
},
|
|
385
375
|
idempotency_notes: 'Creates a new invoice checkout URL/session per call; treat as non-idempotent.',
|
|
386
376
|
error_contract: [
|
|
387
|
-
{ status: 400, code: 'INVALID_REQUEST', when: 'Invalid invoice payload shape' },
|
|
377
|
+
{ status: 400, code: 'INVALID_REQUEST', when: 'Invalid uuid or invoice payload shape' },
|
|
388
378
|
{ status: 401, code: 'AUTH_MISSING_OR_INVALID', when: 'Session/API key missing or invalid' },
|
|
389
379
|
{ status: 422, code: 'VALIDATION_OR_BUSINESS_RULE', when: 'Invoice validation/business rule failure' },
|
|
390
380
|
],
|
package/dist/mcp-handler/mcp.js
CHANGED
|
@@ -47,16 +47,6 @@ async function runWithMcpContextLock(fn) {
|
|
|
47
47
|
*/
|
|
48
48
|
function buildAllowedToolsList(policy, env) {
|
|
49
49
|
const allTools = [
|
|
50
|
-
{
|
|
51
|
-
name: 'list_active_payment_agreements',
|
|
52
|
-
description: 'List the merchant\'s active PayTo payment agreements. Use for requests like "list my active agreements".',
|
|
53
|
-
inputSchema: httpMcpToolSchema(index_js_2.ListActivePaymentAgreementsInputSchema),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'get_todays_earnings',
|
|
57
|
-
description: 'Today\'s settled payment cash summary (AEST) for the merchant and branches. Use for "how much cash came in today?".',
|
|
58
|
-
inputSchema: httpMcpToolSchema(index_js_2.GetTodaysEarningsInputSchema),
|
|
59
|
-
},
|
|
60
50
|
{
|
|
61
51
|
name: 'get_payment_agreement',
|
|
62
52
|
description: 'Retrieve payment agreement details with AI insights.',
|
|
@@ -30,38 +30,6 @@ function toStrictObjectSchema(schema) {
|
|
|
30
30
|
}
|
|
31
31
|
function buildServerCard(env) {
|
|
32
32
|
const tools = [
|
|
33
|
-
{
|
|
34
|
-
name: 'list_active_payment_agreements',
|
|
35
|
-
description: 'List the merchant\'s active PayTo payment agreements. Use when the user asks to list or find their active agreements.',
|
|
36
|
-
inputSchema: toStrictObjectSchema((0, schema_helpers_js_1.stripAuthorizationFieldFromJsonSchema)((0, zod_to_json_schema_1.zodToJsonSchema)(index_js_1.ListActivePaymentAgreementsInputSchema))),
|
|
37
|
-
metadata: {
|
|
38
|
-
schemaVersion: '2026-04-15',
|
|
39
|
-
requiredArguments: [],
|
|
40
|
-
optionalArguments: ['page', 'status', 'include_raw'],
|
|
41
|
-
openapiOperation: { method: 'get', path: '/api/public/payment_agreements' },
|
|
42
|
-
outputSchemaRef: 'inline: { payment_agreements: PaymentAgreement[], count, status_filter }',
|
|
43
|
-
errorContract: [
|
|
44
|
-
{ status: 401, code: 'AUTH_MISSING_OR_INVALID', when: 'Session/API key missing or invalid' },
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'get_todays_earnings',
|
|
51
|
-
description: 'Today\'s settled payment cash summary (AEST) for the authenticated merchant and branches. Use when asked how much cash came in today.',
|
|
52
|
-
inputSchema: toStrictObjectSchema((0, schema_helpers_js_1.stripAuthorizationFieldFromJsonSchema)((0, zod_to_json_schema_1.zodToJsonSchema)(index_js_1.GetTodaysEarningsInputSchema))),
|
|
53
|
-
metadata: {
|
|
54
|
-
schemaVersion: '2026-04-15',
|
|
55
|
-
requiredArguments: [],
|
|
56
|
-
optionalArguments: ['include_raw'],
|
|
57
|
-
openapiOperation: { method: 'get', path: '/api/public/todays_earnings' },
|
|
58
|
-
outputSchemaRef: 'inline: { date, timezone, currency, count, total_amount }',
|
|
59
|
-
errorContract: [
|
|
60
|
-
{ status: 401, code: 'AUTH_MISSING_OR_INVALID', when: 'Session/API key missing or invalid' },
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
64
|
-
},
|
|
65
33
|
{
|
|
66
34
|
name: 'get_payment_agreement',
|
|
67
35
|
description: 'Retrieve payment agreement details with AI insights.',
|
|
@@ -168,19 +136,8 @@ function buildServerCard(env) {
|
|
|
168
136
|
inputSchema: toStrictObjectSchema((0, schema_helpers_js_1.stripAuthorizationFieldFromJsonSchema)((0, zod_to_json_schema_1.zodToJsonSchema)(index_js_1.GenerateInvoiceInputSchema))),
|
|
169
137
|
metadata: {
|
|
170
138
|
schemaVersion: '2026-04-15',
|
|
171
|
-
requiredArguments: ['invoice
|
|
172
|
-
optionalArguments: [
|
|
173
|
-
'phone_number',
|
|
174
|
-
'include_raw',
|
|
175
|
-
'invoice.description',
|
|
176
|
-
'invoice.bill_to',
|
|
177
|
-
'invoice.address',
|
|
178
|
-
'invoice.receiver_abn',
|
|
179
|
-
'invoice.ref_no',
|
|
180
|
-
'invoice.gst_included',
|
|
181
|
-
'invoice.gst_does_not_apply',
|
|
182
|
-
'invoice.email',
|
|
183
|
-
],
|
|
139
|
+
requiredArguments: ['uuid', 'invoice'],
|
|
140
|
+
optionalArguments: ['phone_number', 'include_raw'],
|
|
184
141
|
openapiOperation: { method: 'post', path: '/api/public/generate_invoice' },
|
|
185
142
|
outputSchemaRef: 'inline: { message, data: { checkout_url } }',
|
|
186
143
|
},
|
|
@@ -234,19 +191,6 @@ function buildServerCard(env) {
|
|
|
234
191
|
tools,
|
|
235
192
|
resources: [],
|
|
236
193
|
prompts: [
|
|
237
|
-
{
|
|
238
|
-
name: 'todays_earnings',
|
|
239
|
-
description: 'Answer how much settled cash came in today (AEST) by calling get_todays_earnings for the merchant and branches.',
|
|
240
|
-
arguments: [],
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
name: 'list_active_agreements',
|
|
244
|
-
description: 'List the merchant\'s active PayTo agreements, then use get_payment_agreement for details on a specific ID.',
|
|
245
|
-
arguments: [
|
|
246
|
-
{ name: 'page', description: 'Optional page number', required: false },
|
|
247
|
-
{ name: 'status', description: 'Optional status filter (default active; use all for every agreement)', required: false },
|
|
248
|
-
],
|
|
249
|
-
},
|
|
250
194
|
{
|
|
251
195
|
name: 'create_payto_agreement',
|
|
252
196
|
description: 'Draft parameters for a new PayTo agreement, then call create_payment_agreement with validated fields.',
|
|
@@ -291,16 +235,9 @@ function buildServerCard(env) {
|
|
|
291
235
|
name: 'generate_invoice',
|
|
292
236
|
description: 'Draft invoice payload and call generate_invoice to get an external checkout URL.',
|
|
293
237
|
arguments: [
|
|
294
|
-
{ name: '
|
|
295
|
-
{ name: 'invoice
|
|
296
|
-
{ name: '
|
|
297
|
-
{ name: 'invoice.address', description: 'Billing address', required: false },
|
|
298
|
-
{ name: 'invoice.receiver_abn', description: 'Receiver ABN', required: false },
|
|
299
|
-
{ name: 'invoice.ref_no', description: 'Invoice reference number', required: false },
|
|
300
|
-
{ name: 'invoice.gst_included', description: 'GST included in amount (default false)', required: false },
|
|
301
|
-
{ name: 'invoice.gst_does_not_apply', description: 'GST does not apply', required: false },
|
|
302
|
-
{ name: 'invoice.email', description: 'Customer email for invoice', required: false },
|
|
303
|
-
{ name: 'phone_number', description: 'Customer phone', required: false },
|
|
238
|
+
{ name: 'uuid', description: 'Merchant checkout username or secret', required: true },
|
|
239
|
+
{ name: 'invoice', description: 'Invoice object with amount and description', required: true },
|
|
240
|
+
{ name: 'phone_number', description: 'Optional customer phone', required: false },
|
|
304
241
|
],
|
|
305
242
|
},
|
|
306
243
|
],
|
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
import type { Env } from '../types.js';
|
|
8
8
|
/** get_auth_token: Fetch bearer token. Sandbox only. */
|
|
9
9
|
export declare function getAuthToken(args: any, baseUrl: string, env: Env): Promise<Response>;
|
|
10
|
-
/** get_todays_earnings: settled cash summary for today (AEST), merchant + branches. */
|
|
11
|
-
export declare function getTodaysEarnings(args: any, baseUrl: string, env: Env, bearer: string): Promise<Response>;
|
|
12
|
-
/** list_active_payment_agreements: GET merchant PayTo agreements (active by default). */
|
|
13
|
-
export declare function listActivePaymentAgreements(args: any, baseUrl: string, env: Env, bearer: string): Promise<Response>;
|
|
14
10
|
/** get_payment_agreement: GET agreement by ID. Enriches with insights and summary when enrich !== false. */
|
|
15
11
|
export declare function getPaymentAgreement(args: any, baseUrl: string, env: Env, bearer: string): Promise<Response>;
|
|
16
12
|
/** create_payment_agreement: POST new agreement to backend */
|
|
@@ -21,4 +17,4 @@ export declare function initiatePayment(args: any, baseUrl: string, env: Env, be
|
|
|
21
17
|
export declare function getPaymentInitiation(args: any, baseUrl: string, env: Env, bearer: string): Promise<Response>;
|
|
22
18
|
export declare function initiateDirectDebit(args: any, baseUrl: string, env: Env, bearer: string, requestId: string): Promise<Response>;
|
|
23
19
|
export declare function updateBilateralAgreement(args: any, baseUrl: string, env: Env, bearer: string): Promise<Response>;
|
|
24
|
-
export declare function generateInvoice(args: any, baseUrl: string, env: Env,
|
|
20
|
+
export declare function generateInvoice(args: any, baseUrl: string, env: Env, bearer: string): Promise<Response>;
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getAuthToken = getAuthToken;
|
|
10
|
-
exports.getTodaysEarnings = getTodaysEarnings;
|
|
11
|
-
exports.listActivePaymentAgreements = listActivePaymentAgreements;
|
|
12
10
|
exports.getPaymentAgreement = getPaymentAgreement;
|
|
13
11
|
exports.createPaymentAgreement = createPaymentAgreement;
|
|
14
12
|
exports.initiatePayment = initiatePayment;
|
|
@@ -64,130 +62,6 @@ async function getAuthToken(args, baseUrl, env) {
|
|
|
64
62
|
return (0, utils_js_1.jsonResponse)({ error: 'Authorization failed', message: error.message }, 500, env);
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
function formatAud(amount) {
|
|
68
|
-
return amount.toLocaleString('en-AU', {
|
|
69
|
-
style: 'currency',
|
|
70
|
-
currency: 'AUD',
|
|
71
|
-
minimumFractionDigits: 2,
|
|
72
|
-
maximumFractionDigits: 2,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/** get_todays_earnings: settled cash summary for today (AEST), merchant + branches. */
|
|
76
|
-
async function getTodaysEarnings(args, baseUrl, env, bearer) {
|
|
77
|
-
try {
|
|
78
|
-
const startTime = Date.now();
|
|
79
|
-
const includeRaw = args.include_raw === true;
|
|
80
|
-
const response = await fetch(`${baseUrl}/api/public/todays_earnings`, {
|
|
81
|
-
headers: { Authorization: bearer, 'Content-Type': 'application/json', 'X-Shabaas-Client': 'mcp' },
|
|
82
|
-
});
|
|
83
|
-
const data = (await response.json());
|
|
84
|
-
if (!response.ok) {
|
|
85
|
-
return (0, utils_js_1.jsonResponse)({
|
|
86
|
-
success: false,
|
|
87
|
-
error: data?.error_code || 'Request failed',
|
|
88
|
-
message: data?.message || "Unable to retrieve today's earnings summary.",
|
|
89
|
-
...(includeRaw ? { raw: data } : {}),
|
|
90
|
-
}, response.status, env);
|
|
91
|
-
}
|
|
92
|
-
const payload = data?.data ?? {};
|
|
93
|
-
const count = Number(payload.count ?? 0);
|
|
94
|
-
const totalAmount = Number(payload.total_amount ?? 0);
|
|
95
|
-
const date = payload.date ?? 'today';
|
|
96
|
-
const timezone = payload.timezone ?? 'Australia/Sydney';
|
|
97
|
-
const environment = env.SHABAAS_ENVIRONMENT === 'production' ? 'production' : 'sandbox';
|
|
98
|
-
return (0, utils_js_1.jsonResponse)({
|
|
99
|
-
success: true,
|
|
100
|
-
timestamp: new Date().toISOString(),
|
|
101
|
-
data: {
|
|
102
|
-
date,
|
|
103
|
-
timezone,
|
|
104
|
-
currency: payload.currency ?? 'AUD',
|
|
105
|
-
count,
|
|
106
|
-
total_amount: totalAmount,
|
|
107
|
-
scope: payload.scope ?? 'settled_payments_today',
|
|
108
|
-
includes_branches: payload.includes_branches ?? false,
|
|
109
|
-
},
|
|
110
|
-
metadata: {
|
|
111
|
-
requestId: `req_${Date.now()}`,
|
|
112
|
-
processingTime: Date.now() - startTime,
|
|
113
|
-
environment,
|
|
114
|
-
},
|
|
115
|
-
insights: {
|
|
116
|
-
status: count > 0 ? 'found' : 'empty',
|
|
117
|
-
canProceed: true,
|
|
118
|
-
nextActions: count > 0 ? ['get_payment_initiation'] : ['initiate_payment'],
|
|
119
|
-
warnings: count === 0
|
|
120
|
-
? ['No settled payments today in the EOD reporting window (AEST).']
|
|
121
|
-
: ['Gross settled totals for today; fees and refunds are not deducted here.'],
|
|
122
|
-
},
|
|
123
|
-
summary: count > 0
|
|
124
|
-
? `Today's settled earnings (${date}, ${timezone}): ${formatAud(totalAmount)} from ${count} payment${count === 1 ? '' : 's'}.`
|
|
125
|
-
: `No settled payments today (${date}, ${timezone}) for this merchant and branches.`,
|
|
126
|
-
...(includeRaw ? { raw: data } : {}),
|
|
127
|
-
}, 200, env);
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
return (0, utils_js_1.jsonResponse)({ success: false, error: 'Request failed', message: error.message || 'An error occurred' }, 500, env);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/** list_active_payment_agreements: GET merchant PayTo agreements (active by default). */
|
|
134
|
-
async function listActivePaymentAgreements(args, baseUrl, env, bearer) {
|
|
135
|
-
try {
|
|
136
|
-
const startTime = Date.now();
|
|
137
|
-
const includeRaw = args.include_raw === true;
|
|
138
|
-
const query = new URLSearchParams();
|
|
139
|
-
if (args.page != null)
|
|
140
|
-
query.set('page', String(args.page));
|
|
141
|
-
if (args.status != null)
|
|
142
|
-
query.set('status', String(args.status));
|
|
143
|
-
const qs = query.toString();
|
|
144
|
-
const response = await fetch(`${baseUrl}/api/public/payment_agreements${qs ? `?${qs}` : ''}`, { headers: { Authorization: bearer, 'Content-Type': 'application/json', 'X-Shabaas-Client': 'mcp' } });
|
|
145
|
-
const data = (await response.json());
|
|
146
|
-
if (!response.ok) {
|
|
147
|
-
return (0, utils_js_1.jsonResponse)({
|
|
148
|
-
success: false,
|
|
149
|
-
error: data?.error_code || 'Request failed',
|
|
150
|
-
message: data?.message || 'Unable to list payment agreements.',
|
|
151
|
-
...(includeRaw ? { raw: data } : {}),
|
|
152
|
-
}, response.status, env);
|
|
153
|
-
}
|
|
154
|
-
const agreements = data?.data?.payment_agreements ?? [];
|
|
155
|
-
const count = data?.data?.count ?? agreements.length;
|
|
156
|
-
const statusFilter = data?.data?.status_filter ?? 'active';
|
|
157
|
-
const environment = env.SHABAAS_ENVIRONMENT === 'production' ? 'production' : 'sandbox';
|
|
158
|
-
return (0, utils_js_1.jsonResponse)({
|
|
159
|
-
success: true,
|
|
160
|
-
timestamp: new Date().toISOString(),
|
|
161
|
-
data: {
|
|
162
|
-
payment_agreements: agreements,
|
|
163
|
-
count,
|
|
164
|
-
status_filter: statusFilter,
|
|
165
|
-
},
|
|
166
|
-
metadata: {
|
|
167
|
-
requestId: `req_${Date.now()}`,
|
|
168
|
-
processingTime: Date.now() - startTime,
|
|
169
|
-
environment,
|
|
170
|
-
},
|
|
171
|
-
insights: {
|
|
172
|
-
status: count > 0 ? 'found' : 'empty',
|
|
173
|
-
canProceed: count > 0,
|
|
174
|
-
nextActions: count > 0
|
|
175
|
-
? ['get_payment_agreement', 'initiate_payment']
|
|
176
|
-
: ['create_payment_agreement'],
|
|
177
|
-
warnings: count === 0
|
|
178
|
-
? ['No active agreements found. Create a new agreement or pass status=all to see other agreements.']
|
|
179
|
-
: undefined,
|
|
180
|
-
},
|
|
181
|
-
summary: count > 0
|
|
182
|
-
? `Found ${count} payment agreement${count === 1 ? '' : 's'} (filter: ${statusFilter}).`
|
|
183
|
-
: `No payment agreements found (filter: ${statusFilter}).`,
|
|
184
|
-
...(includeRaw ? { raw: data } : {}),
|
|
185
|
-
}, 200, env);
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
return (0, utils_js_1.jsonResponse)({ success: false, error: 'Request failed', message: error.message || 'An error occurred' }, 500, env);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
65
|
/** get_payment_agreement: GET agreement by ID. Enriches with insights and summary when enrich !== false. */
|
|
192
66
|
async function getPaymentAgreement(args, baseUrl, env, bearer) {
|
|
193
67
|
if (!args.payment_agreement_id) {
|
|
@@ -529,15 +403,15 @@ async function updateBilateralAgreement(args, baseUrl, env, bearer) {
|
|
|
529
403
|
return (0, utils_js_1.jsonResponse)({ error: 'Request failed', message: error.message || 'An error occurred' }, 500, env);
|
|
530
404
|
}
|
|
531
405
|
}
|
|
532
|
-
async function generateInvoice(args, baseUrl, env,
|
|
406
|
+
async function generateInvoice(args, baseUrl, env, bearer) {
|
|
533
407
|
try {
|
|
534
408
|
const startTime = Date.now();
|
|
535
409
|
const includeRaw = args.include_raw === true;
|
|
536
410
|
const response = await fetch(`${baseUrl}/api/public/generate_invoice`, {
|
|
537
411
|
method: 'POST',
|
|
538
|
-
headers: { 'Content-Type': 'application/json', 'X-Shabaas-Client': 'mcp' },
|
|
412
|
+
headers: { 'Authorization': bearer, 'Content-Type': 'application/json', 'X-Shabaas-Client': 'mcp' },
|
|
539
413
|
body: JSON.stringify({
|
|
540
|
-
|
|
414
|
+
uuid: args.uuid,
|
|
541
415
|
phone_number: args.phone_number,
|
|
542
416
|
invoice: args.invoice,
|
|
543
417
|
}),
|
|
@@ -112,12 +112,6 @@ async function runToolInvocation(toolName, args, env, policy, authToken, request
|
|
|
112
112
|
}
|
|
113
113
|
resp = await (0, implementations_js_1.getAuthToken)(args, baseUrl, env);
|
|
114
114
|
break;
|
|
115
|
-
case 'list_active_payment_agreements':
|
|
116
|
-
resp = await (0, implementations_js_1.listActivePaymentAgreements)(args, baseUrl, env, bearer);
|
|
117
|
-
break;
|
|
118
|
-
case 'get_todays_earnings':
|
|
119
|
-
resp = await (0, implementations_js_1.getTodaysEarnings)(args, baseUrl, env, bearer);
|
|
120
|
-
break;
|
|
121
115
|
case 'get_payment_agreement':
|
|
122
116
|
resp = await (0, implementations_js_1.getPaymentAgreement)(args, baseUrl, env, bearer);
|
|
123
117
|
break;
|
|
@@ -137,7 +131,7 @@ async function runToolInvocation(toolName, args, env, policy, authToken, request
|
|
|
137
131
|
resp = await (0, implementations_js_1.updateBilateralAgreement)(args, baseUrl, env, bearer);
|
|
138
132
|
break;
|
|
139
133
|
case 'generate_invoice':
|
|
140
|
-
resp = await (0, implementations_js_1.generateInvoice)(args, baseUrl, env,
|
|
134
|
+
resp = await (0, implementations_js_1.generateInvoice)(args, baseUrl, env, bearer);
|
|
141
135
|
break;
|
|
142
136
|
default:
|
|
143
137
|
return {
|
package/dist/tools/auth.js
CHANGED
|
@@ -32,14 +32,7 @@ function createAuthTools(apiClient, config) {
|
|
|
32
32
|
insights: {
|
|
33
33
|
status: 'success',
|
|
34
34
|
canProceed: true,
|
|
35
|
-
nextActions: [
|
|
36
|
-
'list_active_payment_agreements',
|
|
37
|
-
'get_todays_earnings',
|
|
38
|
-
'create_payment_agreement',
|
|
39
|
-
'get_payment_agreement',
|
|
40
|
-
'initiate_payment',
|
|
41
|
-
'get_payment_initiation',
|
|
42
|
-
],
|
|
35
|
+
nextActions: ['create_payment_agreement', 'get_payment_agreement', 'initiate_payment', 'get_payment_initiation'],
|
|
43
36
|
warnings: includeToken
|
|
44
37
|
? ['Token is included in the response. Treat it as a secret.']
|
|
45
38
|
: ['Token was fetched and cached inside the MCP server. It is not shown in this response.'],
|