@respond-io/mcp-server 1.0.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +635 -0
  4. package/dist/constants.d.ts +89 -0
  5. package/dist/constants.d.ts.map +1 -0
  6. package/dist/constants.js +143 -0
  7. package/dist/constants.js.map +1 -0
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +40 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/middlewares/TokenVerifier.d.ts +19 -0
  13. package/dist/middlewares/TokenVerifier.d.ts.map +1 -0
  14. package/dist/middlewares/TokenVerifier.js +68 -0
  15. package/dist/middlewares/TokenVerifier.js.map +1 -0
  16. package/dist/protocol/BaseProtocol.d.ts +4 -0
  17. package/dist/protocol/BaseProtocol.d.ts.map +1 -0
  18. package/dist/protocol/BaseProtocol.js +7 -0
  19. package/dist/protocol/BaseProtocol.js.map +1 -0
  20. package/dist/protocol/HttpStreamProtocol.d.ts +36 -0
  21. package/dist/protocol/HttpStreamProtocol.d.ts.map +1 -0
  22. package/dist/protocol/HttpStreamProtocol.js +148 -0
  23. package/dist/protocol/HttpStreamProtocol.js.map +1 -0
  24. package/dist/protocol/StdioProtocol.d.ts +14 -0
  25. package/dist/protocol/StdioProtocol.d.ts.map +1 -0
  26. package/dist/protocol/StdioProtocol.js +32 -0
  27. package/dist/protocol/StdioProtocol.js.map +1 -0
  28. package/dist/protocol/index.d.ts +4 -0
  29. package/dist/protocol/index.d.ts.map +1 -0
  30. package/dist/protocol/index.js +4 -0
  31. package/dist/protocol/index.js.map +1 -0
  32. package/dist/server.d.ts +13 -0
  33. package/dist/server.d.ts.map +1 -0
  34. package/dist/server.js +36 -0
  35. package/dist/server.js.map +1 -0
  36. package/dist/tools/BaseTool.d.ts +38 -0
  37. package/dist/tools/BaseTool.d.ts.map +1 -0
  38. package/dist/tools/BaseTool.js +39 -0
  39. package/dist/tools/BaseTool.js.map +1 -0
  40. package/dist/tools/comment.tool.d.ts +14 -0
  41. package/dist/tools/comment.tool.d.ts.map +1 -0
  42. package/dist/tools/comment.tool.js +43 -0
  43. package/dist/tools/comment.tool.js.map +1 -0
  44. package/dist/tools/contacts.tool.d.ts +17 -0
  45. package/dist/tools/contacts.tool.d.ts.map +1 -0
  46. package/dist/tools/contacts.tool.js +355 -0
  47. package/dist/tools/contacts.tool.js.map +1 -0
  48. package/dist/tools/conversation.tool.d.ts +14 -0
  49. package/dist/tools/conversation.tool.d.ts.map +1 -0
  50. package/dist/tools/conversation.tool.js +77 -0
  51. package/dist/tools/conversation.tool.js.map +1 -0
  52. package/dist/tools/index.d.ts +7 -0
  53. package/dist/tools/index.d.ts.map +1 -0
  54. package/dist/tools/index.js +7 -0
  55. package/dist/tools/index.js.map +1 -0
  56. package/dist/tools/messaging.tool.d.ts +15 -0
  57. package/dist/tools/messaging.tool.d.ts.map +1 -0
  58. package/dist/tools/messaging.tool.js +160 -0
  59. package/dist/tools/messaging.tool.js.map +1 -0
  60. package/dist/tools/workspace.tool.d.ts +15 -0
  61. package/dist/tools/workspace.tool.d.ts.map +1 -0
  62. package/dist/tools/workspace.tool.js +282 -0
  63. package/dist/tools/workspace.tool.js.map +1 -0
  64. package/dist/types.d.ts +351 -0
  65. package/dist/types.d.ts.map +1 -0
  66. package/dist/types.js +2 -0
  67. package/dist/types.js.map +1 -0
  68. package/dist/utils/api.d.ts +127 -0
  69. package/dist/utils/api.d.ts.map +1 -0
  70. package/dist/utils/api.js +340 -0
  71. package/dist/utils/api.js.map +1 -0
  72. package/package.json +108 -0
@@ -0,0 +1,340 @@
1
+ import { RespondIO, RespondIOError } from "@respond-io/typescript-sdk";
2
+ /**
3
+ * Enhanced SDK Client Manager with best practices
4
+ */
5
+ class SdkClientManager {
6
+ static instance;
7
+ clients = new Map();
8
+ healthStatus = new Map();
9
+ healthCheckInterval;
10
+ defaultConfig = {
11
+ maxRetries: 3,
12
+ timeout: 30000,
13
+ };
14
+ constructor() {
15
+ // Start periodic health checks
16
+ this.startHealthChecks();
17
+ // Handle graceful shutdown
18
+ this.setupGracefulShutdown();
19
+ }
20
+ static getInstance() {
21
+ if (!SdkClientManager.instance) {
22
+ SdkClientManager.instance = new SdkClientManager();
23
+ }
24
+ return SdkClientManager.instance;
25
+ }
26
+ /**
27
+ * Create a client key for caching
28
+ * Uses a hash of the token to avoid collisions while keeping keys readable
29
+ */
30
+ createClientKey(config) {
31
+ // Use first 8 chars + last 4 chars + length to reduce collision risk
32
+ const tokenPreview = config.apiToken.length > 12
33
+ ? `${config.apiToken.substring(0, 8)}...${config.apiToken.substring(config.apiToken.length - 4)}`
34
+ : config.apiToken.substring(0, 12);
35
+ return `${config.baseUrl}:${tokenPreview}`;
36
+ }
37
+ /**
38
+ * Get or create an SDK client with enhanced configuration
39
+ */
40
+ getClient(config) {
41
+ const key = this.createClientKey(config);
42
+ if (this.clients.has(key)) {
43
+ const client = this.clients.get(key);
44
+ // Check if client is healthy
45
+ const health = this.healthStatus.get(key);
46
+ if (health && !health.isHealthy && this.shouldRecreateClient(health)) {
47
+ console.warn(`Recreating unhealthy client for ${config.baseUrl}`);
48
+ this.clients.delete(key);
49
+ this.healthStatus.delete(key);
50
+ }
51
+ else {
52
+ return client;
53
+ }
54
+ }
55
+ // Create new client with merged configuration
56
+ const fullConfig = { ...this.defaultConfig, ...config };
57
+ const client = new RespondIO(fullConfig);
58
+ // Cache the client
59
+ this.clients.set(key, client);
60
+ this.healthStatus.set(key, {
61
+ isHealthy: true,
62
+ lastChecked: new Date(),
63
+ errorCount: 0,
64
+ });
65
+ return client;
66
+ }
67
+ /**
68
+ * Determine if a client should be recreated based on health status
69
+ */
70
+ shouldRecreateClient(health) {
71
+ const now = new Date();
72
+ const timeSinceLastCheck = now.getTime() - health.lastChecked.getTime();
73
+ // Recreate if unhealthy and checked more than 5 minutes ago, or error count > 5
74
+ return health.errorCount > 5 || timeSinceLastCheck > 5 * 60 * 1000;
75
+ }
76
+ /**
77
+ * Mark a client as unhealthy (called when API calls fail)
78
+ */
79
+ markClientUnhealthy(config) {
80
+ const key = this.createClientKey(config);
81
+ const health = this.healthStatus.get(key);
82
+ if (health) {
83
+ health.isHealthy = false;
84
+ health.errorCount++;
85
+ health.lastChecked = new Date();
86
+ console.warn(`Client marked as unhealthy: ${key}, errors: ${health.errorCount}`);
87
+ }
88
+ }
89
+ /**
90
+ * Perform health check on a client
91
+ */
92
+ async performHealthCheck(key, client) {
93
+ const startTime = Date.now();
94
+ try {
95
+ // Perform a lightweight health check (list users with limit 1)
96
+ await client.space.listUsers({ limit: 1 });
97
+ const responseTime = Date.now() - startTime;
98
+ this.healthStatus.set(key, {
99
+ isHealthy: true,
100
+ lastChecked: new Date(),
101
+ errorCount: 0,
102
+ responseTime,
103
+ });
104
+ }
105
+ catch (error) {
106
+ const health = this.healthStatus.get(key) || { errorCount: 0 };
107
+ this.healthStatus.set(key, {
108
+ isHealthy: false,
109
+ lastChecked: new Date(),
110
+ errorCount: health.errorCount + 1,
111
+ responseTime: Date.now() - startTime,
112
+ });
113
+ console.warn(`Health check failed for client ${key}:`, error);
114
+ }
115
+ }
116
+ /**
117
+ * Start periodic health checks
118
+ */
119
+ startHealthChecks() {
120
+ // Run health checks every 10 minutes
121
+ this.healthCheckInterval = setInterval(() => {
122
+ // Fire and forget - we don't need to wait for health checks
123
+ Array.from(this.clients.entries()).forEach(([key, client]) => {
124
+ this.performHealthCheck(key, client).catch((error) => {
125
+ console.warn(`Health check failed for ${key}:`, error);
126
+ });
127
+ });
128
+ }, 10 * 60 * 1000);
129
+ // Allow process to exit even if interval is running (useful for tests)
130
+ this.healthCheckInterval.unref();
131
+ }
132
+ /**
133
+ * Stop health checks
134
+ */
135
+ stopHealthChecks() {
136
+ if (this.healthCheckInterval) {
137
+ clearInterval(this.healthCheckInterval);
138
+ this.healthCheckInterval = undefined;
139
+ }
140
+ }
141
+ /**
142
+ * Setup graceful shutdown handlers
143
+ */
144
+ setupGracefulShutdown() {
145
+ const shutdown = () => {
146
+ // eslint-disable-next-line no-console
147
+ console.warn("Shutting down SDK client manager...");
148
+ this.stopHealthChecks();
149
+ // Close any connections if needed
150
+ };
151
+ process.on("SIGINT", shutdown);
152
+ process.on("SIGTERM", shutdown);
153
+ process.on("beforeExit", shutdown);
154
+ }
155
+ /**
156
+ * Get client statistics
157
+ */
158
+ getClientStats() {
159
+ const healthyClients = Array.from(this.healthStatus.values()).filter((health) => health.isHealthy).length;
160
+ const unhealthyClients = this.healthStatus.size - healthyClients;
161
+ return {
162
+ totalClients: this.clients.size,
163
+ healthyClients,
164
+ unhealthyClients,
165
+ healthStatus: Object.fromEntries(this.healthStatus),
166
+ };
167
+ }
168
+ }
169
+ // Export singleton instance
170
+ export const sdkClientManager = SdkClientManager.getInstance();
171
+ /**
172
+ * Get comprehensive client statistics and health information
173
+ */
174
+ export function getSdkClientStats() {
175
+ const stats = sdkClientManager.getClientStats();
176
+ return {
177
+ ...stats,
178
+ uptime: process.uptime(),
179
+ memoryUsage: process.memoryUsage(),
180
+ nodeVersion: process.version,
181
+ };
182
+ }
183
+ /**
184
+ * Initialize client monitoring (call this once at app startup).
185
+ * Logs cached client stats periodically; SdkClientManager already runs health checks.
186
+ */
187
+ export function initializeClientMonitoring() {
188
+ // eslint-disable-next-line no-console
189
+ console.warn("SDK Client monitoring initialized");
190
+ const statsInterval = setInterval(() => {
191
+ const stats = getSdkClientStats();
192
+ // eslint-disable-next-line no-console
193
+ console.warn("Client Stats:", {
194
+ total: stats.totalClients,
195
+ healthy: stats.healthyClients,
196
+ unhealthy: stats.unhealthyClients,
197
+ });
198
+ }, 5 * 60 * 1000);
199
+ // Allow process to exit even if interval is running (useful for tests)
200
+ statsInterval.unref();
201
+ }
202
+ /**
203
+ * Formats a contact identifier for the Respond.io SDK.
204
+ * Accepts various input formats and converts them to the proper SDK format.
205
+ *
206
+ * @param {string} identifier - The contact identifier in flexible format
207
+ * @returns {ContactIdentifier} - Properly formatted contact identifier
208
+ */
209
+ export function formatContactIdentifier(identifier) {
210
+ // If already in SDK format, return as-is
211
+ if (identifier.startsWith("id:") ||
212
+ identifier.startsWith("email:") ||
213
+ identifier.startsWith("phone:")) {
214
+ return identifier;
215
+ }
216
+ // If it's an email address
217
+ if (identifier.includes("@")) {
218
+ return `email:${identifier}`;
219
+ }
220
+ // If it starts with +, it's definitely a phone number
221
+ if (identifier.startsWith("+")) {
222
+ return `phone:${identifier}`;
223
+ }
224
+ // If it's all digits, check length to guess type:
225
+ // - Contact IDs are typically large numbers (6+ digits)
226
+ // - Phone numbers without + are usually 10-15 digits
227
+ // We'll treat shorter numbers (< 6 digits) as contact IDs, longer as phone
228
+ if (/^\d+$/.test(identifier)) {
229
+ // If it's a short number (< 6 digits), likely a contact ID
230
+ // Otherwise, treat as phone number (add + prefix)
231
+ if (identifier.length < 6) {
232
+ return `id:${parseInt(identifier)}`;
233
+ }
234
+ return `phone:+${identifier}`;
235
+ }
236
+ // Default: treat as email (e.g. plain email or unknown format)
237
+ return `email:${identifier}`;
238
+ }
239
+ /**
240
+ * Creates a new Respond.io SDK client with enhanced error handling and caching.
241
+ *
242
+ * @param {string} apiBaseUrl - The base URL for the API.
243
+ * @param {string} mode - The mode of operation ("http" or "stdio").
244
+ * @param {Ctx} ctx - The context object containing request information.
245
+ * @returns {RespondIO} - A configured Respond.io SDK client.
246
+ * @throws {Error} - Throws an error if the API base URL or token is not set.
247
+ */
248
+ export function createSdkClient(apiBaseUrl, mode, ctx) {
249
+ const apiToken = mode === "http" && ctx?.requestInfo?.headers?.authorization
250
+ ? ctx.requestInfo.headers.authorization
251
+ : process.env.RESPONDIO_API_KEY;
252
+ if (!apiBaseUrl) {
253
+ throw new Error("RESPONDIO_BASE_URL is not set in the environment");
254
+ }
255
+ if (!apiToken) {
256
+ throw new Error("RESPONDIO_API_KEY is not set in the environment");
257
+ }
258
+ const cleanToken = apiToken.startsWith("Bearer ") ? apiToken.slice(7) : apiToken;
259
+ try {
260
+ const client = sdkClientManager.getClient({
261
+ apiToken: cleanToken,
262
+ baseUrl: apiBaseUrl,
263
+ });
264
+ return client;
265
+ }
266
+ catch (error) {
267
+ // Mark client as unhealthy if creation fails
268
+ sdkClientManager.markClientUnhealthy({ apiToken: cleanToken, baseUrl: apiBaseUrl });
269
+ throw error;
270
+ }
271
+ }
272
+ /**
273
+ * Converts a string to a `CallToolResult` object with a text content type.
274
+ *
275
+ * @param {string} text - The text to be converted.
276
+ * @returns {CallToolResult} - A `CallToolResult` object.
277
+ */
278
+ const asCallToolText = (text) => ({
279
+ content: [{ type: "text", text }],
280
+ });
281
+ /**
282
+ * Safely stringifies a value, handling circular references and BigInts.
283
+ *
284
+ * @param {unknown} data - The data to be stringified.
285
+ * @returns {string} - The stringified data.
286
+ */
287
+ function safeStringify(data) {
288
+ const seen = new WeakSet();
289
+ return JSON.stringify(data, (_k, v) => {
290
+ if (typeof v === "bigint") {
291
+ return v.toString();
292
+ }
293
+ if (v && typeof v === "object") {
294
+ if (seen.has(v)) {
295
+ return "[Circular]";
296
+ }
297
+ seen.add(v);
298
+ }
299
+ return v;
300
+ }, 2);
301
+ }
302
+ /**
303
+ * Handles a successful SDK response by stringifying the data and returning it as a `CallToolResult`.
304
+ *
305
+ * @param {unknown} data - The response data from the SDK.
306
+ * @returns {CallToolResult} - A `CallToolResult` object containing the stringified response data.
307
+ */
308
+ export const handleSdkResponse = (data) => {
309
+ if (typeof data === "undefined") {
310
+ return asCallToolText("No data returned from API.");
311
+ }
312
+ return asCallToolText(safeStringify(data));
313
+ };
314
+ /**
315
+ * Handles an SDK error by creating a descriptive error message and returning it as a `CallToolResult`.
316
+ *
317
+ * @param {unknown} error - The error object.
318
+ * @returns {CallToolResult} - A `CallToolResult` object containing the error message.
319
+ */
320
+ export const handleSdkError = (error) => {
321
+ let message;
322
+ if (error instanceof RespondIOError) {
323
+ const sdkError = error;
324
+ message = `API Error ${sdkError.statusCode}: ${sdkError.message}`;
325
+ if (sdkError.isRateLimitError() && sdkError.rateLimitInfo?.retryAfter) {
326
+ message += ` (Rate limit exceeded. Retry after: ${sdkError.rateLimitInfo.retryAfter} seconds)`;
327
+ }
328
+ }
329
+ else if (error instanceof Error) {
330
+ message = `Error: ${error.message}`;
331
+ }
332
+ else {
333
+ message = `Unknown Error: ${String(error)}`;
334
+ }
335
+ if (process.env.DEBUG && error instanceof Error && error.stack) {
336
+ message += `\nStack: ${error.stack}`;
337
+ }
338
+ return asCallToolText(message);
339
+ };
340
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/utils/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAA0B,MAAM,4BAA4B,CAAC;AAwB/F;;GAEG;AACH,MAAM,gBAAgB;IACZ,MAAM,CAAC,QAAQ,CAAmB;IAClC,OAAO,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC5C,YAAY,GAA8B,IAAI,GAAG,EAAE,CAAC;IACpD,mBAAmB,CAAkB;IAC5B,aAAa,GAA0B;QACtD,UAAU,EAAE,CAAC;QACb,OAAO,EAAE,KAAK;KACf,CAAC;IAEF;QACE,+BAA+B;QAC/B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,2BAA2B;QAC3B,IAAI,CAAC,qBAAqB,EAAE,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC/B,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACrD,CAAC;QACD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACnC,CAAC;IAED;;;OAGG;IACK,eAAe,CAAC,MAAoB;QAC1C,qEAAqE;QACrE,MAAM,YAAY,GAChB,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE;YACzB,CAAC,CAAC,GAAG,MAAM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;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAkB,EAAE;IAC/D,IAAI,OAAe,CAAC;IAEpB,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC;QAEvB,OAAO,GAAG,aAAa,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QAElE,IAAI,QAAQ,CAAC,gBAAgB,EAAE,IAAI,QAAQ,CAAC,aAAa,EAAE,UAAU,EAAE,CAAC;YACtE,OAAO,IAAI,uCAAuC,QAAQ,CAAC,aAAa,CAAC,UAAU,WAAW,CAAC;QACjG,CAAC;IACH,CAAC;SAAM,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAClC,OAAO,GAAG,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,kBAAkB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/D,OAAO,IAAI,YAAY,KAAK,CAAC,KAAK,EAAE,CAAC;IACvC,CAAC;IAED,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "name": "@respond-io/mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "Model Context Protocol server for Respond.io API integration with STDIO and HTTP/SSE support",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "@respond-io/mcp-server": "dist/index.js"
9
+ },
10
+ "scripts": {
11
+ "prebuild": "npm run clean",
12
+ "build": "tsc && chmod +x dist/index.js",
13
+ "dev": "tsx watch src/index.ts",
14
+ "start": "node dist/index.js",
15
+ "start:stdio": "MCP_SERVER_MODE=stdio node dist/index.js",
16
+ "start:http": "MCP_SERVER_MODE=http node dist/index.js",
17
+ "start:local": "npm run build && MCP_SERVER_MODE=stdio npx @modelcontextprotocol/inspector node dist/index.js",
18
+ "start:debug": "DEBUG=true LOG_LEVEL=debug node dist/index.js",
19
+ "lint": "eslint src/**/*.ts",
20
+ "lint:fix": "eslint src/**/*.ts --fix",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\"",
23
+ "type-check": "tsc --noEmit",
24
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
25
+ "test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
26
+ "test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
27
+ "prepare": "npm run build",
28
+ "verify-registry": "npm config get registry",
29
+ "docker:build": "docker build -t respondio-mcp-server .",
30
+ "docker:run": "docker run -p 3000:3000 --env-file .env respondio-mcp-server",
31
+ "docker:compose:up": "docker-compose up -d",
32
+ "docker:compose:down": "docker-compose down",
33
+ "docker:compose:logs": "docker-compose logs -f",
34
+ "health-check": "curl -f http://localhost:3000/health || exit 1",
35
+ "validate": "npm run lint && npm run type-check",
36
+ "prepublishOnly": "npm run validate && npm run build && cd dist",
37
+ "prepack": "npm run build",
38
+ "clean": "rm -rf dist coverage",
39
+ "release:dev": "npm publish --registry https://npm.pkg.github.com/",
40
+ "release": "npm publish --registry https://registry.npmjs.org/ --access public || (echo 'Release failed' && exit 1)"
41
+ },
42
+ "keywords": [
43
+ "mcp",
44
+ "model-context-protocol",
45
+ "respondio",
46
+ "messaging",
47
+ "api",
48
+ "customer-engagement",
49
+ "sse",
50
+ "server-sent-events",
51
+ "http",
52
+ "stdio",
53
+ "whatsapp",
54
+ "facebook",
55
+ "instagram",
56
+ "telegram"
57
+ ],
58
+ "author": "Your Name <your.email@example.com>",
59
+ "license": "MIT",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "https://github.com/respond-io/mcp-server.git"
63
+ },
64
+ "bugs": {
65
+ "url": "https://github.com/respond-io/mcp-server/issues"
66
+ },
67
+ "homepage": "https://github.com/respond-io/mcp-server#readme",
68
+ "dependencies": {
69
+ "@modelcontextprotocol/sdk": "^1.20.2",
70
+ "@respond-io/typescript-sdk": "https://registry.npmjs.org/@respond-io/typescript-sdk/-/typescript-sdk-1.2.0.tgz",
71
+ "cors": "^2.8.5",
72
+ "express": "^5.1.0",
73
+ "zod": "^3.24.2"
74
+ },
75
+ "devDependencies": {
76
+ "@eslint/eslintrc": "^3.3.1",
77
+ "@eslint/js": "^9.39.0",
78
+ "@modelcontextprotocol/inspector": "^0.17.2",
79
+ "@types/body-parser": "^1.19.6",
80
+ "@types/cors": "^2.8.19",
81
+ "@types/express": "^5.0.5",
82
+ "@types/node": "^24.9.2",
83
+ "@typescript-eslint/eslint-plugin": "^8.46.2",
84
+ "@typescript-eslint/parser": "^8.46.2",
85
+ "eslint": "^9.39.0",
86
+ "eslint-config-prettier": "^10.1.8",
87
+ "eslint-plugin-prettier": "^5.5.4",
88
+ "globals": "^16.5.0",
89
+ "prettier": "^3.6.2",
90
+ "ts-node": "^10.9.2",
91
+ "tsx": "^4.20.6",
92
+ "typescript": "^5.9.3",
93
+ "@types/jest": "^29.5.14",
94
+ "jest": "^29.7.0",
95
+ "ts-jest": "^29.2.5"
96
+ },
97
+ "engines": {
98
+ "node": ">=18.0.0",
99
+ "npm": ">=9.0.0"
100
+ },
101
+ "files": [
102
+ "dist",
103
+ "README.md",
104
+ "LICENSE",
105
+ "package.json",
106
+ "CHANGELOG.md"
107
+ ]
108
+ }