@open-mena-mcp/moyasar 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +102 -2
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +16 -0
- package/dist/bin.js.map +1 -0
- package/dist/client.d.ts +43 -0
- package/dist/client.js +122 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +124 -0
- package/dist/server.js +249 -0
- package/dist/server.js.map +1 -0
- package/package.json +52 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dinaelsayed99
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @open-mena-mcp/moyasar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for the [Moyasar API](https://docs.moyasar.com/api/api-introduction): payments and invoices for Saudi/GCC merchants. Runs over stdio with the official `@modelcontextprotocol/sdk`, built on `@open-mena-mcp/core` (shared errors, rate limiter, logger) with Zod input schemas.
|
|
4
|
+
|
|
5
|
+
Requires a Moyasar **secret key** in `MOYASAR_SECRET_KEY`.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Kind | What it does | Moyasar endpoint | Doc source |
|
|
10
|
+
| ---------------- | --------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- |
|
|
11
|
+
| `fetch_payment` | read | One payment by UUID: status, amount, fee, refunded/captured, source, invoice id | `GET /payments/{id}` (`id` path param) | https://docs.moyasar.com/api/payments/02-fetch-payment |
|
|
12
|
+
| `list_payments` | read | Payments newest first, with the documented filters and pagination meta | `GET /payments` (`page`, `id`, `status`, `created[gt]`, `created[lt]`, `updated[gt]`, `updated[lt]`, `metadata[key]`, `card_last_digits`, `receipt_no`) | https://docs.moyasar.com/api/payments/03-list-payments |
|
|
13
|
+
| `fetch_invoice` | read | One invoice by UUID: status, amount, hosted payment `url`, expiry, its payments | `GET /invoices/{id}` (`id` path param) | https://docs.moyasar.com/api/invoices/04-show-invoice |
|
|
14
|
+
| `list_invoices` | read | Invoices newest first, with the documented filters and pagination meta | `GET /invoices` (`page`, `id`, `status`, `created[gt]`, `created[lt]`, `metadata[key]`) | https://docs.moyasar.com/api/invoices/03-list-invoice |
|
|
15
|
+
| `create_invoice` | **WRITE** | **Creates a real invoice** and returns its hosted payment URL | `POST /invoices` (`amount`, `currency`, `description`, `callback_url`, `success_url`, `back_url`, `expired_at`, `phone`, `metadata`) | https://docs.moyasar.com/api/invoices/01-create-invoice |
|
|
16
|
+
|
|
17
|
+
Base URL: `https://api.moyasar.com/v1` (https://docs.moyasar.com/api/api-introduction).
|
|
18
|
+
|
|
19
|
+
## ⚠️ `create_invoice` is a write action
|
|
20
|
+
|
|
21
|
+
`create_invoice` is the only non-read tool in this server, and it is a real write:
|
|
22
|
+
|
|
23
|
+
- It creates an invoice on the authenticated Moyasar account. It is not a draft, a preview or a dry run, and this server cannot delete it afterwards (Moyasar exposes cancel/update on the dashboard and `POST /invoices/{id}/cancel`, neither of which is exposed here).
|
|
24
|
+
- The response contains a hosted payment page `url`. Anyone holding that link can pay the invoice, which moves real money.
|
|
25
|
+
- `amount` is in the smallest currency unit and must be `>= 100` (`1.00 SAR = 100`, `1.00 KWD = 1000`).
|
|
26
|
+
- If `phone` is set, Moyasar sends the payment link to that Saudi mobile number by SMS when the invoice is created. That only works if Moyasar enabled SMS invoicing for the account; when the SMS cannot be delivered the invoice is not created.
|
|
27
|
+
- **Live vs test is decided by the key, not by this server.** An `sk_test_` key hits the sandbox and does not touch banking networks; an `sk_live_` key is a live invoice.
|
|
28
|
+
- Agents should call it only on an explicit request to create an invoice, after confirming amount, currency and description. The tool description says this too, so the calling model sees it before it can call the tool.
|
|
29
|
+
|
|
30
|
+
Nothing in this package ever creates an invoice: the test suite uses an injected `fetch` mock, so no request leaves the process.
|
|
31
|
+
|
|
32
|
+
## Authentication
|
|
33
|
+
|
|
34
|
+
HTTP Basic, with the secret key as the username and an **empty password** (https://docs.moyasar.com/api/authentication). `MOYASAR_SECRET_KEY` is read at call time, so the server starts and lists tools without it; a tool call without the key fails with `AUTH_MISSING`. The key is never placed in a URL, a log line or an error message, and it is never committed.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
export MOYASAR_SECRET_KEY=sk_test_...
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Test keys are prefixed `sk_test_`, live keys `sk_live_`. All calls are HTTPS only.
|
|
41
|
+
|
|
42
|
+
Put the **full** secret key in `MOYASAR_SECRET_KEY`, not the key ID that stays visible in the dashboard. A request carrying only the ID is rejected with `401` and the message "You provided your secret key ID instead of the full secret key" (observed live on 2026-12-05). The full key is shown once, at creation time.
|
|
43
|
+
|
|
44
|
+
## Run
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm install
|
|
48
|
+
pnpm build
|
|
49
|
+
MOYASAR_SECRET_KEY=sk_test_... node packages/mcp-moyasar/dist/bin.js
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Claude Desktop config:
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"mcpServers": {
|
|
57
|
+
"moyasar": {
|
|
58
|
+
"command": "node",
|
|
59
|
+
"args": ["/absolute/path/to/open-mena-mcp/packages/mcp-moyasar/dist/bin.js"],
|
|
60
|
+
"env": { "MOYASAR_SECRET_KEY": "sk_test_..." }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Once published to npm: `npx @open-mena-mcp/moyasar` works as the command instead.
|
|
67
|
+
|
|
68
|
+
## Develop
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm --filter @open-mena-mcp/moyasar build
|
|
72
|
+
pnpm --filter @open-mena-mcp/moyasar typecheck
|
|
73
|
+
pnpm --filter @open-mena-mcp/moyasar lint
|
|
74
|
+
pnpm --filter @open-mena-mcp/moyasar test
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Tests are vitest with an injected fetch mock. **Zero live network calls**: URL construction, Basic auth headers, request bodies, error-type mapping, the rate limiter and all five handlers run against recorded response shapes. `src/stdio.test.ts` additionally spawns the built `dist/bin.js` and performs a real `initialize` + `tools/list` handshake over stdio (it skips when `dist/` has not been built, and it only lists tools, so it never calls the API).
|
|
78
|
+
|
|
79
|
+
## API behaviour relied on
|
|
80
|
+
|
|
81
|
+
All of it verified against the official docs on 2026-12-05:
|
|
82
|
+
|
|
83
|
+
- **Success**: a single JSON object for fetch/create, `{ payments, meta }` / `{ invoices, meta }` for list. `create_invoice` returns `201`.
|
|
84
|
+
- **Pagination** (https://docs.moyasar.com/api/pagination): `page` query param, 40 objects per page by default, newest first; `meta` carries `current_page`, `next_page`, `prev_page`, `total_pages`, `total_count`.
|
|
85
|
+
- **Errors** (https://docs.moyasar.com/api/errors): `{ "type", "message", "errors" }` with types `validation_error`, `invalid_request_error`, `authentication_error`, `record_not_found`, `rate_limit_error`, `account_inactive_error`, `api_error`, plus business types such as `used_given_id`. HTTP statuses 200/400/401/403/404/405/429/500/503. The client maps type first, then falls back to the HTTP status, onto `@open-mena-mcp/core` codes: `validation_error`/`invalid_request_error`/`used_given_id` → `INVALID_INPUT`, `authentication_error` → `AUTH_FAILED`, `record_not_found` → `NOT_FOUND`, `rate_limit_error` → `RATE_LIMITED`, `account_inactive_error`/`api_error` → `UPSTREAM_ERROR`.
|
|
86
|
+
- A declined card is **not** an API error: it returns 201 with the payment `status: failed`. Read the status, do not expect an exception.
|
|
87
|
+
- Payment statuses: `initiated`, `paid`, `authorized`, `failed`, `refunded`, `captured`, `voided`, `verified`, `expired`. Invoice statuses: `initiated`, `paid`, `failed`, `refunded`, `canceled`, `on_hold`, `expired`, `voided`. Both are used as the `status` filter enums.
|
|
88
|
+
|
|
89
|
+
## Doc verification notes and open ambiguities
|
|
90
|
+
|
|
91
|
+
Every endpoint, parameter and response field above was read from the rendered official docs before any code was written. Moyasar publishes **no OpenAPI/Swagger document** that could be downloaded (`/openapi.json`, `/openapi/openapi.json`, `/api/openapi.json` on `docs.moyasar.com` and `api.moyasar.com` all return 404, and the API-introduction page carries no spec link), so the API-reference pages themselves are the source of truth. Points where the docs are thinner than ideal, and how this package handles each:
|
|
92
|
+
|
|
93
|
+
1. **List response objects are not itemised.** The list pages show only `payments` / `invoices` arrays plus `meta`; the per-object schema lives on the fetch pages. List results are therefore returned exactly as the API sends them, untyped.
|
|
94
|
+
2. **`metadata` is documented as "object"** with no field spec. Typed here as a `string -> string` record, which matches the `metadata[key]` filter form and the examples.
|
|
95
|
+
3. **`expired_at` is labelled "timestamp"** but the text accepts an ISO date (`2017-01-12`) or datetime (`2018-01-01T09:55:14.000Z`). Accepted as a string, with the date-only caveat in the field description.
|
|
96
|
+
4. **No per-page-size parameter is documented** (only `page`), although the pagination page mentions 40 objects per page. Only `page` is exposed.
|
|
97
|
+
5. **Currency is not enumerated.** Validated as a 3-letter uppercase ISO-4217 code.
|
|
98
|
+
6. **Invoice idempotency is undocumented.** The idempotency page covers payment and payout creation via `given_id`; the create-invoice body has no `given_id`, so none is sent. Retrying a failed `create_invoice` can therefore create a second invoice. Confirm against Moyasar support before relying on invoice retries.
|
|
99
|
+
7. **Invoice page numbering collides in the sitemap**: both `03-bulk-invoice` and `03-list-invoice` exist; `03-list-invoice` is the "List Invoices" page used here.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createLogger } from "@open-mena-mcp/core";
|
|
4
|
+
import { createServer } from "./server.js";
|
|
5
|
+
async function main() {
|
|
6
|
+
const logger = createLogger({ name: "moyasar" });
|
|
7
|
+
const server = createServer();
|
|
8
|
+
const transport = new StdioServerTransport();
|
|
9
|
+
await server.connect(transport);
|
|
10
|
+
logger.info("MCP server running on stdio");
|
|
11
|
+
}
|
|
12
|
+
main().catch((error) => {
|
|
13
|
+
console.error(error);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;AAC7C,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { RateLimiter, type McpErrorCode } from "@open-mena-mcp/core";
|
|
2
|
+
/** Base URL of the Moyasar API v1, per https://docs.moyasar.com/api/api-introduction */
|
|
3
|
+
export declare const MOYASAR_BASE_URL = "https://api.moyasar.com/v1";
|
|
4
|
+
/** Environment variable holding the secret key (the HTTP Basic username). */
|
|
5
|
+
export declare const MOYASAR_SECRET_KEY_ENV = "MOYASAR_SECRET_KEY";
|
|
6
|
+
export interface MoyasarClientOptions {
|
|
7
|
+
/** Secret key. When omitted it is read from MOYASAR_SECRET_KEY at call time. */
|
|
8
|
+
secretKey?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
limiter?: RateLimiter;
|
|
11
|
+
/** Injectable fetch so tests can mock HTTP without any network. */
|
|
12
|
+
fetchImpl?: typeof fetch;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Error types documented at https://docs.moyasar.com/api/errors.
|
|
16
|
+
* Anything not listed here falls back to the HTTP status code.
|
|
17
|
+
*/
|
|
18
|
+
export declare function codeFromErrorType(type: string): McpErrorCode | undefined;
|
|
19
|
+
export interface MoyasarRequestOptions {
|
|
20
|
+
query?: Record<string, string>;
|
|
21
|
+
body?: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Minimal HTTP client for the Moyasar API.
|
|
25
|
+
*
|
|
26
|
+
* Authentication is HTTP Basic with the secret key as the username and an empty
|
|
27
|
+
* password (https://docs.moyasar.com/api/authentication). The key is never put
|
|
28
|
+
* in a URL, a log line or an error message.
|
|
29
|
+
*/
|
|
30
|
+
export declare class MoyasarClient {
|
|
31
|
+
private readonly baseUrl;
|
|
32
|
+
private readonly limiter;
|
|
33
|
+
private readonly fetchImpl;
|
|
34
|
+
private readonly explicitKey;
|
|
35
|
+
constructor(options?: MoyasarClientOptions);
|
|
36
|
+
/** Resolved lazily so the server can start and list tools without a key. */
|
|
37
|
+
private secretKey;
|
|
38
|
+
private authorizationHeader;
|
|
39
|
+
/** Perform one request and return the parsed JSON body (or undefined for an empty body). */
|
|
40
|
+
request(method: "GET" | "POST", path: string, options?: MoyasarRequestOptions): Promise<unknown>;
|
|
41
|
+
get(path: string, query?: Record<string, string>): Promise<unknown>;
|
|
42
|
+
post(path: string, body: unknown): Promise<unknown>;
|
|
43
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { McpToolError, RateLimiter, codeFromHttpStatus, requireEnv, } from "@open-mena-mcp/core";
|
|
2
|
+
/** Base URL of the Moyasar API v1, per https://docs.moyasar.com/api/api-introduction */
|
|
3
|
+
export const MOYASAR_BASE_URL = "https://api.moyasar.com/v1";
|
|
4
|
+
/** Environment variable holding the secret key (the HTTP Basic username). */
|
|
5
|
+
export const MOYASAR_SECRET_KEY_ENV = "MOYASAR_SECRET_KEY";
|
|
6
|
+
/**
|
|
7
|
+
* Error types documented at https://docs.moyasar.com/api/errors.
|
|
8
|
+
* Anything not listed here falls back to the HTTP status code.
|
|
9
|
+
*/
|
|
10
|
+
export function codeFromErrorType(type) {
|
|
11
|
+
switch (type) {
|
|
12
|
+
case "validation_error":
|
|
13
|
+
case "invalid_request_error":
|
|
14
|
+
case "invalid_request":
|
|
15
|
+
case "used_given_id":
|
|
16
|
+
return "INVALID_INPUT";
|
|
17
|
+
case "authentication_error":
|
|
18
|
+
return "AUTH_FAILED";
|
|
19
|
+
case "record_not_found":
|
|
20
|
+
return "NOT_FOUND";
|
|
21
|
+
case "rate_limit_error":
|
|
22
|
+
return "RATE_LIMITED";
|
|
23
|
+
case "account_inactive_error":
|
|
24
|
+
case "api_error":
|
|
25
|
+
return "UPSTREAM_ERROR";
|
|
26
|
+
default:
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Pull { type, message } out of a Moyasar error body without trusting its shape. */
|
|
31
|
+
function errorParts(body) {
|
|
32
|
+
if (typeof body !== "object" || body === null)
|
|
33
|
+
return {};
|
|
34
|
+
const candidate = body;
|
|
35
|
+
const parts = {};
|
|
36
|
+
if (typeof candidate.type === "string")
|
|
37
|
+
parts.type = candidate.type;
|
|
38
|
+
if (typeof candidate.message === "string")
|
|
39
|
+
parts.message = candidate.message;
|
|
40
|
+
return parts;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Minimal HTTP client for the Moyasar API.
|
|
44
|
+
*
|
|
45
|
+
* Authentication is HTTP Basic with the secret key as the username and an empty
|
|
46
|
+
* password (https://docs.moyasar.com/api/authentication). The key is never put
|
|
47
|
+
* in a URL, a log line or an error message.
|
|
48
|
+
*/
|
|
49
|
+
export class MoyasarClient {
|
|
50
|
+
baseUrl;
|
|
51
|
+
limiter;
|
|
52
|
+
fetchImpl;
|
|
53
|
+
explicitKey;
|
|
54
|
+
constructor(options = {}) {
|
|
55
|
+
this.baseUrl = options.baseUrl ?? MOYASAR_BASE_URL;
|
|
56
|
+
this.limiter = options.limiter ?? new RateLimiter({ capacity: 10, refillPerSecond: 2 });
|
|
57
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
58
|
+
this.explicitKey = options.secretKey;
|
|
59
|
+
}
|
|
60
|
+
/** Resolved lazily so the server can start and list tools without a key. */
|
|
61
|
+
secretKey() {
|
|
62
|
+
if (this.explicitKey !== undefined && this.explicitKey.length > 0)
|
|
63
|
+
return this.explicitKey;
|
|
64
|
+
return requireEnv(MOYASAR_SECRET_KEY_ENV);
|
|
65
|
+
}
|
|
66
|
+
authorizationHeader(key) {
|
|
67
|
+
// Basic auth: username = secret key, password = empty string.
|
|
68
|
+
return "Basic " + Buffer.from(key + ":", "utf8").toString("base64");
|
|
69
|
+
}
|
|
70
|
+
/** Perform one request and return the parsed JSON body (or undefined for an empty body). */
|
|
71
|
+
async request(method, path, options = {}) {
|
|
72
|
+
const key = this.secretKey();
|
|
73
|
+
if (!this.limiter.tryAcquire()) {
|
|
74
|
+
throw new McpToolError("RATE_LIMITED", "Local rate limit reached; retry in a moment.");
|
|
75
|
+
}
|
|
76
|
+
const query = new URLSearchParams(options.query ?? {}).toString();
|
|
77
|
+
const url = this.baseUrl + path + (query.length > 0 ? "?" + query : "");
|
|
78
|
+
const headers = {
|
|
79
|
+
accept: "application/json",
|
|
80
|
+
authorization: this.authorizationHeader(key),
|
|
81
|
+
};
|
|
82
|
+
const init = { method, headers };
|
|
83
|
+
if (options.body !== undefined) {
|
|
84
|
+
headers["content-type"] = "application/json";
|
|
85
|
+
init.body = JSON.stringify(options.body);
|
|
86
|
+
}
|
|
87
|
+
let response;
|
|
88
|
+
try {
|
|
89
|
+
response = await this.fetchImpl(url, init);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
throw new McpToolError("UPSTREAM_ERROR", "Network error talking to the Moyasar API", {
|
|
93
|
+
cause: err,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const text = await response.text();
|
|
97
|
+
let body;
|
|
98
|
+
if (text.length > 0) {
|
|
99
|
+
try {
|
|
100
|
+
body = JSON.parse(text);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
body = undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const parts = errorParts(body);
|
|
108
|
+
const code = (parts.type !== undefined ? codeFromErrorType(parts.type) : undefined) ??
|
|
109
|
+
codeFromHttpStatus(response.status);
|
|
110
|
+
const message = parts.message ?? "Moyasar API responded with HTTP " + String(response.status);
|
|
111
|
+
throw new McpToolError(code, message, { status: response.status, details: body });
|
|
112
|
+
}
|
|
113
|
+
return body;
|
|
114
|
+
}
|
|
115
|
+
get(path, query) {
|
|
116
|
+
return this.request("GET", path, query === undefined ? {} : { query });
|
|
117
|
+
}
|
|
118
|
+
post(path, body) {
|
|
119
|
+
return this.request("POST", path, { body });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,UAAU,GAEX,MAAM,qBAAqB,CAAC;AAE7B,wFAAwF;AACxF,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAE7D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAW3D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,kBAAkB,CAAC;QACxB,KAAK,uBAAuB,CAAC;QAC7B,KAAK,iBAAiB,CAAC;QACvB,KAAK,eAAe;YAClB,OAAO,eAAe,CAAC;QACzB,KAAK,sBAAsB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AC9C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,CAAC,IAAY,EAAE,IAAa;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,kFAAkF;AAClF,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { MoyasarClient } from "./client.js";
|
|
4
|
+
export declare const FetchPaymentInputSchema: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
id: string;
|
|
8
|
+
}, {
|
|
9
|
+
id: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type FetchPaymentInput = z.infer<typeof FetchPaymentInputSchema>;
|
|
12
|
+
export declare const ListPaymentsInputSchema: z.ZodObject<{
|
|
13
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
id: z.ZodOptional<z.ZodString>;
|
|
15
|
+
status: z.ZodOptional<z.ZodEnum<["initiated", "paid", "authorized", "failed", "refunded", "captured", "voided", "verified", "expired"]>>;
|
|
16
|
+
created_gt: z.ZodOptional<z.ZodString>;
|
|
17
|
+
created_lt: z.ZodOptional<z.ZodString>;
|
|
18
|
+
updated_gt: z.ZodOptional<z.ZodString>;
|
|
19
|
+
updated_lt: z.ZodOptional<z.ZodString>;
|
|
20
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
21
|
+
card_last_digits: z.ZodOptional<z.ZodString>;
|
|
22
|
+
receipt_no: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
status?: "initiated" | "paid" | "authorized" | "failed" | "refunded" | "captured" | "voided" | "verified" | "expired" | undefined;
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
page?: number | undefined;
|
|
27
|
+
created_gt?: string | undefined;
|
|
28
|
+
created_lt?: string | undefined;
|
|
29
|
+
updated_gt?: string | undefined;
|
|
30
|
+
updated_lt?: string | undefined;
|
|
31
|
+
metadata?: Record<string, string> | undefined;
|
|
32
|
+
card_last_digits?: string | undefined;
|
|
33
|
+
receipt_no?: string | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
status?: "initiated" | "paid" | "authorized" | "failed" | "refunded" | "captured" | "voided" | "verified" | "expired" | undefined;
|
|
36
|
+
id?: string | undefined;
|
|
37
|
+
page?: number | undefined;
|
|
38
|
+
created_gt?: string | undefined;
|
|
39
|
+
created_lt?: string | undefined;
|
|
40
|
+
updated_gt?: string | undefined;
|
|
41
|
+
updated_lt?: string | undefined;
|
|
42
|
+
metadata?: Record<string, string> | undefined;
|
|
43
|
+
card_last_digits?: string | undefined;
|
|
44
|
+
receipt_no?: string | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
export type ListPaymentsInput = z.infer<typeof ListPaymentsInputSchema>;
|
|
47
|
+
export declare const FetchInvoiceInputSchema: z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
id: string;
|
|
51
|
+
}, {
|
|
52
|
+
id: string;
|
|
53
|
+
}>;
|
|
54
|
+
export type FetchInvoiceInput = z.infer<typeof FetchInvoiceInputSchema>;
|
|
55
|
+
export declare const ListInvoicesInputSchema: z.ZodObject<{
|
|
56
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
id: z.ZodOptional<z.ZodString>;
|
|
58
|
+
status: z.ZodOptional<z.ZodEnum<["initiated", "paid", "failed", "refunded", "canceled", "on_hold", "expired", "voided"]>>;
|
|
59
|
+
created_gt: z.ZodOptional<z.ZodString>;
|
|
60
|
+
created_lt: z.ZodOptional<z.ZodString>;
|
|
61
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
status?: "initiated" | "paid" | "failed" | "refunded" | "voided" | "expired" | "canceled" | "on_hold" | undefined;
|
|
64
|
+
id?: string | undefined;
|
|
65
|
+
page?: number | undefined;
|
|
66
|
+
created_gt?: string | undefined;
|
|
67
|
+
created_lt?: string | undefined;
|
|
68
|
+
metadata?: Record<string, string> | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
status?: "initiated" | "paid" | "failed" | "refunded" | "voided" | "expired" | "canceled" | "on_hold" | undefined;
|
|
71
|
+
id?: string | undefined;
|
|
72
|
+
page?: number | undefined;
|
|
73
|
+
created_gt?: string | undefined;
|
|
74
|
+
created_lt?: string | undefined;
|
|
75
|
+
metadata?: Record<string, string> | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
export type ListInvoicesInput = z.infer<typeof ListInvoicesInputSchema>;
|
|
78
|
+
export declare const CreateInvoiceInputSchema: z.ZodObject<{
|
|
79
|
+
amount: z.ZodNumber;
|
|
80
|
+
currency: z.ZodString;
|
|
81
|
+
description: z.ZodString;
|
|
82
|
+
callback_url: z.ZodOptional<z.ZodString>;
|
|
83
|
+
success_url: z.ZodOptional<z.ZodString>;
|
|
84
|
+
back_url: z.ZodOptional<z.ZodString>;
|
|
85
|
+
expired_at: z.ZodOptional<z.ZodString>;
|
|
86
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
87
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
amount: number;
|
|
90
|
+
currency: string;
|
|
91
|
+
description: string;
|
|
92
|
+
metadata?: Record<string, string> | undefined;
|
|
93
|
+
callback_url?: string | undefined;
|
|
94
|
+
success_url?: string | undefined;
|
|
95
|
+
back_url?: string | undefined;
|
|
96
|
+
expired_at?: string | undefined;
|
|
97
|
+
phone?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
amount: number;
|
|
100
|
+
currency: string;
|
|
101
|
+
description: string;
|
|
102
|
+
metadata?: Record<string, string> | undefined;
|
|
103
|
+
callback_url?: string | undefined;
|
|
104
|
+
success_url?: string | undefined;
|
|
105
|
+
back_url?: string | undefined;
|
|
106
|
+
expired_at?: string | undefined;
|
|
107
|
+
phone?: string | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
export type CreateInvoiceInput = z.infer<typeof CreateInvoiceInputSchema>;
|
|
110
|
+
/** GET /payments/{id} - https://docs.moyasar.com/api/payments/02-fetch-payment */
|
|
111
|
+
export declare function fetchPayment(client: MoyasarClient, input: FetchPaymentInput): Promise<unknown>;
|
|
112
|
+
/** GET /payments - https://docs.moyasar.com/api/payments/03-list-payments */
|
|
113
|
+
export declare function listPayments(client: MoyasarClient, input: ListPaymentsInput): Promise<unknown>;
|
|
114
|
+
/** GET /invoices/{id} - https://docs.moyasar.com/api/invoices/04-show-invoice */
|
|
115
|
+
export declare function fetchInvoice(client: MoyasarClient, input: FetchInvoiceInput): Promise<unknown>;
|
|
116
|
+
/** GET /invoices - https://docs.moyasar.com/api/invoices/03-list-invoice */
|
|
117
|
+
export declare function listInvoices(client: MoyasarClient, input: ListInvoicesInput): Promise<unknown>;
|
|
118
|
+
/**
|
|
119
|
+
* POST /invoices - https://docs.moyasar.com/api/invoices/01-create-invoice
|
|
120
|
+
*
|
|
121
|
+
* WRITE ACTION: creates a real invoice on the authenticated account.
|
|
122
|
+
*/
|
|
123
|
+
export declare function createInvoice(client: MoyasarClient, input: CreateInvoiceInput): Promise<unknown>;
|
|
124
|
+
export declare function createServer(client?: MoyasarClient): McpServer;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { wrapTool } from "@open-mena-mcp/core";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { MoyasarClient } from "./client.js";
|
|
5
|
+
/**
|
|
6
|
+
* Every schema below mirrors a field documented on the official Moyasar API
|
|
7
|
+
* pages. Doc source for each tool is recorded in README.md.
|
|
8
|
+
*/
|
|
9
|
+
const idField = z
|
|
10
|
+
.string()
|
|
11
|
+
.uuid("Expected the Moyasar resource UUID")
|
|
12
|
+
.describe("Moyasar resource ID (UUID), as returned by a create or list call.");
|
|
13
|
+
const pageField = z
|
|
14
|
+
.number()
|
|
15
|
+
.int()
|
|
16
|
+
.min(1)
|
|
17
|
+
.describe("Page number to list, starting at 1. Results come newest first, 40 records per page by default (https://docs.moyasar.com/api/pagination).");
|
|
18
|
+
const paymentStatusField = z
|
|
19
|
+
.enum([
|
|
20
|
+
"initiated",
|
|
21
|
+
"paid",
|
|
22
|
+
"authorized",
|
|
23
|
+
"failed",
|
|
24
|
+
"refunded",
|
|
25
|
+
"captured",
|
|
26
|
+
"voided",
|
|
27
|
+
"verified",
|
|
28
|
+
"expired",
|
|
29
|
+
])
|
|
30
|
+
.describe("Payment status to filter by: initiated, paid, authorized, failed, refunded, captured, voided, verified or expired.");
|
|
31
|
+
const invoiceStatusField = z
|
|
32
|
+
.enum(["initiated", "paid", "failed", "refunded", "canceled", "on_hold", "expired", "voided"])
|
|
33
|
+
.describe("Invoice status to filter by: initiated, paid, failed, refunded, canceled, on_hold, expired or voided.");
|
|
34
|
+
const createdAtGtField = z
|
|
35
|
+
.string()
|
|
36
|
+
.min(1)
|
|
37
|
+
.describe("Only include records created on or after this timestamp (ISO 8601, e.g. 2026-12-01 or 2026-12-01T00:00:00Z).");
|
|
38
|
+
const createdAtLtField = z
|
|
39
|
+
.string()
|
|
40
|
+
.min(1)
|
|
41
|
+
.describe("Only include records created on or before this timestamp (ISO 8601, e.g. 2026-12-31 or 2026-12-31T23:59:59Z).");
|
|
42
|
+
const updatedAtGtField = z
|
|
43
|
+
.string()
|
|
44
|
+
.min(1)
|
|
45
|
+
.describe("Only include payments updated on or after this timestamp (ISO 8601). Payments only.");
|
|
46
|
+
const updatedAtLtField = z
|
|
47
|
+
.string()
|
|
48
|
+
.min(1)
|
|
49
|
+
.describe("Only include payments updated on or before this timestamp (ISO 8601). Payments only.");
|
|
50
|
+
const metadataField = z
|
|
51
|
+
.record(z.string())
|
|
52
|
+
.describe("Arbitrary key/value metadata stored on the resource. When listing, each entry is sent as the documented metadata[key]=value filter.");
|
|
53
|
+
const cardLastDigitsField = z
|
|
54
|
+
.string()
|
|
55
|
+
.regex(/^\d{4}$/, "Expected exactly 4 digits")
|
|
56
|
+
.describe("Filter payments by the last 4 digits of the card. Only applies to scheme payments (creditcard, applepay, samsungpay).");
|
|
57
|
+
const receiptNoField = z
|
|
58
|
+
.string()
|
|
59
|
+
.regex(/^\d{12}$/, "Expected exactly 12 digits")
|
|
60
|
+
.describe("Filter payments by RRN / retrieval reference number (12 digits).");
|
|
61
|
+
const amountField = z
|
|
62
|
+
.number()
|
|
63
|
+
.int()
|
|
64
|
+
.min(100)
|
|
65
|
+
.describe("Amount in the smallest currency unit, as a positive integer >= 100 (1.00 SAR = 100, 1.00 KWD = 1000, 1 JPY = 1).");
|
|
66
|
+
const currencyField = z
|
|
67
|
+
.string()
|
|
68
|
+
.regex(/^[A-Z]{3}$/, "Expected a 3-letter ISO-4217 code such as SAR")
|
|
69
|
+
.describe("ISO-4217 three-letter currency code, e.g. SAR, USD, EGP, KWD.");
|
|
70
|
+
const descriptionField = z
|
|
71
|
+
.string()
|
|
72
|
+
.min(1)
|
|
73
|
+
.describe("Description of the goods or service being billed. It is shown to the payer on the invoice next to the amount.");
|
|
74
|
+
const callbackUrlField = z
|
|
75
|
+
.string()
|
|
76
|
+
.url()
|
|
77
|
+
.describe("Your server endpoint that receives a POST with the invoice object when the invoice is paid. Notification only, the payer is not redirected here.");
|
|
78
|
+
const successUrlField = z
|
|
79
|
+
.string()
|
|
80
|
+
.url()
|
|
81
|
+
.describe("URL the payer is redirected to after paying the invoice.");
|
|
82
|
+
const backUrlField = z
|
|
83
|
+
.string()
|
|
84
|
+
.url()
|
|
85
|
+
.describe("URL the payer is sent to when they click the back button on the payment page.");
|
|
86
|
+
const expiredAtField = z
|
|
87
|
+
.string()
|
|
88
|
+
.min(1)
|
|
89
|
+
.describe("When the invoice expires, as an ISO 8601 date (2017-01-12) or datetime (2018-01-01T09:55:14.000Z). A date-only value expires at 00:00:00 that day. The payer cannot pay an expired invoice.");
|
|
90
|
+
const phoneField = z
|
|
91
|
+
.string()
|
|
92
|
+
.min(1)
|
|
93
|
+
.describe("Saudi mobile number to send the invoice payment link to by SMS, e.g. 0500000000, 966500000000 or +966500000000. Only works if Moyasar enabled SMS invoicing for your account; if the SMS cannot be delivered the invoice is not created.");
|
|
94
|
+
export const FetchPaymentInputSchema = z.object({
|
|
95
|
+
id: idField,
|
|
96
|
+
});
|
|
97
|
+
export const ListPaymentsInputSchema = z.object({
|
|
98
|
+
page: pageField.optional(),
|
|
99
|
+
id: idField.optional(),
|
|
100
|
+
status: paymentStatusField.optional(),
|
|
101
|
+
created_gt: createdAtGtField.optional(),
|
|
102
|
+
created_lt: createdAtLtField.optional(),
|
|
103
|
+
updated_gt: updatedAtGtField.optional(),
|
|
104
|
+
updated_lt: updatedAtLtField.optional(),
|
|
105
|
+
metadata: metadataField.optional(),
|
|
106
|
+
card_last_digits: cardLastDigitsField.optional(),
|
|
107
|
+
receipt_no: receiptNoField.optional(),
|
|
108
|
+
});
|
|
109
|
+
export const FetchInvoiceInputSchema = z.object({
|
|
110
|
+
id: idField,
|
|
111
|
+
});
|
|
112
|
+
export const ListInvoicesInputSchema = z.object({
|
|
113
|
+
page: pageField.optional(),
|
|
114
|
+
id: idField.optional(),
|
|
115
|
+
status: invoiceStatusField.optional(),
|
|
116
|
+
created_gt: createdAtGtField.optional(),
|
|
117
|
+
created_lt: createdAtLtField.optional(),
|
|
118
|
+
metadata: metadataField.optional(),
|
|
119
|
+
});
|
|
120
|
+
export const CreateInvoiceInputSchema = z.object({
|
|
121
|
+
amount: amountField,
|
|
122
|
+
currency: currencyField,
|
|
123
|
+
description: descriptionField,
|
|
124
|
+
callback_url: callbackUrlField.optional(),
|
|
125
|
+
success_url: successUrlField.optional(),
|
|
126
|
+
back_url: backUrlField.optional(),
|
|
127
|
+
expired_at: expiredAtField.optional(),
|
|
128
|
+
phone: phoneField.optional(),
|
|
129
|
+
metadata: metadataField.optional(),
|
|
130
|
+
});
|
|
131
|
+
function putString(target, key, value) {
|
|
132
|
+
if (value !== undefined)
|
|
133
|
+
target[key] = value;
|
|
134
|
+
}
|
|
135
|
+
function metadataFilters(metadata) {
|
|
136
|
+
const out = {};
|
|
137
|
+
if (metadata === undefined)
|
|
138
|
+
return out;
|
|
139
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
140
|
+
out["metadata[" + key + "]"] = value;
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
/** GET /payments/{id} - https://docs.moyasar.com/api/payments/02-fetch-payment */
|
|
145
|
+
export async function fetchPayment(client, input) {
|
|
146
|
+
return client.get("/payments/" + encodeURIComponent(input.id));
|
|
147
|
+
}
|
|
148
|
+
/** GET /payments - https://docs.moyasar.com/api/payments/03-list-payments */
|
|
149
|
+
export async function listPayments(client, input) {
|
|
150
|
+
const query = {};
|
|
151
|
+
if (input.page !== undefined)
|
|
152
|
+
query.page = String(input.page);
|
|
153
|
+
putString(query, "id", input.id);
|
|
154
|
+
putString(query, "status", input.status);
|
|
155
|
+
putString(query, "created[gt]", input.created_gt);
|
|
156
|
+
putString(query, "created[lt]", input.created_lt);
|
|
157
|
+
putString(query, "updated[gt]", input.updated_gt);
|
|
158
|
+
putString(query, "updated[lt]", input.updated_lt);
|
|
159
|
+
putString(query, "card_last_digits", input.card_last_digits);
|
|
160
|
+
putString(query, "receipt_no", input.receipt_no);
|
|
161
|
+
Object.assign(query, metadataFilters(input.metadata));
|
|
162
|
+
return client.get("/payments", query);
|
|
163
|
+
}
|
|
164
|
+
/** GET /invoices/{id} - https://docs.moyasar.com/api/invoices/04-show-invoice */
|
|
165
|
+
export async function fetchInvoice(client, input) {
|
|
166
|
+
return client.get("/invoices/" + encodeURIComponent(input.id));
|
|
167
|
+
}
|
|
168
|
+
/** GET /invoices - https://docs.moyasar.com/api/invoices/03-list-invoice */
|
|
169
|
+
export async function listInvoices(client, input) {
|
|
170
|
+
const query = {};
|
|
171
|
+
if (input.page !== undefined)
|
|
172
|
+
query.page = String(input.page);
|
|
173
|
+
putString(query, "id", input.id);
|
|
174
|
+
putString(query, "status", input.status);
|
|
175
|
+
putString(query, "created[gt]", input.created_gt);
|
|
176
|
+
putString(query, "created[lt]", input.created_lt);
|
|
177
|
+
Object.assign(query, metadataFilters(input.metadata));
|
|
178
|
+
return client.get("/invoices", query);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* POST /invoices - https://docs.moyasar.com/api/invoices/01-create-invoice
|
|
182
|
+
*
|
|
183
|
+
* WRITE ACTION: creates a real invoice on the authenticated account.
|
|
184
|
+
*/
|
|
185
|
+
export async function createInvoice(client, input) {
|
|
186
|
+
const body = {
|
|
187
|
+
amount: input.amount,
|
|
188
|
+
currency: input.currency,
|
|
189
|
+
description: input.description,
|
|
190
|
+
};
|
|
191
|
+
if (input.callback_url !== undefined)
|
|
192
|
+
body.callback_url = input.callback_url;
|
|
193
|
+
if (input.success_url !== undefined)
|
|
194
|
+
body.success_url = input.success_url;
|
|
195
|
+
if (input.back_url !== undefined)
|
|
196
|
+
body.back_url = input.back_url;
|
|
197
|
+
if (input.expired_at !== undefined)
|
|
198
|
+
body.expired_at = input.expired_at;
|
|
199
|
+
if (input.phone !== undefined)
|
|
200
|
+
body.phone = input.phone;
|
|
201
|
+
if (input.metadata !== undefined)
|
|
202
|
+
body.metadata = input.metadata;
|
|
203
|
+
return client.post("/invoices", body);
|
|
204
|
+
}
|
|
205
|
+
const READ_ONLY = { readOnlyHint: true, idempotentHint: true, openWorldHint: true };
|
|
206
|
+
const WRITE_ACTION = {
|
|
207
|
+
readOnlyHint: false,
|
|
208
|
+
destructiveHint: false,
|
|
209
|
+
idempotentHint: false,
|
|
210
|
+
openWorldHint: true,
|
|
211
|
+
};
|
|
212
|
+
export function createServer(client = new MoyasarClient()) {
|
|
213
|
+
const server = new McpServer({
|
|
214
|
+
name: "@open-mena-mcp/moyasar",
|
|
215
|
+
version: "0.1.0",
|
|
216
|
+
});
|
|
217
|
+
server.registerTool("fetch_payment", {
|
|
218
|
+
title: "Fetch Payment",
|
|
219
|
+
description: "Read-only. Fetch one Moyasar payment by its UUID (GET /payments/{id}): status, amount, fee, refunded and captured amounts, currency, source details, invoice id and metadata. Requires MOYASAR_SECRET_KEY.",
|
|
220
|
+
inputSchema: FetchPaymentInputSchema.shape,
|
|
221
|
+
annotations: READ_ONLY,
|
|
222
|
+
}, wrapTool((input) => fetchPayment(client, input)));
|
|
223
|
+
server.registerTool("list_payments", {
|
|
224
|
+
title: "List Payments",
|
|
225
|
+
description: "Read-only. List payments on the Moyasar account, newest first (GET /payments), with the documented filters: page, id, status, created/updated date ranges, metadata key, card last digits and receipt number. Returns { payments, meta } with pagination info. Requires MOYASAR_SECRET_KEY.",
|
|
226
|
+
inputSchema: ListPaymentsInputSchema.shape,
|
|
227
|
+
annotations: READ_ONLY,
|
|
228
|
+
}, wrapTool((input) => listPayments(client, input)));
|
|
229
|
+
server.registerTool("fetch_invoice", {
|
|
230
|
+
title: "Fetch Invoice",
|
|
231
|
+
description: "Read-only. Fetch one Moyasar invoice by its UUID (GET /invoices/{id}): status, amount, description, the hosted payment url, expiry and the payments made against it. Requires MOYASAR_SECRET_KEY.",
|
|
232
|
+
inputSchema: FetchInvoiceInputSchema.shape,
|
|
233
|
+
annotations: READ_ONLY,
|
|
234
|
+
}, wrapTool((input) => fetchInvoice(client, input)));
|
|
235
|
+
server.registerTool("list_invoices", {
|
|
236
|
+
title: "List Invoices",
|
|
237
|
+
description: "Read-only. List invoices on the Moyasar account, newest first (GET /invoices), with the documented filters: page, id, status, created date range and metadata key. Returns { invoices, meta } with pagination info. Requires MOYASAR_SECRET_KEY.",
|
|
238
|
+
inputSchema: ListInvoicesInputSchema.shape,
|
|
239
|
+
annotations: READ_ONLY,
|
|
240
|
+
}, wrapTool((input) => listInvoices(client, input)));
|
|
241
|
+
server.registerTool("create_invoice", {
|
|
242
|
+
title: "Create Invoice (WRITE ACTION - creates a real invoice)",
|
|
243
|
+
description: "WRITE ACTION: creates a real invoice on your Moyasar account (POST /invoices) and returns a hosted payment URL that a payer can use to pay it. This is not a draft or a preview and this server cannot delete the invoice afterwards; at most it can be cancelled from the Moyasar dashboard. It bills the payer the given amount and can send them an SMS if `phone` is set. Only call it when the user has explicitly asked to create an invoice, and confirm the amount, currency and description first. Whether real money moves depends on the key: an sk_test_ key uses the sandbox, an sk_live_ key is a live charge. Requires MOYASAR_SECRET_KEY.",
|
|
244
|
+
inputSchema: CreateInvoiceInputSchema.shape,
|
|
245
|
+
annotations: WRITE_ACTION,
|
|
246
|
+
}, wrapTool((input) => createInvoice(client, input)));
|
|
247
|
+
return server;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,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AEF,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,KAAK,EAAE,eAAe;QACtB,WAAW,EACT,kPAAkP;QACpP,WAAW,EAAE,uBAAuB,CAAC,KAAK;QAC1C,WAAW,EAAE,SAAS;KACvB,EACD,QAAQ,CAAC,CAAC,KAAwB,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACpE,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,wDAAwD;QAC/D,WAAW,EACT,2nBAA2nB;QAC7nB,WAAW,EAAE,wBAAwB,CAAC,KAAK;QAC3C,WAAW,EAAE,YAAY;KAC1B,EACD,QAAQ,CAAC,CAAC,KAAyB,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CACtE,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mena-mcp/moyasar",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for the Moyasar API: payments and invoices (read, plus invoice creation as an explicit write action).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"mcp-moyasar": "./dist/bin.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
25
|
+
"zod": "^3.25.0",
|
|
26
|
+
"@open-mena-mcp/core": "0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.7.4",
|
|
30
|
+
"typescript": "^5.6.3",
|
|
31
|
+
"vitest": "^4.1.12"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/Dinaelsayed99/open-mena-mcp.git",
|
|
36
|
+
"directory": "packages/mcp-moyasar"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/Dinaelsayed99/open-mena-mcp/tree/main/packages/mcp-moyasar#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/Dinaelsayed99/open-mena-mcp/issues"
|
|
41
|
+
},
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc -p tsconfig.build.json",
|
|
50
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
51
|
+
"lint": "eslint src",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"start": "node dist/index.js"
|
|
54
|
+
}
|
|
6
55
|
}
|