@apipay.vn/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/README.md +185 -0
- package/dist/client.d.ts +34 -0
- package/dist/client.js +149 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +49 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +31 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/banks.d.ts +3 -0
- package/dist/tools/banks.js +38 -0
- package/dist/tools/banks.js.map +1 -0
- package/dist/tools/metrics.d.ts +3 -0
- package/dist/tools/metrics.js +145 -0
- package/dist/tools/metrics.js.map +1 -0
- package/dist/tools/payments.d.ts +3 -0
- package/dist/tools/payments.js +189 -0
- package/dist/tools/payments.js.map +1 -0
- package/dist/tools/self_test.d.ts +3 -0
- package/dist/tools/self_test.js +40 -0
- package/dist/tools/self_test.js.map +1 -0
- package/dist/tools/webhooks.d.ts +3 -0
- package/dist/tools/webhooks.js +230 -0
- package/dist/tools/webhooks.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# @apipay.vn/mcp
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for [ApiPay](https://apipay.vn) — bank-transfer payment gateway in Vietnam.
|
|
4
|
+
|
|
5
|
+
This server exposes tools for AI assistants (Claude Desktop, Cursor, Command Code, Codex) over stdio to create sandbox payments, list bank accounts and transactions, manage webhooks, and query transaction metrics.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node.js `>=18.0.0`
|
|
12
|
+
- An ApiPay account with API Keys (`ak_test_...` for sandbox or `ak_live_...` for production) from the [ApiPay Dashboard](https://my.apipay.vn)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Authentication & Configuration
|
|
17
|
+
|
|
18
|
+
The MCP server authenticates requests with Base64-encoded `accessKey:secretKey` (`Authorization: Bearer <base64>`).
|
|
19
|
+
|
|
20
|
+
Configuration is loaded in the following priority:
|
|
21
|
+
|
|
22
|
+
1. **Environment Variables**:
|
|
23
|
+
- `APIPAY_ACCESS_KEY`: Merchant Access Key (`ak_test_...` or `ak_live_...`)
|
|
24
|
+
- `APIPAY_SECRET_KEY`: Merchant Secret Key
|
|
25
|
+
- `APIPAY_API_URL`: (Optional) Base API URL (defaults to `https://app.apipay.vn/v1`)
|
|
26
|
+
2. **CLI Configuration Fallback**:
|
|
27
|
+
- If environment variables are missing, the server reads `~/.config/apipay/config.json` (the configuration file managed by `apipay login` or `apipay keys:create`).
|
|
28
|
+
|
|
29
|
+
> [!NOTE]
|
|
30
|
+
> The server will start even if credentials are not provided initially. Individual tools will return an error message prompting you to set credentials if called while unauthenticated.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Client Setup
|
|
35
|
+
|
|
36
|
+
### Claude Desktop
|
|
37
|
+
|
|
38
|
+
Add to `claude_desktop_config.json` (macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"apipay": {
|
|
44
|
+
"command": "npx",
|
|
45
|
+
"args": ["-y", "@apipay.vn/mcp"],
|
|
46
|
+
"env": {
|
|
47
|
+
"APIPAY_ACCESS_KEY": "ak_test_your_access_key",
|
|
48
|
+
"APIPAY_SECRET_KEY": "your_secret_key"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Cursor
|
|
56
|
+
|
|
57
|
+
In Cursor Settings → Features → MCP:
|
|
58
|
+
|
|
59
|
+
- **Name**: `apipay`
|
|
60
|
+
- **Type**: `stdio`
|
|
61
|
+
- **Command**: `npx -y @apipay.vn/mcp`
|
|
62
|
+
- **Environment Variables**:
|
|
63
|
+
- `APIPAY_ACCESS_KEY`: `ak_test_your_access_key`
|
|
64
|
+
- `APIPAY_SECRET_KEY`: `your_secret_key`
|
|
65
|
+
|
|
66
|
+
Or in `.cursor/mcp.json`:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"apipay": {
|
|
72
|
+
"command": "npx",
|
|
73
|
+
"args": ["-y", "@apipay.vn/mcp"],
|
|
74
|
+
"env": {
|
|
75
|
+
"APIPAY_ACCESS_KEY": "ak_test_your_access_key",
|
|
76
|
+
"APIPAY_SECRET_KEY": "your_secret_key"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Command Code
|
|
84
|
+
|
|
85
|
+
Using the CLI:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
grok mcp add apipay -e APIPAY_ACCESS_KEY=ak_test_your_access_key -e APIPAY_SECRET_KEY=your_secret_key -- npx -y @apipay.vn/mcp
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Or configure via JSON settings:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcp": {
|
|
96
|
+
"servers": {
|
|
97
|
+
"apipay": {
|
|
98
|
+
"command": "npx",
|
|
99
|
+
"args": ["-y", "@apipay.vn/mcp"],
|
|
100
|
+
"env": {
|
|
101
|
+
"APIPAY_ACCESS_KEY": "ak_test_your_access_key",
|
|
102
|
+
"APIPAY_SECRET_KEY": "your_secret_key"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Available Tools
|
|
113
|
+
|
|
114
|
+
The server registers 15 tools with the `apipay_` prefix:
|
|
115
|
+
|
|
116
|
+
### Connection & Verification
|
|
117
|
+
- `apipay_self_test`: Validates API key configuration and returns connection status, key prefix, and bank summary counts.
|
|
118
|
+
|
|
119
|
+
### Banks
|
|
120
|
+
- `apipay_list_banks`: Lists connected bank accounts for this merchant (returns `bankPublicId` values needed to create payments and webhooks).
|
|
121
|
+
|
|
122
|
+
### Payment Requests
|
|
123
|
+
- `apipay_create_payment`: Creates a payment link (requires `bankPublicId`; optional `amount`, `content`, `title`, `expiresAt`, `redirectUrl`).
|
|
124
|
+
- `apipay_list_payments`: Lists payment requests with optional filtering by status, search term, or date range.
|
|
125
|
+
- `apipay_cancel_payment`: **(Destructive)** Cancels an `ACTIVE` payment request.
|
|
126
|
+
- `apipay_simulate_payment`: Simulates payment for sandbox requests (publicId must start with `test_pr_`; triggers sandbox webhooks).
|
|
127
|
+
|
|
128
|
+
### Webhooks
|
|
129
|
+
- `apipay_list_webhooks`: Lists registered webhook endpoints.
|
|
130
|
+
- `apipay_create_webhook`: Registers a webhook URL for a connected bank account.
|
|
131
|
+
- `apipay_update_webhook`: Updates destination URL for a webhook.
|
|
132
|
+
- `apipay_toggle_webhook`: Toggles a webhook between active and inactive.
|
|
133
|
+
- `apipay_remove_webhook`: **(Destructive)** Permanently deletes a webhook.
|
|
134
|
+
- `apipay_list_webhook_deliveries`: Lists webhook delivery attempts and status logs.
|
|
135
|
+
- `apipay_resend_webhook`: Retries a failed webhook delivery (fires a real HTTP request to destination).
|
|
136
|
+
|
|
137
|
+
### Metrics & Transactions
|
|
138
|
+
- `apipay_get_overview`: Returns transaction totals, averages, success rates, and bank volume distribution.
|
|
139
|
+
- `apipay_list_transactions`: Lists recent bank transactions with pagination, date, bank, and search filters.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Typical Sandbox Workflow
|
|
144
|
+
|
|
145
|
+
1. **Verify Connection**:
|
|
146
|
+
Call `apipay_self_test` to confirm the API key is active.
|
|
147
|
+
2. **Find Connected Bank**:
|
|
148
|
+
Call `apipay_list_banks` to get a `bankPublicId`.
|
|
149
|
+
3. **Create Payment Request**:
|
|
150
|
+
Call `apipay_create_payment` with `bankPublicId` and `amount` (e.g. `"50000"`). A `publicId` starting with `test_pr_...` is returned.
|
|
151
|
+
4. **Simulate Customer Payment**:
|
|
152
|
+
Call `apipay_simulate_payment` with `publicId: "test_pr_..."` to test the settlement and webhook flow.
|
|
153
|
+
5. **Check History & Deliveries**:
|
|
154
|
+
Call `apipay_list_webhook_deliveries` and `apipay_list_transactions` to verify the transaction was recorded.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Destructive Tools Notice
|
|
159
|
+
|
|
160
|
+
The following operations permanently change state or remove resources:
|
|
161
|
+
- `apipay_cancel_payment`: Cancels an active payment link.
|
|
162
|
+
- `apipay_remove_webhook`: Deletes a registered webhook URL.
|
|
163
|
+
- `apipay_resend_webhook`: Dispatches an outbound HTTP request to the merchant webhook URL.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Development & Testing
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Install dependencies
|
|
171
|
+
npm install
|
|
172
|
+
|
|
173
|
+
# Run unit tests
|
|
174
|
+
npm test
|
|
175
|
+
|
|
176
|
+
# Build TypeScript to dist/
|
|
177
|
+
npm run build
|
|
178
|
+
|
|
179
|
+
# Start local server over stdio
|
|
180
|
+
npm start
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## License
|
|
184
|
+
|
|
185
|
+
MIT © [ApiPay](https://apipay.vn)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare class ApiError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
body: any;
|
|
4
|
+
constructor(statusCode: number, body: any);
|
|
5
|
+
}
|
|
6
|
+
export declare class CredentialsError extends Error {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export interface RequestOptions {
|
|
10
|
+
body?: any;
|
|
11
|
+
auth?: boolean;
|
|
12
|
+
retries?: number;
|
|
13
|
+
query?: Record<string, any>;
|
|
14
|
+
}
|
|
15
|
+
export declare class ApiClient {
|
|
16
|
+
private baseUrl;
|
|
17
|
+
private accessKey?;
|
|
18
|
+
private secretKey?;
|
|
19
|
+
constructor(options: {
|
|
20
|
+
baseUrl: string;
|
|
21
|
+
accessKey?: string;
|
|
22
|
+
secretKey?: string;
|
|
23
|
+
});
|
|
24
|
+
hasCredentials(): boolean;
|
|
25
|
+
getAccessKeyPrefix(): string | undefined;
|
|
26
|
+
getBaseUrl(): string;
|
|
27
|
+
private buildUrl;
|
|
28
|
+
private getHeaders;
|
|
29
|
+
request<T = any>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
30
|
+
get<T = any>(path: string, options?: Omit<RequestOptions, "body">): Promise<T>;
|
|
31
|
+
post<T = any>(path: string, body?: any, options?: Omit<RequestOptions, "body">): Promise<T>;
|
|
32
|
+
patch<T = any>(path: string, body?: any, options?: Omit<RequestOptions, "body">): Promise<T>;
|
|
33
|
+
delete<T = any>(path: string, options?: Omit<RequestOptions, "body">): Promise<T>;
|
|
34
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export class ApiError extends Error {
|
|
2
|
+
statusCode;
|
|
3
|
+
body;
|
|
4
|
+
constructor(statusCode, body) {
|
|
5
|
+
const msg = typeof body?.message === "string"
|
|
6
|
+
? body.message
|
|
7
|
+
: typeof body?.data?.message === "string"
|
|
8
|
+
? body.data.message
|
|
9
|
+
: typeof body?.error === "string"
|
|
10
|
+
? body.error
|
|
11
|
+
: `API request failed with status ${statusCode}`;
|
|
12
|
+
super(msg);
|
|
13
|
+
this.statusCode = statusCode;
|
|
14
|
+
this.body = body;
|
|
15
|
+
this.name = "ApiError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class CredentialsError extends Error {
|
|
19
|
+
constructor(message = "ApiPay API credentials are required. Set APIPAY_ACCESS_KEY and APIPAY_SECRET_KEY environment variables or configure via ~/.config/apipay/config.json.") {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "CredentialsError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class ApiClient {
|
|
25
|
+
baseUrl;
|
|
26
|
+
accessKey;
|
|
27
|
+
secretKey;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
30
|
+
this.accessKey = options.accessKey;
|
|
31
|
+
this.secretKey = options.secretKey;
|
|
32
|
+
}
|
|
33
|
+
hasCredentials() {
|
|
34
|
+
return !!(this.accessKey && this.secretKey);
|
|
35
|
+
}
|
|
36
|
+
getAccessKeyPrefix() {
|
|
37
|
+
if (!this.accessKey)
|
|
38
|
+
return undefined;
|
|
39
|
+
if (this.accessKey.startsWith("ak_test_"))
|
|
40
|
+
return "ak_test_";
|
|
41
|
+
if (this.accessKey.startsWith("ak_live_"))
|
|
42
|
+
return "ak_live_";
|
|
43
|
+
return this.accessKey.slice(0, 8);
|
|
44
|
+
}
|
|
45
|
+
getBaseUrl() {
|
|
46
|
+
return this.baseUrl;
|
|
47
|
+
}
|
|
48
|
+
buildUrl(path, query) {
|
|
49
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
50
|
+
const url = new URL(`${this.baseUrl}${normalizedPath}`);
|
|
51
|
+
if (query) {
|
|
52
|
+
for (const [key, value] of Object.entries(query)) {
|
|
53
|
+
if (value === undefined || value === null)
|
|
54
|
+
continue;
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
for (const item of value) {
|
|
57
|
+
if (item !== undefined && item !== null) {
|
|
58
|
+
url.searchParams.append(key, String(item));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
url.searchParams.append(key, String(value));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return url.toString();
|
|
68
|
+
}
|
|
69
|
+
getHeaders(auth = true, hasBody = false) {
|
|
70
|
+
const headers = {
|
|
71
|
+
Accept: "application/json",
|
|
72
|
+
};
|
|
73
|
+
if (hasBody) {
|
|
74
|
+
headers["Content-Type"] = "application/json";
|
|
75
|
+
}
|
|
76
|
+
if (auth) {
|
|
77
|
+
if (!this.accessKey || !this.secretKey) {
|
|
78
|
+
throw new CredentialsError();
|
|
79
|
+
}
|
|
80
|
+
const encoded = Buffer.from(`${this.accessKey}:${this.secretKey}`).toString("base64");
|
|
81
|
+
headers["Authorization"] = `Bearer ${encoded}`;
|
|
82
|
+
}
|
|
83
|
+
return headers;
|
|
84
|
+
}
|
|
85
|
+
async request(method, path, options = {}) {
|
|
86
|
+
const { body, auth = true, retries = 3, query } = options;
|
|
87
|
+
const url = this.buildUrl(path, query);
|
|
88
|
+
if (auth && !this.hasCredentials()) {
|
|
89
|
+
throw new CredentialsError();
|
|
90
|
+
}
|
|
91
|
+
let lastError = null;
|
|
92
|
+
const retryDelayMs = 1000;
|
|
93
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
94
|
+
try {
|
|
95
|
+
const headers = this.getHeaders(auth, !!body);
|
|
96
|
+
const res = await fetch(url, {
|
|
97
|
+
method,
|
|
98
|
+
headers,
|
|
99
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
100
|
+
});
|
|
101
|
+
let json = null;
|
|
102
|
+
const text = await res.text();
|
|
103
|
+
if (text) {
|
|
104
|
+
try {
|
|
105
|
+
json = JSON.parse(text);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
json = { message: text };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!res.ok) {
|
|
112
|
+
throw new ApiError(res.status, json);
|
|
113
|
+
}
|
|
114
|
+
return (json?.data !== undefined ? json.data : json);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
lastError = error;
|
|
118
|
+
if (error instanceof CredentialsError) {
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
if (error instanceof ApiError) {
|
|
122
|
+
if (error.statusCode >= 400 &&
|
|
123
|
+
error.statusCode < 500 &&
|
|
124
|
+
error.statusCode !== 429) {
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (attempt < retries) {
|
|
129
|
+
const delay = retryDelayMs * Math.pow(2, attempt);
|
|
130
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
throw lastError ?? new Error("Request failed");
|
|
135
|
+
}
|
|
136
|
+
get(path, options = {}) {
|
|
137
|
+
return this.request("GET", path, options);
|
|
138
|
+
}
|
|
139
|
+
post(path, body, options = {}) {
|
|
140
|
+
return this.request("POST", path, { ...options, body });
|
|
141
|
+
}
|
|
142
|
+
patch(path, body, options = {}) {
|
|
143
|
+
return this.request("PATCH", path, { ...options, body });
|
|
144
|
+
}
|
|
145
|
+
delete(path, options = {}) {
|
|
146
|
+
return this.request("DELETE", path, options);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAExB;IACA;IAFT,YACS,UAAkB,EAClB,IAAS;QAEhB,MAAM,GAAG,GACP,OAAO,IAAI,EAAE,OAAO,KAAK,QAAQ;YAC/B,CAAC,CAAC,IAAI,CAAC,OAAO;YACd,CAAC,CAAC,OAAO,IAAI,EAAE,IAAI,EAAE,OAAO,KAAK,QAAQ;gBACvC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;gBACnB,CAAC,CAAC,OAAO,IAAI,EAAE,KAAK,KAAK,QAAQ;oBAC/B,C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I,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACjD,CAAC;IAED,GAAG,CAAU,IAAY,EAAE,UAAwC,EAAE;QACnE,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,CAAU,IAAY,EAAE,IAAU,EAAE,UAAwC,EAAE;QAChF,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAU,IAAY,EAAE,IAAU,EAAE,UAAwC,EAAE;QACjF,OAAO,IAAI,CAAC,OAAO,CAAI,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAU,IAAY,EAAE,UAAwC,EAAE;QACtE,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACF"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
accessKey?: string;
|
|
4
|
+
secretKey?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function normalizeBaseUrl(url: string): string;
|
|
7
|
+
export declare function getDefaultConfigFilePath(): string;
|
|
8
|
+
export declare function readCliConfigFile(filePath?: string): {
|
|
9
|
+
accessKey?: string;
|
|
10
|
+
secretKey?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function loadConfig(env?: NodeJS.ProcessEnv, customConfigPath?: string): Config;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
export function normalizeBaseUrl(url) {
|
|
5
|
+
const cleanUrl = url.replace(/\/+$/, "");
|
|
6
|
+
if (/\/v[12]$/.test(cleanUrl)) {
|
|
7
|
+
return cleanUrl.replace(/\/v[12]$/, "/v1");
|
|
8
|
+
}
|
|
9
|
+
return `${cleanUrl}/v1`;
|
|
10
|
+
}
|
|
11
|
+
export function getDefaultConfigFilePath() {
|
|
12
|
+
return path.join(os.homedir(), ".config", "apipay", "config.json");
|
|
13
|
+
}
|
|
14
|
+
export function readCliConfigFile(filePath) {
|
|
15
|
+
try {
|
|
16
|
+
const file = filePath ?? getDefaultConfigFilePath();
|
|
17
|
+
if (fs.existsSync(file)) {
|
|
18
|
+
const content = fs.readFileSync(file, "utf8");
|
|
19
|
+
const parsed = JSON.parse(content);
|
|
20
|
+
if (parsed?.apiKey?.accessKey && parsed?.apiKey?.secretKey) {
|
|
21
|
+
return {
|
|
22
|
+
accessKey: parsed.apiKey.accessKey,
|
|
23
|
+
secretKey: parsed.apiKey.secretKey,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// missing/corrupt CLI config must not prevent startup
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
export function loadConfig(env = process.env, customConfigPath) {
|
|
34
|
+
const rawBaseUrl = env.APIPAY_API_URL || "https://app.apipay.vn/v1";
|
|
35
|
+
const baseUrl = normalizeBaseUrl(rawBaseUrl);
|
|
36
|
+
let accessKey = env.APIPAY_ACCESS_KEY;
|
|
37
|
+
let secretKey = env.APIPAY_SECRET_KEY;
|
|
38
|
+
if (!accessKey || !secretKey) {
|
|
39
|
+
const cliKey = readCliConfigFile(customConfigPath);
|
|
40
|
+
accessKey = accessKey || cliKey.accessKey;
|
|
41
|
+
secretKey = secretKey || cliKey.secretKey;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
baseUrl,
|
|
45
|
+
accessKey: accessKey || undefined,
|
|
46
|
+
secretKey: secretKey || undefined,
|
|
47
|
+
};
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ACnC,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sDAAsD;IACxD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,gBAAyB;IACrE,MAAM,UAAU,GAAG,GAAG,CAAC,cAAc,IAAI,0BAA0B,CAAC;IACpE,MAAM,OAAO,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAE7C,IAAI,SAAS,GAAG,GAAG,CAAC,iBAAiB,CAAC;IACtC,IAAI,SAAS,GAAG,GAAG,CAAC,iBAAiB,CAAC;IAEtC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;QACnD,SAAS,GAAG,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC;QAC1C,SAAS,GAAG,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC;IAC5C,CAAC;IAED,OAAO;QACL,OAAO;QACP,SAAS,EAAE,SAAS,IAAI,SAAS;QACjC,SAAS,EAAE,SAAS,IAAI,SAAS;KAClC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createServer } from "./server.js";
|
|
4
|
+
const server = createServer();
|
|
5
|
+
const transport = new StdioServerTransport();
|
|
6
|
+
await server.connect(transport);
|
|
7
|
+
console.error("apipay-mcp listening on stdio");
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;AAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAChC,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC"}
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { ApiClient } from "./client.js";
|
|
3
|
+
import { loadConfig } from "./config.js";
|
|
4
|
+
import { registerBanksTools } from "./tools/banks.js";
|
|
5
|
+
import { registerMetricsTools } from "./tools/metrics.js";
|
|
6
|
+
import { registerPaymentsTools } from "./tools/payments.js";
|
|
7
|
+
import { registerSelfTestTools } from "./tools/self_test.js";
|
|
8
|
+
import { registerWebhooksTools } from "./tools/webhooks.js";
|
|
9
|
+
export function createServer(configOverride) {
|
|
10
|
+
const baseConfig = loadConfig();
|
|
11
|
+
const config = {
|
|
12
|
+
...baseConfig,
|
|
13
|
+
...configOverride,
|
|
14
|
+
};
|
|
15
|
+
const client = new ApiClient({
|
|
16
|
+
baseUrl: config.baseUrl,
|
|
17
|
+
accessKey: config.accessKey,
|
|
18
|
+
secretKey: config.secretKey,
|
|
19
|
+
});
|
|
20
|
+
const server = new McpServer({
|
|
21
|
+
name: "apipay",
|
|
22
|
+
version: "0.1.0",
|
|
23
|
+
});
|
|
24
|
+
registerSelfTestTools(server, client);
|
|
25
|
+
registerBanksTools(server, client);
|
|
26
|
+
registerPaymentsTools(server, client);
|
|
27
|
+
registerWebhooksTools(server, client);
|
|
28
|
+
registerMetricsTools(server, client);
|
|
29
|
+
return server;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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import { z } from "zod";
|
|
2
|
+
import { ApiError } from "../client.js";
|
|
3
|
+
export function registerBanksTools(server, client) {
|
|
4
|
+
server.registerTool("apipay_list_banks", {
|
|
5
|
+
description: "List connected bank accounts for this merchant. Call this to find bankPublicId before creating payments or webhooks.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
page: z.number().int().min(1).optional().describe("Page number for pagination (starts at 1)"),
|
|
8
|
+
limit: z.number().int().min(1).max(50).optional().describe("Number of bank accounts per page (max 50)"),
|
|
9
|
+
},
|
|
10
|
+
}, async ({ page, limit }) => {
|
|
11
|
+
try {
|
|
12
|
+
const query = {};
|
|
13
|
+
if (page !== undefined)
|
|
14
|
+
query.page = page;
|
|
15
|
+
if (limit !== undefined)
|
|
16
|
+
query.limit = limit;
|
|
17
|
+
const data = await client.get("/client/banks", { query });
|
|
18
|
+
const banks = Array.isArray(data)
|
|
19
|
+
? data
|
|
20
|
+
: (data?.message ?? data?.data ?? data);
|
|
21
|
+
const pagination = Array.isArray(data) ? undefined : data?.pagination;
|
|
22
|
+
const payload = pagination === undefined ? { banks } : { banks, pagination };
|
|
23
|
+
return {
|
|
24
|
+
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
const message = err instanceof ApiError
|
|
29
|
+
? `${err.statusCode}: ${err.message}`
|
|
30
|
+
: String(err);
|
|
31
|
+
return {
|
|
32
|
+
content: [{ type: "text", text: message }],
|
|
33
|
+
isError: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=banks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banks.js","sourceRoot":"","sources":["../../src/tools/banks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;A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KAAK,EAAE,UAAU,EAAE,CAAC;YAE/D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACpE,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GACX,GAAG,YAAY,QAAQ;gBACrB,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBAC1C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiError } from "../client.js";
|
|
3
|
+
const PERIOD_ENUM = [
|
|
4
|
+
"today",
|
|
5
|
+
"this_week",
|
|
6
|
+
"last_week",
|
|
7
|
+
"this_month",
|
|
8
|
+
"last_month",
|
|
9
|
+
"last_3_months",
|
|
10
|
+
"last_6_months",
|
|
11
|
+
"this_year",
|
|
12
|
+
"custom",
|
|
13
|
+
];
|
|
14
|
+
export function registerMetricsTools(server, client) {
|
|
15
|
+
server.registerTool("apipay_get_overview", {
|
|
16
|
+
description: "Get transaction metrics overview (totals, averages, success rates, volume by bank).",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
period: z
|
|
19
|
+
.enum(PERIOD_ENUM)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Time period for metrics"),
|
|
22
|
+
dateFrom: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Start date for custom period (YYYY-MM-DD or ISO 8601)"),
|
|
26
|
+
dateTo: z
|
|
27
|
+
.string()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("End date for custom period (YYYY-MM-DD or ISO 8601)"),
|
|
30
|
+
},
|
|
31
|
+
}, async (args) => {
|
|
32
|
+
try {
|
|
33
|
+
const query = {};
|
|
34
|
+
if (args.period !== undefined)
|
|
35
|
+
query.period = args.period;
|
|
36
|
+
if (args.dateFrom !== undefined)
|
|
37
|
+
query.dateFrom = args.dateFrom;
|
|
38
|
+
if (args.dateTo !== undefined)
|
|
39
|
+
query.dateTo = args.dateTo;
|
|
40
|
+
const data = await client.get("/client/metrics/overview", { query });
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
const message = err instanceof ApiError
|
|
47
|
+
? `${err.statusCode}: ${err.message}`
|
|
48
|
+
: String(err);
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: message }],
|
|
51
|
+
isError: true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
server.registerTool("apipay_list_transactions", {
|
|
56
|
+
description: "List recent bank transactions with filtering by date, bank, account, or search keyword.",
|
|
57
|
+
inputSchema: {
|
|
58
|
+
page: z
|
|
59
|
+
.number()
|
|
60
|
+
.int()
|
|
61
|
+
.min(1)
|
|
62
|
+
.optional()
|
|
63
|
+
.default(1)
|
|
64
|
+
.describe("Page number (default 1)"),
|
|
65
|
+
limit: z
|
|
66
|
+
.number()
|
|
67
|
+
.int()
|
|
68
|
+
.min(1)
|
|
69
|
+
.max(100)
|
|
70
|
+
.optional()
|
|
71
|
+
.default(20)
|
|
72
|
+
.describe("Items per page (default 20, max 100)"),
|
|
73
|
+
period: z
|
|
74
|
+
.enum(PERIOD_ENUM)
|
|
75
|
+
.optional()
|
|
76
|
+
.describe("Time period filter"),
|
|
77
|
+
dateFrom: z
|
|
78
|
+
.string()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe("Start date (YYYY-MM-DD or ISO 8601)"),
|
|
81
|
+
dateTo: z
|
|
82
|
+
.string()
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("End date (YYYY-MM-DD or ISO 8601)"),
|
|
85
|
+
search: z
|
|
86
|
+
.string()
|
|
87
|
+
.optional()
|
|
88
|
+
.describe("Search transactions by keyword"),
|
|
89
|
+
accountNumber: z
|
|
90
|
+
.string()
|
|
91
|
+
.optional()
|
|
92
|
+
.describe("Filter by bank account number"),
|
|
93
|
+
bankPublicId: z
|
|
94
|
+
.union([z.string(), z.array(z.string())])
|
|
95
|
+
.optional()
|
|
96
|
+
.describe("Filter by bank public ID(s)"),
|
|
97
|
+
sortBy: z
|
|
98
|
+
.enum(["transactionDate", "amount", "createdAt"])
|
|
99
|
+
.optional()
|
|
100
|
+
.describe("Sort field"),
|
|
101
|
+
sortOrder: z
|
|
102
|
+
.enum(["asc", "desc"])
|
|
103
|
+
.optional()
|
|
104
|
+
.describe("Sort direction (asc or desc)"),
|
|
105
|
+
},
|
|
106
|
+
}, async (args) => {
|
|
107
|
+
try {
|
|
108
|
+
const query = {};
|
|
109
|
+
if (args.page !== undefined)
|
|
110
|
+
query.page = args.page;
|
|
111
|
+
if (args.limit !== undefined)
|
|
112
|
+
query.limit = args.limit;
|
|
113
|
+
if (args.period !== undefined)
|
|
114
|
+
query.period = args.period;
|
|
115
|
+
if (args.dateFrom !== undefined)
|
|
116
|
+
query.dateFrom = args.dateFrom;
|
|
117
|
+
if (args.dateTo !== undefined)
|
|
118
|
+
query.dateTo = args.dateTo;
|
|
119
|
+
if (args.search !== undefined)
|
|
120
|
+
query.search = args.search;
|
|
121
|
+
if (args.accountNumber !== undefined)
|
|
122
|
+
query.accountNumber = args.accountNumber;
|
|
123
|
+
if (args.bankPublicId !== undefined)
|
|
124
|
+
query.bankPublicId = args.bankPublicId;
|
|
125
|
+
if (args.sortBy !== undefined)
|
|
126
|
+
query.sortBy = args.sortBy;
|
|
127
|
+
if (args.sortOrder !== undefined)
|
|
128
|
+
query.sortOrder = args.sortOrder;
|
|
129
|
+
const data = await client.get("/client/metrics/transactions", { query });
|
|
130
|
+
return {
|
|
131
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
const message = err instanceof ApiError
|
|
136
|
+
? `${err.statusCode}: ${err.message}`
|
|
137
|
+
: String(err);
|
|
138
|
+
return {
|
|
139
|
+
content: [{ type: "text", text: message }],
|
|
140
|
+
isError: true,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/tools/metrics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,WAAW,GAAG;IAClB,OAAO;IACP,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,eAAe;IACf,WAAW;IACX,QAAQ;CACA,CAAC;AAEX,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,MAAiB;IACvE,MAAM,CAAC,YAAY,CACjB,qBAAqB,EACrB;QACE,WAAW,EACT,qFAAqF;QACvF,WAAW,EAAE;YACX,MAAM,EAAE,CAAC;iBACN,IAAI,CAAC,WAAW,CAAC;iBACjB,QAAQ,EAAE;iBACV,QAAQ,CAAC,yBAAyB,CAAC;YACtC,QAAQ,EAAE,CAAC;iBACR,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,uDAAuD,CAAC;YACpE,MAAM,EAAE,CAAC;iBACN,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,qDAAqD,CAAC;SAC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I,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACjE,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GACX,GAAG,YAAY,QAAQ;gBACrB,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBAC1C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiError } from "../client.js";
|
|
3
|
+
export function registerPaymentsTools(server, client) {
|
|
4
|
+
server.registerTool("apipay_create_payment", {
|
|
5
|
+
description: "Create a payment link (payment request). Call list_banks first if bankPublicId is unknown.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
bankPublicId: z
|
|
8
|
+
.string()
|
|
9
|
+
.describe("Public ID of the connected bank account. Call list_banks first if bankPublicId is unknown."),
|
|
10
|
+
amount: z
|
|
11
|
+
.union([z.string(), z.number()])
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Amount in VND as an integer or integer string (1–300000000). Omit to let the payer enter the amount."),
|
|
14
|
+
content: z
|
|
15
|
+
.string()
|
|
16
|
+
.max(140)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("Transfer memo / content (max 140 chars)"),
|
|
19
|
+
title: z
|
|
20
|
+
.string()
|
|
21
|
+
.max(200)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Title displayed on payment page (max 200 chars)"),
|
|
24
|
+
expiresAt: z
|
|
25
|
+
.string()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Expiration ISO 8601 date-time string. Omit for no expiry."),
|
|
28
|
+
redirectUrl: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("HTTPS URL to redirect after payment completion"),
|
|
32
|
+
},
|
|
33
|
+
}, async (args) => {
|
|
34
|
+
try {
|
|
35
|
+
const body = {
|
|
36
|
+
bankPublicId: args.bankPublicId,
|
|
37
|
+
};
|
|
38
|
+
if (args.amount !== undefined)
|
|
39
|
+
body.amount = String(args.amount);
|
|
40
|
+
if (args.content !== undefined)
|
|
41
|
+
body.content = args.content;
|
|
42
|
+
if (args.title !== undefined)
|
|
43
|
+
body.title = args.title;
|
|
44
|
+
if (args.expiresAt !== undefined)
|
|
45
|
+
body.expiresAt = args.expiresAt;
|
|
46
|
+
if (args.redirectUrl !== undefined)
|
|
47
|
+
body.redirectUrl = args.redirectUrl;
|
|
48
|
+
const data = await client.post("/client/payment-requests", body);
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
const message = err instanceof ApiError
|
|
55
|
+
? `${err.statusCode}: ${err.message}`
|
|
56
|
+
: String(err);
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: "text", text: message }],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
server.registerTool("apipay_list_payments", {
|
|
64
|
+
description: "List payment requests with optional filtering by status, date range, or search keyword.",
|
|
65
|
+
inputSchema: {
|
|
66
|
+
page: z
|
|
67
|
+
.number()
|
|
68
|
+
.int()
|
|
69
|
+
.min(1)
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Page number for pagination (starts at 1)"),
|
|
72
|
+
limit: z
|
|
73
|
+
.number()
|
|
74
|
+
.int()
|
|
75
|
+
.min(1)
|
|
76
|
+
.max(100)
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Number of items per page (max 100)"),
|
|
79
|
+
search: z
|
|
80
|
+
.string()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Search by public ID, content, title, or account number"),
|
|
83
|
+
status: z
|
|
84
|
+
.union([
|
|
85
|
+
z.enum(["ACTIVE", "EXPIRED", "COMPLETED", "CANCELLED"]),
|
|
86
|
+
z.array(z.enum(["ACTIVE", "EXPIRED", "COMPLETED", "CANCELLED"])),
|
|
87
|
+
])
|
|
88
|
+
.optional()
|
|
89
|
+
.describe("Filter by payment request status"),
|
|
90
|
+
dateFrom: z
|
|
91
|
+
.string()
|
|
92
|
+
.optional()
|
|
93
|
+
.describe("Filter by start date (YYYY-MM-DD or ISO 8601)"),
|
|
94
|
+
dateTo: z
|
|
95
|
+
.string()
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Filter by end date (YYYY-MM-DD or ISO 8601)"),
|
|
98
|
+
},
|
|
99
|
+
}, async (args) => {
|
|
100
|
+
try {
|
|
101
|
+
const query = {};
|
|
102
|
+
if (args.page !== undefined)
|
|
103
|
+
query.page = args.page;
|
|
104
|
+
if (args.limit !== undefined)
|
|
105
|
+
query.limit = args.limit;
|
|
106
|
+
if (args.search !== undefined)
|
|
107
|
+
query.search = args.search;
|
|
108
|
+
if (args.status !== undefined)
|
|
109
|
+
query.status = args.status;
|
|
110
|
+
if (args.dateFrom !== undefined)
|
|
111
|
+
query.dateFrom = args.dateFrom;
|
|
112
|
+
if (args.dateTo !== undefined)
|
|
113
|
+
query.dateTo = args.dateTo;
|
|
114
|
+
const data = await client.get("/client/payment-requests", { query });
|
|
115
|
+
return {
|
|
116
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
const message = err instanceof ApiError
|
|
121
|
+
? `${err.statusCode}: ${err.message}`
|
|
122
|
+
: String(err);
|
|
123
|
+
return {
|
|
124
|
+
content: [{ type: "text", text: message }],
|
|
125
|
+
isError: true,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
server.registerTool("apipay_cancel_payment", {
|
|
130
|
+
description: "Cancel an ACTIVE payment request (destructive, only ACTIVE requests can be cancelled).",
|
|
131
|
+
inputSchema: {
|
|
132
|
+
publicId: z
|
|
133
|
+
.string()
|
|
134
|
+
.describe("Public ID of the payment request to cancel"),
|
|
135
|
+
},
|
|
136
|
+
}, async ({ publicId }) => {
|
|
137
|
+
try {
|
|
138
|
+
const data = await client.delete(`/client/payment-requests/${publicId}`);
|
|
139
|
+
return {
|
|
140
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
const message = err instanceof ApiError
|
|
145
|
+
? `${err.statusCode}: ${err.message}`
|
|
146
|
+
: String(err);
|
|
147
|
+
return {
|
|
148
|
+
content: [{ type: "text", text: message }],
|
|
149
|
+
isError: true,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
server.registerTool("apipay_simulate_payment", {
|
|
154
|
+
description: "Simulate a payment for sandbox testing (sandbox only; publicId must start with test_pr_; creates webhook with sandbox: true).",
|
|
155
|
+
inputSchema: {
|
|
156
|
+
publicId: z
|
|
157
|
+
.string()
|
|
158
|
+
.describe("Sandbox payment request public ID (must start with test_pr_)"),
|
|
159
|
+
},
|
|
160
|
+
}, async ({ publicId }) => {
|
|
161
|
+
if (!publicId.startsWith("test_pr_")) {
|
|
162
|
+
return {
|
|
163
|
+
content: [
|
|
164
|
+
{
|
|
165
|
+
type: "text",
|
|
166
|
+
text: "Invalid payment request ID: simulate_payment is only available for sandbox requests starting with 'test_pr_'.",
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
isError: true,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
const data = await client.post(`/payment-requests/${publicId}/pay`, undefined, { auth: false });
|
|
174
|
+
return {
|
|
175
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
const message = err instanceof ApiError
|
|
180
|
+
? `${err.statusCode}: ${err.message}`
|
|
181
|
+
: String(err);
|
|
182
|
+
return {
|
|
183
|
+
content: [{ type: "text", text: message }],
|
|
184
|
+
isError: true,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=payments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/tools/payments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAiB;IACxE,MAAM,CAAC,YAAY,CACjB,uBAAuB,EACvB;QACE,WAAW,EACT,4FAA4F;QAC9F,WAAW,EAAE;YACX,YAAY,EAAE,CAAC;iBACZ,MAAM,EAAE;iBACR,QAAQ,CACP,4FAA4F,CAC7F;YACH,MAAM,EAAE,CAAC;iBACN,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;iBAC/B,QAAQ,EAAE;iBACV,QAAQ,CACP,sGAAsG,CACvG;YACH,OAAO,EAAE,CAAC;iBACP,MAAM,EAAE;iBACR,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,yCAAyC,CAAC;YACtD,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,iDAAiD,CAAC;YAC9D,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,QAAQ,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;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,+GAA+G;qBACtH;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAC5B,qBAAqB,QAAQ,MAAM,EACnC,SAAS,EACT,EAAE,IAAI,EAAE,KAAK,EAAE,CAChB,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACjE,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GACX,GAAG,YAAY,QAAQ;gBACrB,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBAC1C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ApiError } from "../client.js";
|
|
2
|
+
export function registerSelfTestTools(server, client) {
|
|
3
|
+
server.registerTool("apipay_self_test", {
|
|
4
|
+
description: "Verify ApiPay connection and API key configuration. Returns connection status, key prefix, and bank summary counts.",
|
|
5
|
+
}, async () => {
|
|
6
|
+
if (!client.hasCredentials()) {
|
|
7
|
+
return {
|
|
8
|
+
content: [
|
|
9
|
+
{
|
|
10
|
+
type: "text",
|
|
11
|
+
text: "Missing credentials. Please set APIPAY_ACCESS_KEY and APIPAY_SECRET_KEY environment variables or configure via ~/.config/apipay/config.json.",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
isError: true,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const summary = await client.get("/client/banks/summary");
|
|
19
|
+
const result = {
|
|
20
|
+
ok: true,
|
|
21
|
+
baseUrl: client.getBaseUrl(),
|
|
22
|
+
keyPrefix: client.getAccessKeyPrefix(),
|
|
23
|
+
summary,
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
const message = err instanceof ApiError
|
|
31
|
+
? `${err.statusCode}: ${err.message}`
|
|
32
|
+
: String(err);
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: message }],
|
|
35
|
+
isError: true,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=self_test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self_test.js","sourceRoot":"","sources":["../../src/tools/self_test.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAiB;IACxE,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,WAAW,EACT,qHAAqH;KACxH,EACD,KAAK,IAAI,EAAE;QACT,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,CAAC;YAC7B,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,8IAA8I;qBACrJ;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG;gBACb,EAAE,EAAE,IAAI;gBACR,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE;gBAC5B,SAAS,EAAE,MAAM,CAAC,kBAAkB,EAAE;gBACtC,OAAO;aACR,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACnE,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GACX,GAAG,YAAY,QAAQ;gBACrB,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBAC1C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiError } from "../client.js";
|
|
3
|
+
export function registerWebhooksTools(server, client) {
|
|
4
|
+
server.registerTool("apipay_list_webhooks", {
|
|
5
|
+
description: "List registered webhook endpoints.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
page: z
|
|
8
|
+
.number()
|
|
9
|
+
.int()
|
|
10
|
+
.min(1)
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Page number for pagination (starts at 1)"),
|
|
13
|
+
limit: z
|
|
14
|
+
.number()
|
|
15
|
+
.int()
|
|
16
|
+
.min(1)
|
|
17
|
+
.max(100)
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Number of items per page (max 100)"),
|
|
20
|
+
},
|
|
21
|
+
}, async ({ page, limit }) => {
|
|
22
|
+
try {
|
|
23
|
+
const query = {};
|
|
24
|
+
if (page !== undefined)
|
|
25
|
+
query.page = page;
|
|
26
|
+
if (limit !== undefined)
|
|
27
|
+
query.limit = limit;
|
|
28
|
+
const data = await client.get("/client/webhooks", { query });
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const message = err instanceof ApiError
|
|
35
|
+
? `${err.statusCode}: ${err.message}`
|
|
36
|
+
: String(err);
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: message }],
|
|
39
|
+
isError: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
server.registerTool("apipay_create_webhook", {
|
|
44
|
+
description: "Register a new webhook endpoint for transaction notifications on a connected bank account.",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
webhookUrl: z
|
|
47
|
+
.string()
|
|
48
|
+
.describe("HTTPS URL to receive webhook notifications"),
|
|
49
|
+
bankPublicId: z
|
|
50
|
+
.string()
|
|
51
|
+
.describe("Public ID of the connected bank account"),
|
|
52
|
+
},
|
|
53
|
+
}, async ({ webhookUrl, bankPublicId }) => {
|
|
54
|
+
try {
|
|
55
|
+
const data = await client.post("/client/webhooks", {
|
|
56
|
+
webhookUrl,
|
|
57
|
+
bankPublicId,
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const message = err instanceof ApiError
|
|
65
|
+
? `${err.statusCode}: ${err.message}`
|
|
66
|
+
: String(err);
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: message }],
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
server.registerTool("apipay_update_webhook", {
|
|
74
|
+
description: "Update the destination URL of an existing webhook.",
|
|
75
|
+
inputSchema: {
|
|
76
|
+
id: z.string().describe("Webhook ID to update"),
|
|
77
|
+
webhookUrl: z.string().describe("New HTTPS webhook URL"),
|
|
78
|
+
},
|
|
79
|
+
}, async ({ id, webhookUrl }) => {
|
|
80
|
+
try {
|
|
81
|
+
const data = await client.patch(`/client/webhooks/${id}`, {
|
|
82
|
+
webhookUrl,
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
const message = err instanceof ApiError
|
|
90
|
+
? `${err.statusCode}: ${err.message}`
|
|
91
|
+
: String(err);
|
|
92
|
+
return {
|
|
93
|
+
content: [{ type: "text", text: message }],
|
|
94
|
+
isError: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
server.registerTool("apipay_toggle_webhook", {
|
|
99
|
+
description: "Toggle a webhook between active and inactive states.",
|
|
100
|
+
inputSchema: {
|
|
101
|
+
id: z.string().describe("Webhook ID to toggle"),
|
|
102
|
+
},
|
|
103
|
+
}, async ({ id }) => {
|
|
104
|
+
try {
|
|
105
|
+
const data = await client.patch(`/client/webhooks/${id}/toggle`);
|
|
106
|
+
return {
|
|
107
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
const message = err instanceof ApiError
|
|
112
|
+
? `${err.statusCode}: ${err.message}`
|
|
113
|
+
: String(err);
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text", text: message }],
|
|
116
|
+
isError: true,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
server.registerTool("apipay_remove_webhook", {
|
|
121
|
+
description: "Permanently delete a registered webhook (destructive).",
|
|
122
|
+
inputSchema: {
|
|
123
|
+
id: z.string().describe("Webhook ID to delete"),
|
|
124
|
+
},
|
|
125
|
+
}, async ({ id }) => {
|
|
126
|
+
try {
|
|
127
|
+
const data = await client.delete(`/client/webhooks/${id}`);
|
|
128
|
+
return {
|
|
129
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
const message = err instanceof ApiError
|
|
134
|
+
? `${err.statusCode}: ${err.message}`
|
|
135
|
+
: String(err);
|
|
136
|
+
return {
|
|
137
|
+
content: [{ type: "text", text: message }],
|
|
138
|
+
isError: true,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
server.registerTool("apipay_list_webhook_deliveries", {
|
|
143
|
+
description: "List webhook delivery logs and attempt statuses.",
|
|
144
|
+
inputSchema: {
|
|
145
|
+
page: z
|
|
146
|
+
.number()
|
|
147
|
+
.int()
|
|
148
|
+
.min(1)
|
|
149
|
+
.optional()
|
|
150
|
+
.describe("Page number for pagination (starts at 1)"),
|
|
151
|
+
limit: z
|
|
152
|
+
.number()
|
|
153
|
+
.int()
|
|
154
|
+
.min(1)
|
|
155
|
+
.max(100)
|
|
156
|
+
.optional()
|
|
157
|
+
.describe("Number of items per page (max 100)"),
|
|
158
|
+
webhookId: z
|
|
159
|
+
.string()
|
|
160
|
+
.optional()
|
|
161
|
+
.describe("Filter by specific webhook ID"),
|
|
162
|
+
status: z
|
|
163
|
+
.enum(["SUCCESS", "FAILED"])
|
|
164
|
+
.optional()
|
|
165
|
+
.describe("Filter by delivery status"),
|
|
166
|
+
dateFrom: z
|
|
167
|
+
.string()
|
|
168
|
+
.optional()
|
|
169
|
+
.describe("Filter by start date (YYYY-MM-DD or ISO 8601)"),
|
|
170
|
+
dateTo: z
|
|
171
|
+
.string()
|
|
172
|
+
.optional()
|
|
173
|
+
.describe("Filter by end date (YYYY-MM-DD or ISO 8601)"),
|
|
174
|
+
},
|
|
175
|
+
}, async (args) => {
|
|
176
|
+
try {
|
|
177
|
+
const query = {};
|
|
178
|
+
if (args.page !== undefined)
|
|
179
|
+
query.page = args.page;
|
|
180
|
+
if (args.limit !== undefined)
|
|
181
|
+
query.limit = args.limit;
|
|
182
|
+
if (args.webhookId !== undefined)
|
|
183
|
+
query.webhookId = args.webhookId;
|
|
184
|
+
if (args.status !== undefined)
|
|
185
|
+
query.status = args.status;
|
|
186
|
+
if (args.dateFrom !== undefined)
|
|
187
|
+
query.dateFrom = args.dateFrom;
|
|
188
|
+
if (args.dateTo !== undefined)
|
|
189
|
+
query.dateTo = args.dateTo;
|
|
190
|
+
const data = await client.get("/client/webhooks/deliveries", { query });
|
|
191
|
+
return {
|
|
192
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
const message = err instanceof ApiError
|
|
197
|
+
? `${err.statusCode}: ${err.message}`
|
|
198
|
+
: String(err);
|
|
199
|
+
return {
|
|
200
|
+
content: [{ type: "text", text: message }],
|
|
201
|
+
isError: true,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
server.registerTool("apipay_resend_webhook", {
|
|
206
|
+
description: "Resend a failed webhook delivery (fires a real HTTP request to the merchant URL).",
|
|
207
|
+
inputSchema: {
|
|
208
|
+
historyId: z
|
|
209
|
+
.string()
|
|
210
|
+
.describe("Webhook delivery history ID to resend"),
|
|
211
|
+
},
|
|
212
|
+
}, async ({ historyId }) => {
|
|
213
|
+
try {
|
|
214
|
+
const data = await client.post(`/client/webhooks/history/${historyId}/resend`);
|
|
215
|
+
return {
|
|
216
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
catch (err) {
|
|
220
|
+
const message = err instanceof ApiError
|
|
221
|
+
? `${err.statusCode}: ${err.message}`
|
|
222
|
+
: String(err);
|
|
223
|
+
return {
|
|
224
|
+
content: [{ type: "text", text: message }],
|
|
225
|
+
isError: true,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAiB;IACxE,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,WAAW,EAAE,oCAAoC;QACjD,WAAW,EAAE;YACX,IAAI,EAAE,CAAC;iBACJ,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CAAC,0CAA0C,CAAC;YACvD,KAAK,EAAE,CAAC;iBACL,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,GAAG,CAAC;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,oCAAoC,CAAC;SAClD;KACF,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;QACxB,IAAI,CAAC;YACH,MAAM,KAAK,GAAwB,EAAE,CAAC;YACtC,IAAI,IAAI,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;YAC1C,IAAI,KAAK,KAAK,SAAS;gBAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;YAE7C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7D,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI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AAE,CAAC;gBAC1C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,uBAAuB,EACvB;QACE,WAAW,EACT,mFAAmF;QACrF,WAAW,EAAE;YACX,SAAS,EAAE,CAAC;iBACT,MAAM,EAAE;iBACR,QAAQ,CAAC,uCAAuC,CAAC;SACrD;KACF,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;QACtB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAC5B,4BAA4B,SAAS,SAAS,CAC/C,CAAC;YACF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACjE,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GACX,GAAG,YAAY,QAAQ;gBACrB,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gBAC1C,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apipay.vn/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Model Context Protocol (MCP) server for ApiPay",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"apipay-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18.0.0"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
21
|
+
"build": "tsc -b",
|
|
22
|
+
"dev": "tsx src/index.ts",
|
|
23
|
+
"start": "node dist/index.js",
|
|
24
|
+
"test": "tsx --test 'src/*.test.ts' 'src/**/*.test.ts'",
|
|
25
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
29
|
+
"zod": "^3.24.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.13.5",
|
|
33
|
+
"tsx": "^4.19.3",
|
|
34
|
+
"typescript": "^5.7.3"
|
|
35
|
+
}
|
|
36
|
+
}
|