shabaaspay-mcp-server 1.0.1
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 -0
- package/dist/api/client.d.ts +60 -0
- package/dist/api/client.js +214 -0
- package/dist/config/index.d.ts +54 -0
- package/dist/config/index.js +79 -0
- package/dist/enricher/action-suggester.d.ts +2 -0
- package/dist/enricher/action-suggester.js +26 -0
- package/dist/enricher/index.d.ts +2 -0
- package/dist/enricher/index.js +166 -0
- package/dist/enricher/status-analyzer.d.ts +6 -0
- package/dist/enricher/status-analyzer.js +71 -0
- package/dist/enricher/summary-generator.d.ts +8 -0
- package/dist/enricher/summary-generator.js +45 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -0
- package/dist/security/auth.d.ts +4 -0
- package/dist/security/auth.js +30 -0
- package/dist/security/policy.d.ts +18 -0
- package/dist/security/policy.js +35 -0
- package/dist/security/rate-limiter.d.ts +13 -0
- package/dist/security/rate-limiter.js +55 -0
- package/dist/security/validator.d.ts +6 -0
- package/dist/security/validator.js +22 -0
- package/dist/server/http-server.d.ts +28 -0
- package/dist/server/http-server.js +524 -0
- package/dist/server/stdio-server.d.ts +13 -0
- package/dist/server/stdio-server.js +114 -0
- package/dist/server-http.d.ts +2 -0
- package/dist/server-http.js +27 -0
- package/dist/tools/auth.d.ts +17 -0
- package/dist/tools/auth.js +51 -0
- package/dist/tools/index.d.ts +159 -0
- package/dist/tools/index.js +14 -0
- package/dist/tools/payment-agreements.d.ts +68 -0
- package/dist/tools/payment-agreements.js +92 -0
- package/dist/tools/payment-initiations.d.ts +84 -0
- package/dist/tools/payment-initiations.js +162 -0
- package/dist/tools/response-helpers.d.ts +4 -0
- package/dist/tools/response-helpers.js +32 -0
- package/dist/types/index.d.ts +184 -0
- package/dist/types/index.js +80 -0
- package/dist/worker.d.ts +15 -0
- package/dist/worker.js +767 -0
- package/package.json +64 -0
- package/readme.md +113 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validationErrorResponse = validationErrorResponse;
|
|
4
|
+
exports.toolErrorResponse = toolErrorResponse;
|
|
5
|
+
function baseErrorResponse(summary, environment, warnings, raw) {
|
|
6
|
+
const requestId = `req_${Date.now()}`;
|
|
7
|
+
return {
|
|
8
|
+
success: false,
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
data: null,
|
|
11
|
+
metadata: {
|
|
12
|
+
requestId,
|
|
13
|
+
processingTime: 0,
|
|
14
|
+
environment,
|
|
15
|
+
},
|
|
16
|
+
insights: {
|
|
17
|
+
status: 'error',
|
|
18
|
+
canProceed: false,
|
|
19
|
+
nextActions: [],
|
|
20
|
+
warnings,
|
|
21
|
+
},
|
|
22
|
+
summary,
|
|
23
|
+
...(raw ? { raw } : {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function validationErrorResponse(errors, environment) {
|
|
27
|
+
const summary = `Validation failed: ${errors.join(', ')}`;
|
|
28
|
+
return baseErrorResponse(summary, environment, ['validation_error']);
|
|
29
|
+
}
|
|
30
|
+
function toolErrorResponse(message, environment, raw) {
|
|
31
|
+
return baseErrorResponse(message, environment, undefined, raw);
|
|
32
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export interface StandardResponse<T = any> {
|
|
3
|
+
success: boolean;
|
|
4
|
+
timestamp: string;
|
|
5
|
+
data: T;
|
|
6
|
+
metadata: {
|
|
7
|
+
requestId: string;
|
|
8
|
+
processingTime: number;
|
|
9
|
+
environment: 'sandbox' | 'production';
|
|
10
|
+
};
|
|
11
|
+
insights: {
|
|
12
|
+
status: string;
|
|
13
|
+
canProceed: boolean;
|
|
14
|
+
nextActions: string[];
|
|
15
|
+
warnings?: string[];
|
|
16
|
+
business?: {
|
|
17
|
+
product: 'PayTo';
|
|
18
|
+
meaning: string;
|
|
19
|
+
readiness: {
|
|
20
|
+
canInitiatePayment: boolean;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
limits: {
|
|
24
|
+
maximumAmount?: number;
|
|
25
|
+
currency: 'AUD';
|
|
26
|
+
};
|
|
27
|
+
cadence: {
|
|
28
|
+
frequency?: string;
|
|
29
|
+
numberOfTransactionsPermitted?: number;
|
|
30
|
+
};
|
|
31
|
+
timing: {
|
|
32
|
+
createdAt?: string;
|
|
33
|
+
endDate?: string;
|
|
34
|
+
createdDaysAgo?: number;
|
|
35
|
+
expiresInDays?: number;
|
|
36
|
+
isExpiringSoon?: boolean;
|
|
37
|
+
};
|
|
38
|
+
payerControls: string[];
|
|
39
|
+
reconciliationNotes: string[];
|
|
40
|
+
operationalChecks: string[];
|
|
41
|
+
recommendedCustomerCopy?: string;
|
|
42
|
+
riskFlags: string[];
|
|
43
|
+
references: Array<{
|
|
44
|
+
title: string;
|
|
45
|
+
url: string;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
summary: string;
|
|
50
|
+
raw?: any;
|
|
51
|
+
}
|
|
52
|
+
export declare const PaymentAgreementSchema: z.ZodObject<{
|
|
53
|
+
payment_agreement_id: z.ZodString;
|
|
54
|
+
status: z.ZodString;
|
|
55
|
+
end_date: z.ZodOptional<z.ZodString>;
|
|
56
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
57
|
+
maximum_amount: z.ZodOptional<z.ZodString>;
|
|
58
|
+
extented_status: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
status: string;
|
|
61
|
+
payment_agreement_id: string;
|
|
62
|
+
end_date?: string | undefined;
|
|
63
|
+
created_at?: string | undefined;
|
|
64
|
+
maximum_amount?: string | undefined;
|
|
65
|
+
extented_status?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
status: string;
|
|
68
|
+
payment_agreement_id: string;
|
|
69
|
+
end_date?: string | undefined;
|
|
70
|
+
created_at?: string | undefined;
|
|
71
|
+
maximum_amount?: string | undefined;
|
|
72
|
+
extented_status?: string | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
export type PaymentAgreement = z.infer<typeof PaymentAgreementSchema>;
|
|
75
|
+
export declare const PaymentInitiationSchema: z.ZodObject<{
|
|
76
|
+
payment_initiation_id: z.ZodOptional<z.ZodString>;
|
|
77
|
+
status: z.ZodOptional<z.ZodString>;
|
|
78
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
79
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
80
|
+
payment_agreement_id: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
82
|
+
payment_initiation_id: z.ZodOptional<z.ZodString>;
|
|
83
|
+
status: z.ZodOptional<z.ZodString>;
|
|
84
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
85
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
86
|
+
payment_agreement_id: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
88
|
+
payment_initiation_id: z.ZodOptional<z.ZodString>;
|
|
89
|
+
status: z.ZodOptional<z.ZodString>;
|
|
90
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
91
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
92
|
+
payment_agreement_id: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
94
|
+
export type PaymentInitiation = z.infer<typeof PaymentInitiationSchema>;
|
|
95
|
+
export interface ApiResponse<T = any> {
|
|
96
|
+
message: string;
|
|
97
|
+
data: T;
|
|
98
|
+
error_code?: string;
|
|
99
|
+
}
|
|
100
|
+
export declare const GetPaymentAgreementInputSchema: z.ZodObject<{
|
|
101
|
+
payment_agreement_id: z.ZodString;
|
|
102
|
+
enrich: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
103
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
payment_agreement_id: string;
|
|
106
|
+
enrich: boolean;
|
|
107
|
+
include_raw: boolean;
|
|
108
|
+
}, {
|
|
109
|
+
payment_agreement_id: string;
|
|
110
|
+
enrich?: boolean | undefined;
|
|
111
|
+
include_raw?: boolean | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
export declare const CreatePaymentAgreementInputSchema: z.ZodObject<{
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
type: z.ZodString;
|
|
116
|
+
maximum_amount: z.ZodString;
|
|
117
|
+
frequency: z.ZodString;
|
|
118
|
+
number_of_transactions_permitted: z.ZodNumber;
|
|
119
|
+
pay_id: z.ZodString;
|
|
120
|
+
idempotency_key: z.ZodString;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
type: string;
|
|
123
|
+
maximum_amount: string;
|
|
124
|
+
name: string;
|
|
125
|
+
frequency: string;
|
|
126
|
+
number_of_transactions_permitted: number;
|
|
127
|
+
pay_id: string;
|
|
128
|
+
idempotency_key: string;
|
|
129
|
+
}, {
|
|
130
|
+
type: string;
|
|
131
|
+
maximum_amount: string;
|
|
132
|
+
name: string;
|
|
133
|
+
frequency: string;
|
|
134
|
+
number_of_transactions_permitted: number;
|
|
135
|
+
pay_id: string;
|
|
136
|
+
idempotency_key: string;
|
|
137
|
+
}>;
|
|
138
|
+
export declare const InitiatePaymentInputSchema: z.ZodObject<{
|
|
139
|
+
payment_agreement_id: z.ZodString;
|
|
140
|
+
amount: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string | number, string | number>;
|
|
141
|
+
description: z.ZodOptional<z.ZodString>;
|
|
142
|
+
enrich: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
143
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
144
|
+
idempotency_key: z.ZodString;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
payment_agreement_id: string;
|
|
147
|
+
amount: string | number;
|
|
148
|
+
enrich: boolean;
|
|
149
|
+
include_raw: boolean;
|
|
150
|
+
idempotency_key: string;
|
|
151
|
+
description?: string | undefined;
|
|
152
|
+
}, {
|
|
153
|
+
payment_agreement_id: string;
|
|
154
|
+
amount: string | number;
|
|
155
|
+
idempotency_key: string;
|
|
156
|
+
enrich?: boolean | undefined;
|
|
157
|
+
include_raw?: boolean | undefined;
|
|
158
|
+
description?: string | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
export declare const GetPaymentInitiationInputSchema: z.ZodObject<{
|
|
161
|
+
payment_initiation_id: z.ZodString;
|
|
162
|
+
enrich: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
163
|
+
include_raw: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
payment_initiation_id: string;
|
|
166
|
+
enrich: boolean;
|
|
167
|
+
include_raw: boolean;
|
|
168
|
+
}, {
|
|
169
|
+
payment_initiation_id: string;
|
|
170
|
+
enrich?: boolean | undefined;
|
|
171
|
+
include_raw?: boolean | undefined;
|
|
172
|
+
}>;
|
|
173
|
+
export declare const GetAuthTokenInputSchema: z.ZodObject<{
|
|
174
|
+
include_token_in_response: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
include_token_in_response: boolean;
|
|
177
|
+
}, {
|
|
178
|
+
include_token_in_response?: boolean | undefined;
|
|
179
|
+
}>;
|
|
180
|
+
export interface RateLimitInfo {
|
|
181
|
+
limit: number;
|
|
182
|
+
remaining: number;
|
|
183
|
+
reset: number;
|
|
184
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAuthTokenInputSchema = exports.GetPaymentInitiationInputSchema = exports.InitiatePaymentInputSchema = exports.CreatePaymentAgreementInputSchema = exports.GetPaymentAgreementInputSchema = exports.PaymentInitiationSchema = exports.PaymentAgreementSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// Payment Agreement Types
|
|
6
|
+
exports.PaymentAgreementSchema = zod_1.z.object({
|
|
7
|
+
payment_agreement_id: zod_1.z.string(),
|
|
8
|
+
status: zod_1.z.string(),
|
|
9
|
+
end_date: zod_1.z.string().optional(),
|
|
10
|
+
created_at: zod_1.z.string().optional(),
|
|
11
|
+
maximum_amount: zod_1.z.string().optional(),
|
|
12
|
+
extented_status: zod_1.z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
// Payment Initiation Types
|
|
15
|
+
exports.PaymentInitiationSchema = zod_1.z.object({
|
|
16
|
+
payment_initiation_id: zod_1.z.string().optional(),
|
|
17
|
+
status: zod_1.z.string().optional(),
|
|
18
|
+
amount: zod_1.z.string().optional(),
|
|
19
|
+
created_at: zod_1.z.string().optional(),
|
|
20
|
+
payment_agreement_id: zod_1.z.string().optional(),
|
|
21
|
+
}).passthrough();
|
|
22
|
+
// Tool input schemas
|
|
23
|
+
exports.GetPaymentAgreementInputSchema = zod_1.z.object({
|
|
24
|
+
payment_agreement_id: zod_1.z.string()
|
|
25
|
+
.describe('The payment agreement ID to retrieve'),
|
|
26
|
+
enrich: zod_1.z.boolean()
|
|
27
|
+
.optional()
|
|
28
|
+
.default(true)
|
|
29
|
+
.describe('If true include business enrichment such as readiness, customer copy, operational checks and references'),
|
|
30
|
+
include_raw: zod_1.z.boolean()
|
|
31
|
+
.optional()
|
|
32
|
+
.default(false)
|
|
33
|
+
.describe('Include raw API response for debugging'),
|
|
34
|
+
});
|
|
35
|
+
exports.CreatePaymentAgreementInputSchema = zod_1.z.object({
|
|
36
|
+
name: zod_1.z.string().describe('Payment agreement name'),
|
|
37
|
+
type: zod_1.z.string().describe('Payment agreement type, example email'),
|
|
38
|
+
maximum_amount: zod_1.z.string().describe('Maximum amount, example 10 or 10.00'),
|
|
39
|
+
frequency: zod_1.z.string().describe('Frequency, example WEEK'),
|
|
40
|
+
number_of_transactions_permitted: zod_1.z.number().describe('Number of transactions permitted, example 1'),
|
|
41
|
+
pay_id: zod_1.z.string().describe('PayID that will be charged, example sample@shabaas.com'),
|
|
42
|
+
idempotency_key: zod_1.z.string().min(8).describe('Required idempotency key for write operations'),
|
|
43
|
+
});
|
|
44
|
+
exports.InitiatePaymentInputSchema = zod_1.z.object({
|
|
45
|
+
payment_agreement_id: zod_1.z.string()
|
|
46
|
+
.describe('The payment agreement ID to charge'),
|
|
47
|
+
amount: zod_1.z.union([zod_1.z.string(), zod_1.z.number()])
|
|
48
|
+
.refine(val => Number(val) > 0, 'Amount must be greater than zero')
|
|
49
|
+
.describe('Amount to charge. Use a number (e.g. 50.00) or numeric string.'),
|
|
50
|
+
description: zod_1.z.string()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe('Payment description'),
|
|
53
|
+
enrich: zod_1.z.boolean()
|
|
54
|
+
.optional()
|
|
55
|
+
.default(true)
|
|
56
|
+
.describe('If true include PayTo context such as readiness, next actions, and reconciliation tips'),
|
|
57
|
+
include_raw: zod_1.z.boolean()
|
|
58
|
+
.optional()
|
|
59
|
+
.default(false)
|
|
60
|
+
.describe('Include raw API response for debugging'),
|
|
61
|
+
idempotency_key: zod_1.z.string().min(8).describe('Required idempotency key for write operations'),
|
|
62
|
+
});
|
|
63
|
+
// Payment initiation inputs
|
|
64
|
+
exports.GetPaymentInitiationInputSchema = zod_1.z.object({
|
|
65
|
+
payment_initiation_id: zod_1.z.string()
|
|
66
|
+
.describe('The payment initiation ID to retrieve'),
|
|
67
|
+
enrich: zod_1.z.boolean()
|
|
68
|
+
.optional()
|
|
69
|
+
.default(true)
|
|
70
|
+
.describe('If true include PayTo context such as readiness, next actions, and reconciliation tips'),
|
|
71
|
+
include_raw: zod_1.z.boolean()
|
|
72
|
+
.optional()
|
|
73
|
+
.default(false)
|
|
74
|
+
.describe('Include raw API response for debugging'),
|
|
75
|
+
});
|
|
76
|
+
// Auth inputs
|
|
77
|
+
exports.GetAuthTokenInputSchema = zod_1.z.object({
|
|
78
|
+
include_token_in_response: zod_1.z.boolean().optional().default(false)
|
|
79
|
+
.describe('If true, include the raw token string in the response data'),
|
|
80
|
+
});
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare Worker for ShaBaas Pay MCP Server
|
|
3
|
+
* Proxies requests to ShaBaas API with authentication and rate limiting
|
|
4
|
+
*/
|
|
5
|
+
interface Env {
|
|
6
|
+
SHABAAS_ENVIRONMENT: string;
|
|
7
|
+
ALLOWED_ORIGINS: string;
|
|
8
|
+
AUTH_TOKEN_MAX_AGE_MINUTES?: string;
|
|
9
|
+
POLICY_TABLE_JSON?: string;
|
|
10
|
+
[key: string]: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: {
|
|
13
|
+
fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|