@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.
Files changed (72) hide show
  1. package/.env.example +14 -0
  2. package/README.md +223 -0
  3. package/dist/config.d.ts +19 -0
  4. package/dist/config.js +81 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/http/httpClient.d.ts +40 -0
  7. package/dist/http/httpClient.js +341 -0
  8. package/dist/http/httpClient.js.map +1 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +60 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/mcp/errors.d.ts +21 -0
  13. package/dist/mcp/errors.js +214 -0
  14. package/dist/mcp/errors.js.map +1 -0
  15. package/dist/mcp/logging.d.ts +21 -0
  16. package/dist/mcp/logging.js +241 -0
  17. package/dist/mcp/logging.js.map +1 -0
  18. package/dist/mcp/prompts.d.ts +9 -0
  19. package/dist/mcp/prompts.js +165 -0
  20. package/dist/mcp/prompts.js.map +1 -0
  21. package/dist/mcp/resources.d.ts +9 -0
  22. package/dist/mcp/resources.js +125 -0
  23. package/dist/mcp/resources.js.map +1 -0
  24. package/dist/mcp/tools_futures.d.ts +5 -0
  25. package/dist/mcp/tools_futures.js +694 -0
  26. package/dist/mcp/tools_futures.js.map +1 -0
  27. package/dist/mcp/tools_spot.d.ts +11 -0
  28. package/dist/mcp/tools_spot.js +2225 -0
  29. package/dist/mcp/tools_spot.js.map +1 -0
  30. package/dist/private/FuturesClient.d.ts +57 -0
  31. package/dist/private/FuturesClient.js +181 -0
  32. package/dist/private/FuturesClient.js.map +1 -0
  33. package/dist/private/SpotClient.d.ts +44 -0
  34. package/dist/private/SpotClient.js +201 -0
  35. package/dist/private/SpotClient.js.map +1 -0
  36. package/dist/private/ZebpayAPI.d.ts +19 -0
  37. package/dist/private/ZebpayAPI.js +172 -0
  38. package/dist/private/ZebpayAPI.js.map +1 -0
  39. package/dist/public/PublicClient.d.ts +79 -0
  40. package/dist/public/PublicClient.js +283 -0
  41. package/dist/public/PublicClient.js.map +1 -0
  42. package/dist/public/PublicFuturesClient.d.ts +27 -0
  43. package/dist/public/PublicFuturesClient.js +187 -0
  44. package/dist/public/PublicFuturesClient.js.map +1 -0
  45. package/dist/security/credentials.d.ts +42 -0
  46. package/dist/security/credentials.js +80 -0
  47. package/dist/security/credentials.js.map +1 -0
  48. package/dist/security/signing.d.ts +33 -0
  49. package/dist/security/signing.js +56 -0
  50. package/dist/security/signing.js.map +1 -0
  51. package/dist/types/responses.d.ts +130 -0
  52. package/dist/types/responses.js +6 -0
  53. package/dist/types/responses.js.map +1 -0
  54. package/dist/utils/cache.d.ts +29 -0
  55. package/dist/utils/cache.js +72 -0
  56. package/dist/utils/cache.js.map +1 -0
  57. package/dist/utils/fileLogger.d.ts +10 -0
  58. package/dist/utils/fileLogger.js +81 -0
  59. package/dist/utils/fileLogger.js.map +1 -0
  60. package/dist/utils/metrics.d.ts +35 -0
  61. package/dist/utils/metrics.js +94 -0
  62. package/dist/utils/metrics.js.map +1 -0
  63. package/dist/utils/responseFormatter.d.ts +93 -0
  64. package/dist/utils/responseFormatter.js +268 -0
  65. package/dist/utils/responseFormatter.js.map +1 -0
  66. package/dist/validation/schemas.d.ts +70 -0
  67. package/dist/validation/schemas.js +48 -0
  68. package/dist/validation/schemas.js.map +1 -0
  69. package/dist/validation/validators.d.ts +28 -0
  70. package/dist/validation/validators.js +129 -0
  71. package/dist/validation/validators.js.map +1 -0
  72. package/package.json +54 -0
@@ -0,0 +1,214 @@
1
+ /*
2
+ MCP error handling utilities using MCP SDK error types.
3
+ */
4
+ import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
5
+ /**
6
+ * Creates an MCP error for invalid parameters with helpful messages
7
+ */
8
+ export function createInvalidParamsError(message, data) {
9
+ return new McpError(ErrorCode.InvalidParams, message, data);
10
+ }
11
+ /**
12
+ * Creates an MCP error for internal/server errors
13
+ */
14
+ export function createInternalError(message, data) {
15
+ return new McpError(ErrorCode.InternalError, message, data);
16
+ }
17
+ /**
18
+ * Converts HTTP errors to appropriate MCP errors.
19
+ *
20
+ * NOTE: This is transport-agnostic - converts errors from Zebpay API (external)
21
+ * to MCP-compliant errors. Works identically for both stdio and HTTP transports.
22
+ *
23
+ * @param status HTTP status code from Zebpay API
24
+ * @param message Error message (may be HTML if from Cloudflare)
25
+ * @param details Additional error details
26
+ * @param isHtmlResponse Whether the response was HTML (for Cloudflare errors)
27
+ */
28
+ export function convertHttpErrorToMcpError(status, message, details, isHtmlResponse) {
29
+ // If message is HTML or contains HTML tags, try to extract meaningful error
30
+ if (isHtmlResponse || (typeof message === "string" && (message.includes("<!doctype") || message.includes("<html")))) {
31
+ // Try to parse HTML error
32
+ const htmlText = typeof message === "string" ? message : String(details || "");
33
+ const parsedMessage = parseHtmlError(htmlText);
34
+ if (parsedMessage) {
35
+ message = parsedMessage;
36
+ }
37
+ else {
38
+ // Fallback for HTML errors
39
+ if (htmlText.includes("Access denied") || htmlText.includes("banned")) {
40
+ message = "Access denied: Your IP address has been restricted. Please contact support or try again later.";
41
+ }
42
+ else if (htmlText.includes("Cloudflare")) {
43
+ message = "Cloudflare error: Access to the API has been restricted. Please try again later or contact support.";
44
+ }
45
+ else {
46
+ message = "API access error: The server returned an HTML error page. Please check your API credentials and try again.";
47
+ }
48
+ }
49
+ }
50
+ // 4xx errors are typically invalid parameters or requests
51
+ if (status >= 400 && status < 500) {
52
+ // 401/403 are authentication errors - treat as invalid params
53
+ if (status === 401 || status === 403) {
54
+ const userMessage = message && message !== `HTTP ${status}` && !message.startsWith("HTTP")
55
+ ? `${message}. Please check your API credentials.`
56
+ : "Authentication failed. Please check your API credentials and try again.";
57
+ return createInvalidParamsError(userMessage, { status, details });
58
+ }
59
+ // 400 is bad request - invalid params
60
+ if (status === 400) {
61
+ // Extract additional error details from response
62
+ let enhancedMessage = message;
63
+ let statusCode;
64
+ let statusDescription;
65
+ if (details && typeof details === "object") {
66
+ const detailsObj = details;
67
+ statusCode = typeof detailsObj.statusCode === "number" ? detailsObj.statusCode : undefined;
68
+ statusDescription = typeof detailsObj.statusDescription === "string"
69
+ ? detailsObj.statusDescription
70
+ : undefined;
71
+ // Handle specific API error codes
72
+ if (statusCode === 77 && statusDescription) {
73
+ // Market order minimum value error
74
+ // Extract minimum value from the error message if present
75
+ const minValueMatch = statusDescription.match(/minimum\s+([\d,]+\.?\d*)\s+(\w+)/i);
76
+ if (minValueMatch) {
77
+ const minValue = minValueMatch[1];
78
+ const currency = minValueMatch[2];
79
+ enhancedMessage = `${statusDescription} Please ensure your order value meets the minimum requirement of ${minValue} ${currency}.`;
80
+ }
81
+ else {
82
+ enhancedMessage = statusDescription;
83
+ }
84
+ }
85
+ else if (statusCode && statusDescription) {
86
+ // Use the status description with code for context
87
+ enhancedMessage = `[Error ${statusCode}] ${statusDescription}`;
88
+ }
89
+ else if (statusDescription) {
90
+ // Use the status description if available
91
+ enhancedMessage = statusDescription;
92
+ }
93
+ }
94
+ // If message already contains useful information, use it directly
95
+ // Otherwise, provide a generic message
96
+ const userMessage = enhancedMessage && enhancedMessage !== "HTTP 400" && !enhancedMessage.startsWith("HTTP")
97
+ ? enhancedMessage
98
+ : message && message !== "HTTP 400" && !message.startsWith("HTTP")
99
+ ? message
100
+ : "The request was invalid. Please check your parameters and try again.";
101
+ return createInvalidParamsError(userMessage, { status, statusCode, statusDescription, details });
102
+ }
103
+ // 404 is not found - could be invalid symbol or resource
104
+ if (status === 404) {
105
+ const userMessage = message && message !== "HTTP 404" && !message.startsWith("HTTP")
106
+ ? `${message}. Please check the symbol or resource identifier.`
107
+ : "Resource not found. Please check the symbol or resource identifier and try again.";
108
+ return createInvalidParamsError(userMessage, { status, details });
109
+ }
110
+ // 429 is rate limit - treat as internal error with retry guidance
111
+ if (status === 429) {
112
+ const userMessage = message && message !== "HTTP 429" && !message.startsWith("HTTP")
113
+ ? `Rate limit exceeded: ${message}. Please retry after a short delay.`
114
+ : "Rate limit exceeded. Please wait a moment and try again.";
115
+ return createInternalError(userMessage, { status, details, retryable: true });
116
+ }
117
+ // Other 4xx errors
118
+ const userMessage = message && message !== `HTTP ${status}` && !message.startsWith("HTTP")
119
+ ? message
120
+ : `Request error (${status}). Please check your parameters and try again.`;
121
+ return createInvalidParamsError(userMessage, { status, details });
122
+ }
123
+ // 5xx errors are server/internal errors
124
+ if (status >= 500) {
125
+ const userMessage = message && message !== `HTTP ${status}` && !message.startsWith("HTTP")
126
+ ? `Zebpay API server error: ${message}. Please try again later.`
127
+ : `Zebpay API server error (${status}). The server encountered an issue. Please try again later.`;
128
+ return createInternalError(userMessage, { status, details, retryable: true });
129
+ }
130
+ // Network errors (status 0) or other errors
131
+ const userMessage = message && message !== "Network error" && message !== "Unknown API error"
132
+ ? `Network error: ${message}. Please check your connection and try again.`
133
+ : "Network error. Please check your internet connection and try again.";
134
+ return createInternalError(userMessage, { status, details, retryable: true });
135
+ }
136
+ /**
137
+ * Parses HTML error pages (like Cloudflare) to extract user-friendly error messages.
138
+ *
139
+ * NOTE: Transport-agnostic - parses HTML responses from Zebpay API (external),
140
+ * not from MCP clients. Works for both stdio and HTTP transports.
141
+ */
142
+ function parseHtmlError(html) {
143
+ if (!html || typeof html !== "string") {
144
+ return null;
145
+ }
146
+ // Check if it's HTML
147
+ if (!html.trim().toLowerCase().startsWith("<!doctype") && !html.trim().toLowerCase().startsWith("<html")) {
148
+ return null;
149
+ }
150
+ // Extract Cloudflare error messages
151
+ const cloudflarePatterns = [
152
+ // Cloudflare Error 1006 - Access denied
153
+ /<h2[^>]*>Access denied<\/h2>/i,
154
+ /The owner of this website.*?has banned your IP address[^<]*/i,
155
+ /<p[^>]*>The owner of this website[^<]*<\/p>/i,
156
+ // Cloudflare Error 1020 - Access denied
157
+ /<h1[^>]*>Error[^<]*<\/h1>/i,
158
+ // Generic error extraction from title
159
+ /<title>([^<]+)<\/title>/i,
160
+ // Extract error messages from h1/h2 tags
161
+ /<h[12][^>]*>([^<]+)<\/h[12]>/i,
162
+ ];
163
+ for (const pattern of cloudflarePatterns) {
164
+ const match = html.match(pattern);
165
+ if (match) {
166
+ let message = match[1] || match[0];
167
+ // Clean up HTML entities and tags
168
+ message = message
169
+ .replace(/<[^>]+>/g, "")
170
+ .replace(/&nbsp;/g, " ")
171
+ .replace(/&amp;/g, "&")
172
+ .replace(/&lt;/g, "<")
173
+ .replace(/&gt;/g, ">")
174
+ .replace(/&quot;/g, '"')
175
+ .replace(/\s+/g, " ")
176
+ .trim();
177
+ if (message && message.length > 10) {
178
+ // Check for IP ban message
179
+ if (html.includes("banned your IP address")) {
180
+ const ipMatch = html.match(/IP address[^<]*\(([^)]+)\)/i);
181
+ if (ipMatch) {
182
+ return `Access denied: Your IP address has been banned by the website. Please contact support or try again later.`;
183
+ }
184
+ return `Access denied: Your IP address has been restricted. Please contact support or try again later.`;
185
+ }
186
+ // Check for Cloudflare error codes
187
+ const errorCodeMatch = html.match(/Error\s*(\d+)/i);
188
+ if (errorCodeMatch) {
189
+ const errorCode = errorCodeMatch[1];
190
+ if (errorCode === "1006") {
191
+ return `Access denied (Error 1006): Your IP address has been banned. Please contact support or try again later.`;
192
+ }
193
+ return `Cloudflare error (${errorCode}): ${message}`;
194
+ }
195
+ return message;
196
+ }
197
+ }
198
+ }
199
+ // Fallback: try to extract any meaningful text
200
+ const textMatch = html.match(/<body[^>]*>([\s\S]{100,500})<\/body>/i);
201
+ if (textMatch) {
202
+ let text = textMatch[1]
203
+ .replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "")
204
+ .replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "")
205
+ .replace(/<[^>]+>/g, " ")
206
+ .replace(/\s+/g, " ")
207
+ .trim();
208
+ if (text.length > 20 && text.length < 200) {
209
+ return text;
210
+ }
211
+ }
212
+ return null;
213
+ }
214
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/mcp/errors.ts"],"names":[],"mappings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CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface LogContext {
2
+ toolName: string;
3
+ logLevel: "debug" | "info" | "warn" | "error";
4
+ correlationId?: string;
5
+ }
6
+ /**
7
+ * Logs MCP tool request with parameters
8
+ */
9
+ export declare function logMcpRequest(context: LogContext, params: unknown): void;
10
+ /**
11
+ * Logs MCP tool response (success)
12
+ */
13
+ export declare function logMcpResponse(context: LogContext, params: unknown, result: unknown, durationMs: number): void;
14
+ /**
15
+ * Logs MCP tool error response
16
+ */
17
+ export declare function logMcpError(context: LogContext, params: unknown, error: unknown, durationMs: number): void;
18
+ /**
19
+ * Wraps an MCP tool handler with request/response logging
20
+ */
21
+ export declare function withLogging<TParams, TResult>(toolName: string, logLevel: "debug" | "info" | "warn" | "error", handler: (params: TParams) => Promise<TResult>): (params: TParams) => Promise<TResult>;
@@ -0,0 +1,241 @@
1
+ /*
2
+ MCP request/response logging utility for tracing and debugging.
3
+ */
4
+ import { fileLogger } from "../utils/fileLogger.js";
5
+ import { generateCorrelationId } from "../utils/responseFormatter.js";
6
+ import { McpError } from "@modelcontextprotocol/sdk/types.js";
7
+ /**
8
+ * Logs MCP tool request with parameters
9
+ */
10
+ export function logMcpRequest(context, params) {
11
+ try {
12
+ const { toolName, logLevel, correlationId } = context;
13
+ const timestamp = new Date().toISOString();
14
+ const logMessage = JSON.stringify({
15
+ level: "info",
16
+ type: "mcp_request",
17
+ timestamp,
18
+ tool: toolName,
19
+ correlationId: correlationId || generateCorrelationId(),
20
+ params: sanitizeParams(params),
21
+ });
22
+ fileLogger.log(logMessage);
23
+ }
24
+ catch (error) {
25
+ // Silently fail logging to prevent breaking the application
26
+ console.error(`[LOG ERROR] Failed to log MCP request: ${error instanceof Error ? error.message : String(error)}`);
27
+ }
28
+ }
29
+ /**
30
+ * Logs MCP tool response (success)
31
+ */
32
+ export function logMcpResponse(context, params, result, durationMs) {
33
+ try {
34
+ const { toolName, logLevel, correlationId } = context;
35
+ const timestamp = new Date().toISOString();
36
+ const logMessage = JSON.stringify({
37
+ level: "info",
38
+ type: "mcp_response",
39
+ timestamp,
40
+ tool: toolName,
41
+ correlationId: correlationId || generateCorrelationId(),
42
+ params: sanitizeParams(params),
43
+ success: true,
44
+ durationMs,
45
+ result: sanitizeResult(result),
46
+ });
47
+ fileLogger.log(logMessage);
48
+ }
49
+ catch (error) {
50
+ // Silently fail logging to prevent breaking the application
51
+ console.error(`[LOG ERROR] Failed to log MCP response: ${error instanceof Error ? error.message : String(error)}`);
52
+ }
53
+ }
54
+ /**
55
+ * Sanitizes stack traces by removing file paths, keeping only function names and line numbers
56
+ */
57
+ function sanitizeStack(stack) {
58
+ if (!stack)
59
+ return undefined;
60
+ try {
61
+ // Remove file:// URLs and absolute paths, keep only filename and line numbers
62
+ const lines = stack.split('\n');
63
+ const sanitizedLines = lines.map(line => {
64
+ let sanitized = line;
65
+ // Remove file:// URLs (e.g., file:///Users/path/to/file.js:123:45)
66
+ sanitized = sanitized.replace(/file:\/\/\/[^\s\)]+/g, (match) => {
67
+ // Extract just the filename and line numbers
68
+ const filenameMatch = match.match(/([^\/]+\.(js|ts|mjs|cjs)):(\d+):(\d+)/);
69
+ if (filenameMatch) {
70
+ return `${filenameMatch[1]}:${filenameMatch[3]}:${filenameMatch[4]}`;
71
+ }
72
+ return '';
73
+ });
74
+ // Remove absolute paths (e.g., /Users/path/to/file.js:123:45)
75
+ sanitized = sanitized.replace(/\/(?:[^\/\s]+\/)+([^\/\s]+\.(js|ts|mjs|cjs)):(\d+):(\d+)/g, '$1:$3:$4');
76
+ // Simplify node_modules paths (e.g., node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js)
77
+ sanitized = sanitized.replace(/node_modules\/([^\/\s]+)\/[^\s\)]+/g, 'node_modules/$1');
78
+ return sanitized.trim();
79
+ });
80
+ return sanitizedLines.join('\n');
81
+ }
82
+ catch {
83
+ // If sanitization fails, return a minimal version without paths
84
+ return stack.split('\n').slice(0, 3).join('\n'); // Keep only first 3 lines
85
+ }
86
+ }
87
+ /**
88
+ * Logs MCP tool error response
89
+ */
90
+ export function logMcpError(context, params, error, durationMs) {
91
+ try {
92
+ const { toolName, logLevel, correlationId } = context;
93
+ const timestamp = new Date().toISOString();
94
+ // Extract error details
95
+ let errorMessage = error instanceof Error ? error.message : String(error);
96
+ let errorStack = error instanceof Error ? error.stack : undefined;
97
+ let errorCode;
98
+ let errorData;
99
+ // If it's an MCP error, extract additional details
100
+ if (error instanceof McpError) {
101
+ errorCode = error.code;
102
+ errorData = error.data;
103
+ // MCP errors have a formatted message, use it directly
104
+ errorMessage = error.message;
105
+ }
106
+ else if (error && typeof error === "object" && "code" in error) {
107
+ // Check if it's an MCP error-like object (from SDK)
108
+ errorCode = typeof error.code === "number" ? error.code : undefined;
109
+ if ("data" in error) {
110
+ errorData = error.data;
111
+ }
112
+ }
113
+ const logMessage = JSON.stringify({
114
+ level: "error",
115
+ type: "mcp_error",
116
+ timestamp,
117
+ tool: toolName,
118
+ correlationId: correlationId || generateCorrelationId(),
119
+ params: sanitizeParams(params),
120
+ success: false,
121
+ durationMs,
122
+ error: errorMessage,
123
+ ...(errorCode !== undefined && { errorCode }),
124
+ ...(errorData !== undefined && { errorData: sanitizeParams(errorData) }),
125
+ ...(errorStack && { stack: sanitizeStack(errorStack) }),
126
+ });
127
+ fileLogger.log(logMessage);
128
+ }
129
+ catch (logError) {
130
+ // Silently fail logging to prevent breaking the application
131
+ console.error(`[LOG ERROR] Failed to log MCP error: ${logError instanceof Error ? logError.message : String(logError)}`);
132
+ }
133
+ }
134
+ /**
135
+ * Wraps an MCP tool handler with request/response logging
136
+ */
137
+ export function withLogging(toolName, logLevel, handler) {
138
+ return async (params) => {
139
+ const correlationId = generateCorrelationId();
140
+ const context = { toolName, logLevel, correlationId };
141
+ const startTime = Date.now();
142
+ // Log request
143
+ logMcpRequest(context, params);
144
+ try {
145
+ // Execute handler
146
+ const result = await handler(params);
147
+ const durationMs = Date.now() - startTime;
148
+ // Log successful response
149
+ logMcpResponse(context, params, result, durationMs);
150
+ return result;
151
+ }
152
+ catch (error) {
153
+ const durationMs = Date.now() - startTime;
154
+ // Log error response
155
+ logMcpError(context, params, error, durationMs);
156
+ // Re-throw error
157
+ throw error;
158
+ }
159
+ };
160
+ }
161
+ /**
162
+ * Sanitizes parameters to remove sensitive data
163
+ */
164
+ function sanitizeParams(params) {
165
+ try {
166
+ if (!params || typeof params !== "object") {
167
+ return params;
168
+ }
169
+ const sanitized = {};
170
+ const sensitiveKeys = ["apiKey", "secret", "password", "token", "authorization"];
171
+ for (const [key, value] of Object.entries(params)) {
172
+ const lowerKey = key.toLowerCase();
173
+ if (sensitiveKeys.some((sk) => lowerKey.includes(sk))) {
174
+ sanitized[key] = "<redacted>";
175
+ }
176
+ else {
177
+ sanitized[key] = value;
178
+ }
179
+ }
180
+ return sanitized;
181
+ }
182
+ catch (error) {
183
+ // If sanitization fails, return a safe fallback
184
+ return { error: "Failed to sanitize params", original: String(params) };
185
+ }
186
+ }
187
+ /**
188
+ * Sanitizes result to prevent logging huge responses
189
+ */
190
+ function sanitizeResult(result) {
191
+ try {
192
+ if (!result) {
193
+ return result;
194
+ }
195
+ // If result is a string, check if it's JSON and limit size
196
+ if (typeof result === "string") {
197
+ if (result.length > 10000) {
198
+ return result.substring(0, 10000) + "... [truncated]";
199
+ }
200
+ return result;
201
+ }
202
+ // If result is an object with content array (MCP response format)
203
+ if (typeof result === "object" && result !== null) {
204
+ const obj = result;
205
+ if (Array.isArray(obj.content)) {
206
+ const sanitizedContent = obj.content.map((item) => {
207
+ if (typeof item === "object" && item !== null) {
208
+ const itemObj = item;
209
+ if (typeof itemObj.text === "string" && itemObj.text.length > 10000) {
210
+ return {
211
+ ...itemObj,
212
+ text: itemObj.text.substring(0, 10000) + "... [truncated]",
213
+ };
214
+ }
215
+ }
216
+ return item;
217
+ });
218
+ return {
219
+ ...obj,
220
+ content: sanitizedContent,
221
+ };
222
+ }
223
+ }
224
+ // For other objects, stringify and limit size
225
+ try {
226
+ const jsonStr = JSON.stringify(result);
227
+ if (jsonStr.length > 10000) {
228
+ return JSON.parse(jsonStr.substring(0, 10000) + '..."}');
229
+ }
230
+ return result;
231
+ }
232
+ catch {
233
+ return result;
234
+ }
235
+ }
236
+ catch (error) {
237
+ // If sanitization fails, return a safe fallback
238
+ return { error: "Failed to sanitize result", type: typeof result };
239
+ }
240
+ }
241
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/mcp/logging.ts"],"names":[],"mappings":"AAAA;;EAEE;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAQ9D;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAmB,EAAE,MAAe;IAChE,IAAI,CAAC;QACL,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;QACtD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE3C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;YAChC,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,aAAa;YACnB,SAAS;YACT,IAAI,EAAE,QAAQ;YACd,aAAa,EAAE,aAAa,IAAI,qBAAqB,EAAE;YACvD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC;SAC/B,CAAC,CAAC;QAEH,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4DAA4D;QAC5D,OAAO,CAAC,KAAK,CAAC,0CAA0C,KAAK,YAAY,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AAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,CAAC;QACd,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gDAAgD;QAChD,OAAO,EAAE,KAAK,EAAE,2BAA2B,EAAE,IAAI,EAAE,OAAO,MAAM,EAAE,CAAC;IACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { SpotClient } from "../private/SpotClient.js";
3
+ import { PublicClient } from "../public/PublicClient.js";
4
+ import { AppConfig } from "../config.js";
5
+ /**
6
+ * Registers MCP prompts for common Zebpay trading workflows.
7
+ * Prompts help LLMs understand common use cases and provide structured guidance.
8
+ */
9
+ export declare function registerPrompts(server: McpServer, spot: SpotClient | null, publicClient: PublicClient, config: AppConfig): void;