@zebpay_rajesh/zebpay-mcp-server 1.0.3
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/.env.example +14 -0
- package/README.md +223 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +81 -0
- package/dist/config.js.map +1 -0
- package/dist/http/httpClient.d.ts +40 -0
- package/dist/http/httpClient.js +341 -0
- package/dist/http/httpClient.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +21 -0
- package/dist/mcp/errors.js +214 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/logging.d.ts +21 -0
- package/dist/mcp/logging.js +241 -0
- package/dist/mcp/logging.js.map +1 -0
- package/dist/mcp/prompts.d.ts +9 -0
- package/dist/mcp/prompts.js +165 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +9 -0
- package/dist/mcp/resources.js +125 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/tools_futures.d.ts +5 -0
- package/dist/mcp/tools_futures.js +694 -0
- package/dist/mcp/tools_futures.js.map +1 -0
- package/dist/mcp/tools_spot.d.ts +11 -0
- package/dist/mcp/tools_spot.js +2225 -0
- package/dist/mcp/tools_spot.js.map +1 -0
- package/dist/private/FuturesClient.d.ts +57 -0
- package/dist/private/FuturesClient.js +181 -0
- package/dist/private/FuturesClient.js.map +1 -0
- package/dist/private/SpotClient.d.ts +44 -0
- package/dist/private/SpotClient.js +201 -0
- package/dist/private/SpotClient.js.map +1 -0
- package/dist/private/ZebpayAPI.d.ts +19 -0
- package/dist/private/ZebpayAPI.js +172 -0
- package/dist/private/ZebpayAPI.js.map +1 -0
- package/dist/public/PublicClient.d.ts +79 -0
- package/dist/public/PublicClient.js +283 -0
- package/dist/public/PublicClient.js.map +1 -0
- package/dist/public/PublicFuturesClient.d.ts +27 -0
- package/dist/public/PublicFuturesClient.js +187 -0
- package/dist/public/PublicFuturesClient.js.map +1 -0
- package/dist/security/credentials.d.ts +42 -0
- package/dist/security/credentials.js +80 -0
- package/dist/security/credentials.js.map +1 -0
- package/dist/security/signing.d.ts +33 -0
- package/dist/security/signing.js +56 -0
- package/dist/security/signing.js.map +1 -0
- package/dist/types/responses.d.ts +130 -0
- package/dist/types/responses.js +6 -0
- package/dist/types/responses.js.map +1 -0
- package/dist/utils/cache.d.ts +29 -0
- package/dist/utils/cache.js +72 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/fileLogger.d.ts +10 -0
- package/dist/utils/fileLogger.js +81 -0
- package/dist/utils/fileLogger.js.map +1 -0
- package/dist/utils/metrics.d.ts +35 -0
- package/dist/utils/metrics.js +94 -0
- package/dist/utils/metrics.js.map +1 -0
- package/dist/utils/responseFormatter.d.ts +93 -0
- package/dist/utils/responseFormatter.js +268 -0
- package/dist/utils/responseFormatter.js.map +1 -0
- package/dist/validation/schemas.d.ts +70 -0
- package/dist/validation/schemas.js +48 -0
- package/dist/validation/schemas.js.map +1 -0
- package/dist/validation/validators.d.ts +28 -0
- package/dist/validation/validators.js +129 -0
- package/dist/validation/validators.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const sideEnum: z.ZodEnum<{
|
|
3
|
+
buy: "buy";
|
|
4
|
+
sell: "sell";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const orderTypeEnum: z.ZodEnum<{
|
|
7
|
+
limit: "limit";
|
|
8
|
+
market: "market";
|
|
9
|
+
}>;
|
|
10
|
+
export declare const spotPlaceOrderInput: z.ZodObject<{
|
|
11
|
+
symbol: z.ZodString;
|
|
12
|
+
side: z.ZodEnum<{
|
|
13
|
+
buy: "buy";
|
|
14
|
+
sell: "sell";
|
|
15
|
+
}>;
|
|
16
|
+
type: z.ZodEnum<{
|
|
17
|
+
limit: "limit";
|
|
18
|
+
market: "market";
|
|
19
|
+
}>;
|
|
20
|
+
quantity: z.ZodString;
|
|
21
|
+
price: z.ZodOptional<z.ZodString>;
|
|
22
|
+
clientOrderId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const spotCancelOrderInput: z.ZodObject<{
|
|
25
|
+
orderId: z.ZodString;
|
|
26
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export declare const spotBalancesOutput: z.ZodObject<{
|
|
29
|
+
balances: z.ZodArray<z.ZodObject<{
|
|
30
|
+
asset: z.ZodString;
|
|
31
|
+
free: z.ZodString;
|
|
32
|
+
locked: z.ZodString;
|
|
33
|
+
}, z.core.$strip>>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const futuresPlaceOrderInput: z.ZodObject<{
|
|
36
|
+
symbol: z.ZodString;
|
|
37
|
+
side: z.ZodEnum<{
|
|
38
|
+
buy: "buy";
|
|
39
|
+
sell: "sell";
|
|
40
|
+
}>;
|
|
41
|
+
type: z.ZodEnum<{
|
|
42
|
+
limit: "limit";
|
|
43
|
+
market: "market";
|
|
44
|
+
}>;
|
|
45
|
+
quantity: z.ZodString;
|
|
46
|
+
price: z.ZodOptional<z.ZodString>;
|
|
47
|
+
leverage: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
clientOrderId: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export declare const futuresCancelOrderInput: z.ZodObject<{
|
|
51
|
+
orderId: z.ZodString;
|
|
52
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const futuresPositionsOutput: z.ZodObject<{
|
|
55
|
+
positions: z.ZodArray<z.ZodObject<{
|
|
56
|
+
symbol: z.ZodString;
|
|
57
|
+
positionSide: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
long: "long";
|
|
59
|
+
short: "short";
|
|
60
|
+
}>>;
|
|
61
|
+
quantity: z.ZodString;
|
|
62
|
+
entryPrice: z.ZodOptional<z.ZodString>;
|
|
63
|
+
unrealizedPnl: z.ZodOptional<z.ZodString>;
|
|
64
|
+
leverage: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type SpotPlaceOrderInput = z.infer<typeof spotPlaceOrderInput>;
|
|
68
|
+
export type SpotCancelOrderInput = z.infer<typeof spotCancelOrderInput>;
|
|
69
|
+
export type FuturesPlaceOrderInput = z.infer<typeof futuresPlaceOrderInput>;
|
|
70
|
+
export type FuturesCancelOrderInput = z.infer<typeof futuresCancelOrderInput>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Zod schemas for inputs/outputs. These validate tool params and normalize outputs.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
// Shared enums
|
|
6
|
+
export const sideEnum = z.enum(["buy", "sell"]);
|
|
7
|
+
export const orderTypeEnum = z.enum(["market", "limit"]);
|
|
8
|
+
// Spot
|
|
9
|
+
export const spotPlaceOrderInput = z.object({
|
|
10
|
+
symbol: z.string().min(1),
|
|
11
|
+
side: sideEnum,
|
|
12
|
+
type: orderTypeEnum,
|
|
13
|
+
quantity: z.string().min(1),
|
|
14
|
+
price: z.string().optional(),
|
|
15
|
+
clientOrderId: z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
export const spotCancelOrderInput = z.object({
|
|
18
|
+
orderId: z.string().min(1),
|
|
19
|
+
symbol: z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
export const spotBalancesOutput = z.object({
|
|
22
|
+
balances: z.array(z.object({ asset: z.string(), free: z.string(), locked: z.string() })),
|
|
23
|
+
});
|
|
24
|
+
// Futures
|
|
25
|
+
export const futuresPlaceOrderInput = z.object({
|
|
26
|
+
symbol: z.string().min(1),
|
|
27
|
+
side: sideEnum,
|
|
28
|
+
type: orderTypeEnum,
|
|
29
|
+
quantity: z.string().min(1),
|
|
30
|
+
price: z.string().optional(),
|
|
31
|
+
leverage: z.number().int().positive().max(125).optional(),
|
|
32
|
+
clientOrderId: z.string().optional(),
|
|
33
|
+
});
|
|
34
|
+
export const futuresCancelOrderInput = z.object({
|
|
35
|
+
orderId: z.string().min(1),
|
|
36
|
+
symbol: z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
export const futuresPositionsOutput = z.object({
|
|
39
|
+
positions: z.array(z.object({
|
|
40
|
+
symbol: z.string(),
|
|
41
|
+
positionSide: z.enum(["long", "short"]).optional(),
|
|
42
|
+
quantity: z.string(),
|
|
43
|
+
entryPrice: z.string().optional(),
|
|
44
|
+
unrealizedPnl: z.string().optional(),
|
|
45
|
+
leverage: z.number().int().positive().optional(),
|
|
46
|
+
})),
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/validation/schemas.ts"],"names":[],"mappings":"AAAA;;EAEE;AAEF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAe;AACf,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAEzD,OAAO;AACP,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE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AAC;IAC9C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,SAAS,EAAE,CAAC,CAAC,KAAK,CAChB,CAAC,CAAC,MAAM,CAAC;QACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;QAClB,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;QAClD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACjC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACpC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;KACjD,CAAC,CACH;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Validates trading pair symbol format (BASE-QUOTE)
|
|
4
|
+
* Examples: BTC-INR, ETH-INR, BTC-USDT
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateSymbol(symbol: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Validates quantity string format
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateQuantity(quantity: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Zod schema for symbol validation
|
|
13
|
+
*/
|
|
14
|
+
export declare const symbolSchema: z.ZodString;
|
|
15
|
+
/**
|
|
16
|
+
* Zod schema for quantity validation
|
|
17
|
+
*/
|
|
18
|
+
export declare const quantitySchema: z.ZodString;
|
|
19
|
+
/**
|
|
20
|
+
* Validates clientOrderId format
|
|
21
|
+
* Must contain only letters, numbers, dots, colons, slashes, underscores, and hyphens
|
|
22
|
+
* Length must be between 1-36 characters
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateClientOrderId(clientOrderId: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Zod schema for clientOrderId validation
|
|
27
|
+
*/
|
|
28
|
+
export declare const clientOrderIdSchema: z.ZodString;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Input validation helpers with helpful error messages for LLMs.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createInvalidParamsError } from "../mcp/errors.js";
|
|
6
|
+
/**
|
|
7
|
+
* Validates trading pair symbol format (BASE-QUOTE)
|
|
8
|
+
* Examples: BTC-INR, ETH-INR, BTC-USDT
|
|
9
|
+
*/
|
|
10
|
+
export function validateSymbol(symbol) {
|
|
11
|
+
if (!symbol || typeof symbol !== "string") {
|
|
12
|
+
throw createInvalidParamsError(`Invalid symbol: must be a non-empty string. Expected format: BASE-QUOTE (e.g., "BTC-INR", "ETH-INR")`);
|
|
13
|
+
}
|
|
14
|
+
const trimmed = symbol.trim().toUpperCase();
|
|
15
|
+
const parts = trimmed.split("-");
|
|
16
|
+
if (parts.length !== 2) {
|
|
17
|
+
throw createInvalidParamsError(`Invalid symbol format: "${symbol}". Expected format: BASE-QUOTE (e.g., "BTC-INR", "ETH-INR", "BTC-USDT"). Use uppercase currency codes separated by a single hyphen.`);
|
|
18
|
+
}
|
|
19
|
+
const [base, quote] = parts;
|
|
20
|
+
if (!base || base.length === 0) {
|
|
21
|
+
throw createInvalidParamsError(`Invalid symbol: base currency is missing. Expected format: BASE-QUOTE (e.g., "BTC-INR")`);
|
|
22
|
+
}
|
|
23
|
+
if (!quote || quote.length === 0) {
|
|
24
|
+
throw createInvalidParamsError(`Invalid symbol: quote currency is missing. Expected format: BASE-QUOTE (e.g., "BTC-INR")`);
|
|
25
|
+
}
|
|
26
|
+
// Check for valid currency code format (alphanumeric, typically 2-10 characters)
|
|
27
|
+
const currencyCodeRegex = /^[A-Z0-9]{2,10}$/;
|
|
28
|
+
if (!currencyCodeRegex.test(base)) {
|
|
29
|
+
throw createInvalidParamsError(`Invalid base currency code: "${base}". Currency codes should be 2-10 uppercase alphanumeric characters (e.g., "BTC", "ETH", "USDT")`);
|
|
30
|
+
}
|
|
31
|
+
if (!currencyCodeRegex.test(quote)) {
|
|
32
|
+
throw createInvalidParamsError(`Invalid quote currency code: "${quote}". Currency codes should be 2-10 uppercase alphanumeric characters (e.g., "INR", "USDT", "BTC")`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates quantity string format
|
|
37
|
+
*/
|
|
38
|
+
export function validateQuantity(quantity) {
|
|
39
|
+
if (!quantity || typeof quantity !== "string") {
|
|
40
|
+
throw createInvalidParamsError(`Invalid quantity: must be a non-empty string. This prevents floating-point precision issues. Example: "0.001" or "100"`);
|
|
41
|
+
}
|
|
42
|
+
const trimmed = quantity.trim();
|
|
43
|
+
if (trimmed.length === 0) {
|
|
44
|
+
throw createInvalidParamsError(`Invalid quantity: cannot be empty. Provide a positive number as a string (e.g., "0.001", "100", "0.5")`);
|
|
45
|
+
}
|
|
46
|
+
// Check if it's a valid number format
|
|
47
|
+
const numberRegex = /^-?\d+(\.\d+)?$/;
|
|
48
|
+
if (!numberRegex.test(trimmed)) {
|
|
49
|
+
throw createInvalidParamsError(`Invalid quantity format: "${quantity}". Expected a positive number as a string. Examples: "0.001", "100", "0.5". Do not include commas or other formatting.`);
|
|
50
|
+
}
|
|
51
|
+
// Check if it's positive
|
|
52
|
+
const numValue = parseFloat(trimmed);
|
|
53
|
+
if (isNaN(numValue)) {
|
|
54
|
+
throw createInvalidParamsError(`Invalid quantity: "${quantity}" is not a valid number. Provide a positive number as a string (e.g., "0.001")`);
|
|
55
|
+
}
|
|
56
|
+
if (numValue <= 0) {
|
|
57
|
+
throw createInvalidParamsError(`Invalid quantity: "${quantity}" must be greater than zero. Provide a positive number as a string (e.g., "0.001", "100")`);
|
|
58
|
+
}
|
|
59
|
+
// Check for reasonable precision (typically up to 8 decimal places for crypto)
|
|
60
|
+
const decimalParts = trimmed.split(".");
|
|
61
|
+
if (decimalParts.length === 2 && decimalParts[1].length > 18) {
|
|
62
|
+
throw createInvalidParamsError(`Invalid quantity precision: "${quantity}" has too many decimal places (max 18). Example: "0.001" or "100.123456789012345678"`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Zod schema for symbol validation
|
|
67
|
+
*/
|
|
68
|
+
export const symbolSchema = z.string().min(1).refine((val) => {
|
|
69
|
+
try {
|
|
70
|
+
validateSymbol(val);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
message: 'Invalid symbol format. Expected BASE-QUOTE (e.g., "BTC-INR", "ETH-INR")',
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Zod schema for quantity validation
|
|
81
|
+
*/
|
|
82
|
+
export const quantitySchema = z.string().min(1).refine((val) => {
|
|
83
|
+
try {
|
|
84
|
+
validateQuantity(val);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
message: 'Invalid quantity format. Expected a positive number as a string (e.g., "0.001", "100")',
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Validates clientOrderId format
|
|
95
|
+
* Must contain only letters, numbers, dots, colons, slashes, underscores, and hyphens
|
|
96
|
+
* Length must be between 1-36 characters
|
|
97
|
+
*/
|
|
98
|
+
export function validateClientOrderId(clientOrderId) {
|
|
99
|
+
if (!clientOrderId || typeof clientOrderId !== "string") {
|
|
100
|
+
throw createInvalidParamsError(`Invalid clientOrderId: must be a non-empty string`);
|
|
101
|
+
}
|
|
102
|
+
const trimmed = clientOrderId.trim();
|
|
103
|
+
if (trimmed.length === 0) {
|
|
104
|
+
throw createInvalidParamsError(`Invalid clientOrderId: cannot be empty`);
|
|
105
|
+
}
|
|
106
|
+
if (trimmed.length > 36) {
|
|
107
|
+
throw createInvalidParamsError(`Invalid clientOrderId: "${clientOrderId}" exceeds maximum length of 36 characters (current: ${trimmed.length})`);
|
|
108
|
+
}
|
|
109
|
+
// Must contain only letters, numbers, dots, colons, slashes, underscores, and hyphens
|
|
110
|
+
const validFormat = /^[a-zA-Z0-9.:/_\-]+$/;
|
|
111
|
+
if (!validFormat.test(trimmed)) {
|
|
112
|
+
throw createInvalidParamsError(`Invalid clientOrderId format: "${clientOrderId}". Must contain only letters, numbers, dots, colons, slashes, underscores, and hyphens. Examples: "my-order-123", "order:2024/01/15_001", "trade.abc-123"`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Zod schema for clientOrderId validation
|
|
117
|
+
*/
|
|
118
|
+
export const clientOrderIdSchema = z.string().min(1).max(36).refine((val) => {
|
|
119
|
+
try {
|
|
120
|
+
validateClientOrderId(val);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
message: 'Invalid clientOrderId format. Must be 1-36 characters and contain only letters, numbers, dots, colons, slashes, underscores, and hyphens',
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/validation/validators.ts"],"names":[],"mappings":"AAAA;;EAEE;AAEF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,CA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AC,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CACjE,CAAC,GAAG,EAAE,EAAE;IACN,IAAI,CAAC;QACH,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,EACD;IACE,OAAO,EAAE,0IAA0I;CACpJ,CACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zebpay_rajesh/zebpay-mcp-server",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"mcpName": "io.github.ZebpayRajesh/zebpay-mcp-server",
|
|
5
|
+
"author": "Rajesh.K",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json",
|
|
11
|
+
"start": "node dist/index.js",
|
|
12
|
+
"start:log": "node dist/index.js 2> logs/mcp-server.log",
|
|
13
|
+
"start:log-append": "node dist/index.js 2>> logs/mcp-server.log",
|
|
14
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
15
|
+
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
|
|
16
|
+
"logs": "node scripts/log-viewer.js",
|
|
17
|
+
"logs:watch": "node scripts/log-viewer.js --watch",
|
|
18
|
+
"logs:errors": "node scripts/log-viewer.js --errors",
|
|
19
|
+
"logs:http": "node scripts/log-viewer.js --type=http",
|
|
20
|
+
"logs:mcp": "node scripts/log-viewer.js --type=mcp",
|
|
21
|
+
"logs:stats": "node scripts/log-stats.js",
|
|
22
|
+
"logs:clear": "node scripts/clear-logs.js"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
26
|
+
"dotenv": "^17.3.1",
|
|
27
|
+
"undici": "^7.22.0",
|
|
28
|
+
"zod": "^4.3.6"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jest": "^30.0.0",
|
|
32
|
+
"@types/node": "^25.3.5",
|
|
33
|
+
"jest": "^30.2.0",
|
|
34
|
+
"ts-jest": "^29.4.6",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"jest": {
|
|
38
|
+
"preset": "ts-jest/presets/default-esm",
|
|
39
|
+
"extensionsToTreatAsEsm": [
|
|
40
|
+
".ts"
|
|
41
|
+
],
|
|
42
|
+
"moduleNameMapper": {
|
|
43
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
44
|
+
},
|
|
45
|
+
"testMatch": [
|
|
46
|
+
"**/__tests__/**/*.test.ts"
|
|
47
|
+
],
|
|
48
|
+
"collectCoverageFrom": [
|
|
49
|
+
"src/**/*.ts",
|
|
50
|
+
"!src/**/*.d.ts",
|
|
51
|
+
"!src/__tests__/**"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|