motionmcp 1.0.1 → 2.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 (159) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +251 -417
  3. package/dist/handlers/CommentHandler.d.ts +9 -0
  4. package/dist/handlers/CommentHandler.d.ts.map +1 -0
  5. package/dist/handlers/CommentHandler.js +66 -0
  6. package/dist/handlers/CommentHandler.js.map +1 -0
  7. package/dist/handlers/CustomFieldHandler.d.ts +14 -0
  8. package/dist/handlers/CustomFieldHandler.d.ts.map +1 -0
  9. package/dist/handlers/CustomFieldHandler.js +95 -0
  10. package/dist/handlers/CustomFieldHandler.js.map +1 -0
  11. package/dist/handlers/HandlerFactory.d.ts +15 -0
  12. package/dist/handlers/HandlerFactory.d.ts.map +1 -0
  13. package/dist/handlers/HandlerFactory.js +58 -0
  14. package/dist/handlers/HandlerFactory.js.map +1 -0
  15. package/dist/handlers/ProjectHandler.d.ts +10 -0
  16. package/dist/handlers/ProjectHandler.d.ts.map +1 -0
  17. package/dist/handlers/ProjectHandler.js +63 -0
  18. package/dist/handlers/ProjectHandler.js.map +1 -0
  19. package/dist/handlers/RecurringTaskHandler.d.ts +10 -0
  20. package/dist/handlers/RecurringTaskHandler.d.ts.map +1 -0
  21. package/dist/handlers/RecurringTaskHandler.js +68 -0
  22. package/dist/handlers/RecurringTaskHandler.js.map +1 -0
  23. package/dist/handlers/ScheduleHandler.d.ts +8 -0
  24. package/dist/handlers/ScheduleHandler.d.ts.map +1 -0
  25. package/dist/handlers/ScheduleHandler.js +43 -0
  26. package/dist/handlers/ScheduleHandler.js.map +1 -0
  27. package/dist/handlers/SearchHandler.d.ts +10 -0
  28. package/dist/handlers/SearchHandler.d.ts.map +1 -0
  29. package/dist/handlers/SearchHandler.js +116 -0
  30. package/dist/handlers/SearchHandler.js.map +1 -0
  31. package/dist/handlers/StatusHandler.d.ts +8 -0
  32. package/dist/handlers/StatusHandler.d.ts.map +1 -0
  33. package/dist/handlers/StatusHandler.js +22 -0
  34. package/dist/handlers/StatusHandler.js.map +1 -0
  35. package/dist/handlers/TaskHandler.d.ts +22 -0
  36. package/dist/handlers/TaskHandler.d.ts.map +1 -0
  37. package/dist/handlers/TaskHandler.js +266 -0
  38. package/dist/handlers/TaskHandler.js.map +1 -0
  39. package/dist/handlers/UserHandler.d.ts +9 -0
  40. package/dist/handlers/UserHandler.d.ts.map +1 -0
  41. package/dist/handlers/UserHandler.js +36 -0
  42. package/dist/handlers/UserHandler.js.map +1 -0
  43. package/dist/handlers/WorkspaceHandler.d.ts +10 -0
  44. package/dist/handlers/WorkspaceHandler.d.ts.map +1 -0
  45. package/dist/handlers/WorkspaceHandler.js +49 -0
  46. package/dist/handlers/WorkspaceHandler.js.map +1 -0
  47. package/dist/handlers/base/BaseHandler.d.ts +16 -0
  48. package/dist/handlers/base/BaseHandler.d.ts.map +1 -0
  49. package/dist/handlers/base/BaseHandler.js +31 -0
  50. package/dist/handlers/base/BaseHandler.js.map +1 -0
  51. package/dist/handlers/base/HandlerInterface.d.ts +18 -0
  52. package/dist/handlers/base/HandlerInterface.d.ts.map +1 -0
  53. package/dist/handlers/base/HandlerInterface.js +3 -0
  54. package/dist/handlers/base/HandlerInterface.js.map +1 -0
  55. package/dist/handlers/index.d.ts +14 -0
  56. package/dist/handlers/index.d.ts.map +1 -0
  57. package/dist/handlers/index.js +31 -0
  58. package/dist/handlers/index.js.map +1 -0
  59. package/dist/mcp-server-old.d.ts +29 -0
  60. package/dist/mcp-server-old.d.ts.map +1 -0
  61. package/dist/mcp-server-old.js +1304 -0
  62. package/dist/mcp-server-old.js.map +1 -0
  63. package/dist/mcp-server.d.ts +15 -0
  64. package/dist/mcp-server.d.ts.map +1 -0
  65. package/dist/mcp-server.js +145 -0
  66. package/dist/mcp-server.js.map +1 -0
  67. package/dist/schemas/motion.d.ts +4971 -0
  68. package/dist/schemas/motion.d.ts.map +1 -0
  69. package/dist/schemas/motion.js +328 -0
  70. package/dist/schemas/motion.js.map +1 -0
  71. package/dist/services/motionApi.d.ts +186 -0
  72. package/dist/services/motionApi.d.ts.map +1 -0
  73. package/dist/services/motionApi.js +1912 -0
  74. package/dist/services/motionApi.js.map +1 -0
  75. package/dist/tools/ToolConfigurator.d.ts +19 -0
  76. package/dist/tools/ToolConfigurator.d.ts.map +1 -0
  77. package/dist/tools/ToolConfigurator.js +89 -0
  78. package/dist/tools/ToolConfigurator.js.map +1 -0
  79. package/dist/tools/ToolDefinitions.d.ts +25 -0
  80. package/dist/tools/ToolDefinitions.d.ts.map +1 -0
  81. package/dist/tools/ToolDefinitions.js +502 -0
  82. package/dist/tools/ToolDefinitions.js.map +1 -0
  83. package/dist/tools/ToolRegistry.d.ts +16 -0
  84. package/dist/tools/ToolRegistry.d.ts.map +1 -0
  85. package/dist/tools/ToolRegistry.js +89 -0
  86. package/dist/tools/ToolRegistry.js.map +1 -0
  87. package/dist/tools/index.d.ts +4 -0
  88. package/dist/tools/index.d.ts.map +1 -0
  89. package/dist/tools/index.js +21 -0
  90. package/dist/tools/index.js.map +1 -0
  91. package/dist/types/mcp-tool-args.d.ts +122 -0
  92. package/dist/types/mcp-tool-args.d.ts.map +1 -0
  93. package/dist/types/mcp-tool-args.js +7 -0
  94. package/dist/types/mcp-tool-args.js.map +1 -0
  95. package/dist/types/mcp.d.ts +32 -0
  96. package/dist/types/mcp.d.ts.map +1 -0
  97. package/dist/types/mcp.js +3 -0
  98. package/dist/types/mcp.js.map +1 -0
  99. package/dist/types/motion.d.ts +304 -0
  100. package/dist/types/motion.d.ts.map +1 -0
  101. package/dist/types/motion.js +3 -0
  102. package/dist/types/motion.js.map +1 -0
  103. package/dist/utils/cache.d.ts +25 -0
  104. package/dist/utils/cache.d.ts.map +1 -0
  105. package/dist/utils/cache.js +135 -0
  106. package/dist/utils/cache.js.map +1 -0
  107. package/dist/utils/constants.d.ts +83 -0
  108. package/dist/utils/constants.d.ts.map +1 -0
  109. package/dist/utils/constants.js +151 -0
  110. package/dist/utils/constants.js.map +1 -0
  111. package/dist/utils/errorHandling.d.ts +50 -0
  112. package/dist/utils/errorHandling.d.ts.map +1 -0
  113. package/dist/utils/errorHandling.js +86 -0
  114. package/dist/utils/errorHandling.js.map +1 -0
  115. package/dist/utils/index.d.ts +13 -0
  116. package/dist/utils/index.d.ts.map +1 -0
  117. package/dist/utils/index.js +38 -0
  118. package/dist/utils/index.js.map +1 -0
  119. package/dist/utils/logger.d.ts +13 -0
  120. package/dist/utils/logger.d.ts.map +1 -0
  121. package/dist/utils/logger.js +47 -0
  122. package/dist/utils/logger.js.map +1 -0
  123. package/dist/utils/paginationNew.d.ts +44 -0
  124. package/dist/utils/paginationNew.d.ts.map +1 -0
  125. package/dist/utils/paginationNew.js +149 -0
  126. package/dist/utils/paginationNew.js.map +1 -0
  127. package/dist/utils/parameterUtils.d.ts +79 -0
  128. package/dist/utils/parameterUtils.d.ts.map +1 -0
  129. package/dist/utils/parameterUtils.js +189 -0
  130. package/dist/utils/parameterUtils.js.map +1 -0
  131. package/dist/utils/responseFormatters.d.ts +92 -0
  132. package/dist/utils/responseFormatters.d.ts.map +1 -0
  133. package/dist/utils/responseFormatters.js +331 -0
  134. package/dist/utils/responseFormatters.js.map +1 -0
  135. package/dist/utils/responseWrapper.d.ts +38 -0
  136. package/dist/utils/responseWrapper.d.ts.map +1 -0
  137. package/dist/utils/responseWrapper.js +201 -0
  138. package/dist/utils/responseWrapper.js.map +1 -0
  139. package/dist/utils/sanitize.d.ts +51 -0
  140. package/dist/utils/sanitize.d.ts.map +1 -0
  141. package/dist/utils/sanitize.js +137 -0
  142. package/dist/utils/sanitize.js.map +1 -0
  143. package/dist/utils/validator.d.ts +37 -0
  144. package/dist/utils/validator.d.ts.map +1 -0
  145. package/dist/utils/validator.js +74 -0
  146. package/dist/utils/validator.js.map +1 -0
  147. package/dist/utils/workspaceResolver.d.ts +40 -0
  148. package/dist/utils/workspaceResolver.d.ts.map +1 -0
  149. package/dist/utils/workspaceResolver.js +207 -0
  150. package/dist/utils/workspaceResolver.js.map +1 -0
  151. package/package.json +41 -17
  152. package/.claude/settings.local.json +0 -15
  153. package/.env.example +0 -3
  154. package/sample.png +0 -0
  155. package/src/index.js +0 -49
  156. package/src/mcp-server.js +0 -1137
  157. package/src/routes/motion.js +0 -152
  158. package/src/services/motionApi.js +0 -1177
  159. package/src/worker.js +0 -248
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SimpleCache = void 0;
4
+ const logger_1 = require("./logger");
5
+ const constants_1 = require("./constants");
6
+ class SimpleCache {
7
+ constructor(ttlSeconds = 300, maxSize = 1000, options = {}) {
8
+ this.cleanupInterval = null;
9
+ this.cache = new Map();
10
+ this.ttl = ttlSeconds * 1000;
11
+ this.maxSize = maxSize;
12
+ // Set up automatic cleanup if requested
13
+ if (options.autoCleanup !== false) { // Default to true for automatic cleanup
14
+ // Run cleanup periodically at half the TTL interval for efficiency
15
+ this.cleanupInterval = setInterval(() => this.cleanup(), Math.max(30000, this.ttl / 2));
16
+ // Allow process to exit even if interval is active
17
+ if (typeof this.cleanupInterval.unref === 'function') {
18
+ this.cleanupInterval.unref();
19
+ }
20
+ }
21
+ }
22
+ /**
23
+ * Destroy the cache and clean up resources
24
+ */
25
+ destroy() {
26
+ if (this.cleanupInterval) {
27
+ clearInterval(this.cleanupInterval);
28
+ this.cleanupInterval = null;
29
+ }
30
+ this.cache.clear();
31
+ }
32
+ set(key, value) {
33
+ // Enforce size limit - remove oldest entry if at capacity
34
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
35
+ const oldestKey = this.cache.keys().next().value;
36
+ if (oldestKey !== undefined) {
37
+ this.cache.delete(oldestKey);
38
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, 'Cache eviction - removed oldest entry', {
39
+ key: oldestKey,
40
+ reason: 'maxSize',
41
+ currentSize: this.cache.size
42
+ });
43
+ }
44
+ }
45
+ this.cache.set(key, {
46
+ value,
47
+ expiry: Date.now() + this.ttl
48
+ });
49
+ }
50
+ get(key) {
51
+ const item = this.cache.get(key);
52
+ if (!item)
53
+ return null;
54
+ if (Date.now() > item.expiry) {
55
+ this.cache.delete(key);
56
+ return null;
57
+ }
58
+ // Implement LRU: move accessed item to the end of insertion order
59
+ // This makes it the "most recently used" item
60
+ this.cache.delete(key);
61
+ this.cache.set(key, item);
62
+ return item.value;
63
+ }
64
+ invalidate(pattern = null) {
65
+ if (!pattern) {
66
+ this.cache.clear();
67
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, 'Cache cleared', { size: 0 });
68
+ return;
69
+ }
70
+ // Invalidate keys matching pattern - use startsWith for precision
71
+ let invalidatedCount = 0;
72
+ for (const key of this.cache.keys()) {
73
+ if (key.startsWith(pattern)) {
74
+ this.cache.delete(key);
75
+ invalidatedCount++;
76
+ }
77
+ }
78
+ if (invalidatedCount > 0) {
79
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, 'Cache invalidation', {
80
+ pattern,
81
+ invalidatedCount,
82
+ remainingSize: this.cache.size
83
+ });
84
+ }
85
+ }
86
+ // Decorator for caching method results with error handling
87
+ async withCache(key, fn) {
88
+ const cached = this.get(key);
89
+ if (cached !== null) {
90
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, 'Cache hit', { key });
91
+ return cached;
92
+ }
93
+ try {
94
+ const result = await fn();
95
+ this.set(key, result);
96
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, 'Cache miss - storing', { key });
97
+ return result;
98
+ }
99
+ catch (error) {
100
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.ERROR, 'Cache function failed', {
101
+ key,
102
+ error: error instanceof Error ? error.message : String(error)
103
+ });
104
+ throw error;
105
+ }
106
+ }
107
+ // Utility method to get cache statistics
108
+ getStats() {
109
+ return {
110
+ size: this.cache.size,
111
+ maxSize: this.maxSize,
112
+ ttlSeconds: this.ttl / 1000
113
+ };
114
+ }
115
+ // Clean up expired entries (can be called periodically if needed)
116
+ cleanup() {
117
+ const now = Date.now();
118
+ let cleanedCount = 0;
119
+ for (const [key, item] of this.cache.entries()) {
120
+ if (now > item.expiry) {
121
+ this.cache.delete(key);
122
+ cleanedCount++;
123
+ }
124
+ }
125
+ if (cleanedCount > 0) {
126
+ (0, logger_1.mcpLog)(constants_1.LOG_LEVELS.DEBUG, 'Cache cleanup', {
127
+ cleanedCount,
128
+ remainingSize: this.cache.size
129
+ });
130
+ }
131
+ }
132
+ }
133
+ exports.SimpleCache = SimpleCache;
134
+ exports.default = SimpleCache;
135
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":";;;AAAA,qCAAkC;AAClC,2CAAyC;AAOzC,MAAa,WAAW;IAMtB,YAAY,aAAqB,GAAG,EAAE,UAAkB,IAAI,EAAE,UAAqC,EAAE;QAF7F,oBAAe,GAA0B,IAAI,CAAC;QAGpD,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,UAAU,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,wCAAwC;QACxC,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC,CAAC,wCAAwC;YAC3E,mEAAmE;YACnE,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAExF,mDAAmD;YACnD,IAAI,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;gBACrD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC/B,CAA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,CAAC;YACjB,CAAC;QACH,CAAC;QAED,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,IAAA,eAAM,EAAC,sBAAU,CAAC,KAAK,EAAE,eAAe,EAAE;gBACxC,YAAY;gBACZ,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;aAC/B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAnJD,kCAmJC;AAED,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Shared constants and error codes for Motion MCP Server utilities
3
+ */
4
+ export declare const ERROR_CODES: {
5
+ readonly WORKSPACE_NOT_FOUND: "WORKSPACE_NOT_FOUND";
6
+ readonly WORKSPACE_ACCESS_DENIED: "WORKSPACE_ACCESS_DENIED";
7
+ readonly NO_DEFAULT_WORKSPACE: "NO_DEFAULT_WORKSPACE";
8
+ readonly INVALID_PARAMETERS: "INVALID_PARAMETERS";
9
+ readonly MISSING_REQUIRED_PARAM: "MISSING_REQUIRED_PARAM";
10
+ readonly MOTION_API_ERROR: "MOTION_API_ERROR";
11
+ readonly NETWORK_ERROR: "NETWORK_ERROR";
12
+ readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED";
13
+ readonly RETRY_EXHAUSTED: "RETRY_EXHAUSTED";
14
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
15
+ };
16
+ export type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
17
+ export declare const WORKSPACE_TYPES: {
18
+ readonly PERSONAL: "personal";
19
+ readonly TEAM: "team";
20
+ readonly UNKNOWN: "unknown";
21
+ };
22
+ export type WorkspaceType = typeof WORKSPACE_TYPES[keyof typeof WORKSPACE_TYPES];
23
+ export declare const MCP_RESPONSE_TYPES: {
24
+ readonly TEXT: "text";
25
+ readonly JSON: "json";
26
+ };
27
+ export type McpResponseType = typeof MCP_RESPONSE_TYPES[keyof typeof MCP_RESPONSE_TYPES];
28
+ export declare const DEFAULTS: {
29
+ readonly WORKSPACE_FALLBACK_TO_DEFAULT: true;
30
+ readonly WORKSPACE_VALIDATE_ACCESS: false;
31
+ readonly WORKSPACE_USE_CACHE: true;
32
+ readonly SEARCH_LIMIT: 40;
33
+ readonly SEARCH_SCOPE: "both" | "tasks" | "projects";
34
+ readonly MAX_SUGGESTIONS: 5;
35
+ readonly TIMEFRAME: "today" | "this_week" | "this_month";
36
+ readonly INCLUDE_PROJECTS: true;
37
+ };
38
+ export declare const RETRY_CONFIG: {
39
+ readonly MAX_RETRIES: 3;
40
+ readonly INITIAL_BACKOFF_MS: 250;
41
+ readonly MAX_BACKOFF_MS: 30000;
42
+ readonly JITTER_FACTOR: 0.2;
43
+ readonly BACKOFF_MULTIPLIER: 2;
44
+ };
45
+ export declare const CACHE_TTL: {
46
+ readonly WORKSPACES: 600;
47
+ readonly USERS: 600;
48
+ readonly PROJECTS: 300;
49
+ readonly COMMENTS: 60;
50
+ readonly CUSTOM_FIELDS: 600;
51
+ readonly RECURRING_TASKS: 300;
52
+ readonly SCHEDULES: 300;
53
+ };
54
+ export declare const CACHE_TTL_MS_MULTIPLIER = 1000;
55
+ export declare const LIMITS: {
56
+ readonly COMMENT_MAX_LENGTH: 5000;
57
+ readonly COMMENT_DISPLAY_LENGTH: 120;
58
+ readonly CUSTOM_FIELD_NAME_MAX_LENGTH: 255;
59
+ readonly CUSTOM_FIELD_OPTIONS_MAX_COUNT: 100;
60
+ readonly DEFAULT_PAGE_SIZE: 50;
61
+ readonly MAX_PAGE_SIZE: 200;
62
+ readonly MAX_PAGES: 10;
63
+ readonly ABSOLUTE_MAX_PAGES: 50;
64
+ readonly MAX_SEARCH_RESULTS: 100;
65
+ };
66
+ export declare const LOG_LEVELS: {
67
+ readonly DEBUG: "debug";
68
+ readonly INFO: "info";
69
+ readonly WARN: "warn";
70
+ readonly ERROR: "error";
71
+ };
72
+ export type LogLevel = typeof LOG_LEVELS[keyof typeof LOG_LEVELS];
73
+ export declare const NULL_UNDEFINED_POLICY: {};
74
+ export declare function convertUndefinedToNull<T extends Record<string, any>>(obj: T): T;
75
+ /**
76
+ * Creates a minimal payload by removing null, undefined, and empty values
77
+ * This prevents API validation errors from unexpected fields
78
+ * @param obj - The object to minimize
79
+ * @returns Clean object with only meaningful values
80
+ */
81
+ export declare function createMinimalPayload<T extends Record<string, any>>(obj: T): Partial<T>;
82
+ export declare function convertNullToUndefined<T extends Record<string, any>>(obj: T): T;
83
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,WAAW;;;;;;;;;;;CAkBd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAGrE,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAGjF,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,OAAO,kBAAkB,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAGzF,eAAO,MAAM,QAAQ;;;;;2BAOK,MAAM,GAAG,OAAO,GAAG,UAAU;;wBAM3B,OAAO,GAAG,WAAW,GAAG,YAAY;;CAEtD,CAAC;AAGX,eAAO,MAAM,YAAY;;;;;;CAMf,CAAC;AAGX,eAAO,MAAM,SAAS;;;;;;;;CAQZ,CAAC;AAGX,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAG5C,eAAO,MAAM,MAAM;;;;;;;;;;CAYT,CAAC;AAGX,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAGlE,eAAO,MAAM,qBAAqB,IAYxB,CAAC;AAGX,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAQ/E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAyBtF;AAGD,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAQ/E"}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ /**
3
+ * Shared constants and error codes for Motion MCP Server utilities
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NULL_UNDEFINED_POLICY = exports.LOG_LEVELS = exports.LIMITS = exports.CACHE_TTL_MS_MULTIPLIER = exports.CACHE_TTL = exports.RETRY_CONFIG = exports.DEFAULTS = exports.MCP_RESPONSE_TYPES = exports.WORKSPACE_TYPES = exports.ERROR_CODES = void 0;
7
+ exports.convertUndefinedToNull = convertUndefinedToNull;
8
+ exports.createMinimalPayload = createMinimalPayload;
9
+ exports.convertNullToUndefined = convertNullToUndefined;
10
+ // Error codes for different types of failures
11
+ exports.ERROR_CODES = {
12
+ // Workspace related errors
13
+ WORKSPACE_NOT_FOUND: 'WORKSPACE_NOT_FOUND',
14
+ WORKSPACE_ACCESS_DENIED: 'WORKSPACE_ACCESS_DENIED',
15
+ NO_DEFAULT_WORKSPACE: 'NO_DEFAULT_WORKSPACE',
16
+ // Validation errors
17
+ INVALID_PARAMETERS: 'INVALID_PARAMETERS',
18
+ MISSING_REQUIRED_PARAM: 'MISSING_REQUIRED_PARAM',
19
+ // API related errors
20
+ MOTION_API_ERROR: 'MOTION_API_ERROR',
21
+ NETWORK_ERROR: 'NETWORK_ERROR',
22
+ RATE_LIMIT_EXCEEDED: 'RATE_LIMIT_EXCEEDED',
23
+ RETRY_EXHAUSTED: 'RETRY_EXHAUSTED',
24
+ // General errors
25
+ INTERNAL_ERROR: 'INTERNAL_ERROR'
26
+ };
27
+ // Workspace types
28
+ exports.WORKSPACE_TYPES = {
29
+ PERSONAL: 'personal',
30
+ TEAM: 'team',
31
+ UNKNOWN: 'unknown'
32
+ };
33
+ // MCP response types
34
+ exports.MCP_RESPONSE_TYPES = {
35
+ TEXT: 'text',
36
+ JSON: 'json'
37
+ };
38
+ // Default values for common parameters
39
+ exports.DEFAULTS = {
40
+ WORKSPACE_FALLBACK_TO_DEFAULT: true,
41
+ WORKSPACE_VALIDATE_ACCESS: false,
42
+ WORKSPACE_USE_CACHE: true,
43
+ // Search defaults
44
+ SEARCH_LIMIT: 40,
45
+ SEARCH_SCOPE: 'both',
46
+ // Suggestion defaults
47
+ MAX_SUGGESTIONS: 5,
48
+ // Workload analysis defaults
49
+ TIMEFRAME: 'this_week',
50
+ INCLUDE_PROJECTS: true
51
+ };
52
+ // Retry configuration
53
+ exports.RETRY_CONFIG = {
54
+ MAX_RETRIES: 3,
55
+ INITIAL_BACKOFF_MS: 250,
56
+ MAX_BACKOFF_MS: 30000, // 30 seconds max
57
+ JITTER_FACTOR: 0.2, // 20% jitter
58
+ BACKOFF_MULTIPLIER: 2
59
+ };
60
+ // Cache TTL configuration (in seconds)
61
+ exports.CACHE_TTL = {
62
+ WORKSPACES: 600, // 10 minutes
63
+ USERS: 600, // 10 minutes
64
+ PROJECTS: 300, // 5 minutes
65
+ COMMENTS: 60, // 1 minute
66
+ CUSTOM_FIELDS: 600, // 10 minutes
67
+ RECURRING_TASKS: 300, // 5 minutes (same as projects)
68
+ SCHEDULES: 300 // 5 minutes (schedule data changes frequently)
69
+ };
70
+ // Cache TTL conversion factor
71
+ exports.CACHE_TTL_MS_MULTIPLIER = 1000; // Convert seconds to milliseconds
72
+ // Content limits and validation
73
+ exports.LIMITS = {
74
+ COMMENT_MAX_LENGTH: 5000, // Maximum comment length in characters
75
+ COMMENT_DISPLAY_LENGTH: 120, // Maximum length for display before truncation
76
+ CUSTOM_FIELD_NAME_MAX_LENGTH: 255, // Maximum custom field name length
77
+ CUSTOM_FIELD_OPTIONS_MAX_COUNT: 100, // Maximum number of options for select fields
78
+ // Pagination limits to prevent resource exhaustion
79
+ DEFAULT_PAGE_SIZE: 50, // Default number of items per page
80
+ MAX_PAGE_SIZE: 200, // Maximum allowed page size
81
+ MAX_PAGES: 10, // Maximum number of pages to fetch
82
+ ABSOLUTE_MAX_PAGES: 50, // Absolute maximum pages to prevent infinite loops
83
+ MAX_SEARCH_RESULTS: 100 // Maximum search results to return
84
+ };
85
+ // Logging levels for MCP compliance
86
+ exports.LOG_LEVELS = {
87
+ DEBUG: 'debug',
88
+ INFO: 'info',
89
+ WARN: 'warn',
90
+ ERROR: 'error'
91
+ };
92
+ // Null vs Undefined Policy
93
+ exports.NULL_UNDEFINED_POLICY = {
94
+ // Use undefined for:
95
+ // - Optional parameters that weren't provided
96
+ // - Missing object properties
97
+ // - Function returns when item not found
98
+ // - Uninitialized values
99
+ // Use null for:
100
+ // - Explicit absence of value from API
101
+ // - Database null values
102
+ // - Cleared/reset state (e.g., cache reset)
103
+ // - Values that need to be explicitly sent as null to external APIs
104
+ };
105
+ // Helper to convert undefined to null for API compatibility
106
+ function convertUndefinedToNull(obj) {
107
+ const result = { ...obj };
108
+ for (const key in result) {
109
+ if (result[key] === undefined) {
110
+ result[key] = null;
111
+ }
112
+ }
113
+ return result;
114
+ }
115
+ /**
116
+ * Creates a minimal payload by removing null, undefined, and empty values
117
+ * This prevents API validation errors from unexpected fields
118
+ * @param obj - The object to minimize
119
+ * @returns Clean object with only meaningful values
120
+ */
121
+ function createMinimalPayload(obj) {
122
+ const result = {};
123
+ for (const key in obj) {
124
+ const value = obj[key];
125
+ // Skip null, undefined, empty strings, and empty arrays
126
+ if (value === null || value === undefined || value === '') {
127
+ continue;
128
+ }
129
+ // Skip empty arrays
130
+ if (Array.isArray(value) && value.length === 0) {
131
+ continue;
132
+ }
133
+ // Skip empty objects (but preserve objects with properties)
134
+ if (typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0) {
135
+ continue;
136
+ }
137
+ result[key] = value;
138
+ }
139
+ return result;
140
+ }
141
+ // Helper to convert null to undefined for internal consistency
142
+ function convertNullToUndefined(obj) {
143
+ const result = { ...obj };
144
+ for (const key in result) {
145
+ if (result[key] === null) {
146
+ delete result[key]; // This makes it undefined
147
+ }
148
+ }
149
+ return result;
150
+ }
151
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA4HH,wDAQC;AAQD,oDAyBC;AAGD,wDAQC;AA9KD,8CAA8C;AACjC,QAAA,WAAW,GAAG;IACzB,2BAA2B;IAC3B,mBAAmB,EAAE,qBAAqB;IAC1C,uBAAuB,EAAE,yBAAyB;IAClD,oBAAoB,EAAE,sBAAsB;IAE5C,oBAAoB;IACpB,kBAAkB,EAAE,oBAAoB;IACxC,sBAAsB,EAAE,wBAAwB;IAEhD,qBAAqB;IACrB,gBAAgB,EAAE,kBAAkB;IACpC,aAAa,EAAE,eAAe;IAC9B,mBAAmB,EAAE,qBAAqB;IAC1C,eAAe,EAAE,iBAAiB;IAElC,iBAAiB;IACjB,cAAc,EAAE,gBAAgB;CACxB,CAAC;AAIX,kBAAkB;AACL,QAAA,eAAe,GAAG;IAC7B,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACV,CAAC;AAIX,qBAAqB;AACR,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACJ,CAAC;AAIX,uCAAuC;AAC1B,QAAA,QAAQ,GAAG;IACtB,6BAA6B,EAAE,IAAI;IACnC,yBAAyB,EAAE,KAAK;IAChC,mBAAmB,EAAE,IAAI;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,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1F,SAAS;QACX,CAAC;QAED,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+DAA+D;AAC/D,SAAgB,sBAAsB,CAAgC,GAAM;IAC1E,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,0BAA0B;QAChD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Error Handling Utilities - Custom error classes and MCP response formatters
3
+ *
4
+ * This module provides custom error classes and MCP-compliant error response
5
+ * formatting to ensure consistent error handling across all handlers.
6
+ */
7
+ import { ErrorCode } from './constants';
8
+ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
9
+ interface ErrorContext {
10
+ [key: string]: any;
11
+ }
12
+ /**
13
+ * Base error class for Motion API related errors
14
+ */
15
+ export declare class MotionApiError extends Error {
16
+ readonly code: ErrorCode;
17
+ readonly context: ErrorContext;
18
+ constructor(message: string, code?: ErrorCode, context?: ErrorContext);
19
+ }
20
+ /**
21
+ * Error class for parameter validation failures
22
+ */
23
+ export declare class ValidationError extends Error {
24
+ readonly code: ErrorCode;
25
+ readonly parameter: string | null;
26
+ readonly context: ErrorContext;
27
+ constructor(message: string, parameter?: string | null, context?: ErrorContext);
28
+ }
29
+ /**
30
+ * Error class for workspace-specific issues
31
+ */
32
+ export declare class WorkspaceError extends Error {
33
+ readonly code: ErrorCode;
34
+ readonly context: ErrorContext;
35
+ constructor(message: string, code?: ErrorCode, context?: ErrorContext);
36
+ }
37
+ /**
38
+ * Format an error for MCP protocol response
39
+ */
40
+ export declare function formatMcpError(error: Error | MotionApiError, _context?: ErrorContext): CallToolResult;
41
+ /**
42
+ * Format a success response for MCP protocol
43
+ */
44
+ export declare function formatMcpSuccess(text: string): CallToolResult;
45
+ /**
46
+ * Create a standardized error response with context
47
+ */
48
+ export declare function createErrorResponse(message: string, code?: ErrorCode, context?: ErrorContext): CallToolResult;
49
+ export {};
50
+ //# sourceMappingURL=errorHandling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../src/utils/errorHandling.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmC,SAAS,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,UAAU,YAAY;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,SAAwC,EAAE,OAAO,GAAE,YAAiB;CAMxG;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,GAAG,IAAW,EAAE,OAAO,GAAE,YAAiB;CAOzF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,IAAI,EAAE,SAAS,CAAC;IAChC,SAAgB,OAAO,EAAE,YAAY,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,SAA2C,EAAE,OAAO,GAAE,YAAiB;CAM3G;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,EAAE,QAAQ,GAAE,YAAiB,GAAG,cAAc,CAYzG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAS7D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,SAAsC,EAC5C,OAAO,GAAE,YAAiB,GACzB,cAAc,CAGhB"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Error Handling Utilities - Custom error classes and MCP response formatters
4
+ *
5
+ * This module provides custom error classes and MCP-compliant error response
6
+ * formatting to ensure consistent error handling across all handlers.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.WorkspaceError = exports.ValidationError = exports.MotionApiError = void 0;
10
+ exports.formatMcpError = formatMcpError;
11
+ exports.formatMcpSuccess = formatMcpSuccess;
12
+ exports.createErrorResponse = createErrorResponse;
13
+ const constants_1 = require("./constants");
14
+ /**
15
+ * Base error class for Motion API related errors
16
+ */
17
+ class MotionApiError extends Error {
18
+ constructor(message, code = constants_1.ERROR_CODES.MOTION_API_ERROR, context = {}) {
19
+ super(message);
20
+ this.name = 'MotionApiError';
21
+ this.code = code;
22
+ this.context = context;
23
+ }
24
+ }
25
+ exports.MotionApiError = MotionApiError;
26
+ /**
27
+ * Error class for parameter validation failures
28
+ */
29
+ class ValidationError extends Error {
30
+ constructor(message, parameter = null, context = {}) {
31
+ super(message);
32
+ this.name = 'ValidationError';
33
+ this.code = constants_1.ERROR_CODES.INVALID_PARAMETERS;
34
+ this.parameter = parameter;
35
+ this.context = context;
36
+ }
37
+ }
38
+ exports.ValidationError = ValidationError;
39
+ /**
40
+ * Error class for workspace-specific issues
41
+ */
42
+ class WorkspaceError extends Error {
43
+ constructor(message, code = constants_1.ERROR_CODES.WORKSPACE_NOT_FOUND, context = {}) {
44
+ super(message);
45
+ this.name = 'WorkspaceError';
46
+ this.code = code;
47
+ this.context = context;
48
+ }
49
+ }
50
+ exports.WorkspaceError = WorkspaceError;
51
+ /**
52
+ * Format an error for MCP protocol response
53
+ */
54
+ function formatMcpError(error, _context = {}) {
55
+ const errorMessage = error.message || 'An unknown error occurred';
56
+ return {
57
+ content: [
58
+ {
59
+ type: constants_1.MCP_RESPONSE_TYPES.TEXT,
60
+ text: `Error: ${errorMessage}`
61
+ }
62
+ ],
63
+ isError: true
64
+ };
65
+ }
66
+ /**
67
+ * Format a success response for MCP protocol
68
+ */
69
+ function formatMcpSuccess(text) {
70
+ return {
71
+ content: [
72
+ {
73
+ type: constants_1.MCP_RESPONSE_TYPES.TEXT,
74
+ text
75
+ }
76
+ ]
77
+ };
78
+ }
79
+ /**
80
+ * Create a standardized error response with context
81
+ */
82
+ function createErrorResponse(message, code = constants_1.ERROR_CODES.INTERNAL_ERROR, context = {}) {
83
+ const error = new MotionApiError(message, code, context);
84
+ return formatMcpError(error, context);
85
+ }
86
+ //# sourceMappingURL=errorHandling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../src/utils/errorHandling.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA2DH,wCAYC;AAKD,4CASC;AAKD,kDAOC;AA/FD,2CAAyE;AAOzE;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IAIvC,YAAY,OAAe,EAAE,OAAkB,uBAAW,CAAC,gBAAgB,EAAE,UAAwB,EAAE;QACrG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,wCAUC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAKxC,YAAY,OAAe,EAAE,YAA2B,IAAI,EAAE,UAAwB,EAAE;QACtF,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AE,OAAO,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Central export point for Motion MCP Server utilities
3
+ *
4
+ * This module provides a single import point for all utility functions,
5
+ * classes, and constants used throughout the Motion MCP Server.
6
+ */
7
+ export * from './constants';
8
+ export * from './errorHandling';
9
+ export * from './responseFormatters';
10
+ export * from './parameterUtils';
11
+ export { WorkspaceResolver } from './workspaceResolver';
12
+ export { mcpLog } from './logger';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,aAAa,CAAC;AAG5B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Central export point for Motion MCP Server utilities
4
+ *
5
+ * This module provides a single import point for all utility functions,
6
+ * classes, and constants used throughout the Motion MCP Server.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.mcpLog = exports.WorkspaceResolver = void 0;
24
+ // Export all constants
25
+ __exportStar(require("./constants"), exports);
26
+ // Export error handling utilities
27
+ __exportStar(require("./errorHandling"), exports);
28
+ // Export response formatters
29
+ __exportStar(require("./responseFormatters"), exports);
30
+ // Export parameter utilities
31
+ __exportStar(require("./parameterUtils"), exports);
32
+ // Export WorkspaceResolver
33
+ var workspaceResolver_1 = require("./workspaceResolver");
34
+ Object.defineProperty(exports, "WorkspaceResolver", { enumerable: true, get: function () { return workspaceResolver_1.WorkspaceResolver; } });
35
+ // Export logger
36
+ var logger_1 = require("./logger");
37
+ Object.defineProperty(exports, "mcpLog", { enumerable: true, get: function () { return logger_1.mcpLog; } });
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;AAEH,uBAAuB;AACvB,8CAA4B;AAE5B,kCAAkC;AAClC,kDAAgC;AAEhC,6BAA6B;AAC7B,uDAAqC;AAErC,6BAA6B;AAC7B,mDAAiC;AAEjC,2BAA2B;AAC3B,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAE1B,gBAAgB;AAChB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Centralized MCP-compliant logger
3
+ * Outputs structured JSON logs to stderr as required by MCP protocol
4
+ */
5
+ import { LogLevel } from './constants';
6
+ /**
7
+ * MCP-compliant logger that outputs to stderr in JSON format
8
+ * @param level - Log level (ERROR, WARN, INFO, DEBUG)
9
+ * @param message - Log message
10
+ * @param extra - Additional context data
11
+ */
12
+ export declare const mcpLog: (level: LogLevel, message: string, extra?: Record<string, any>) => void;
13
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyBvC;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,QAAQ,EAAE,SAAS,MAAM,EAAE,QAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,KAAG,IAY1F,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /**
3
+ * Centralized MCP-compliant logger
4
+ * Outputs structured JSON logs to stderr as required by MCP protocol
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.mcpLog = void 0;
8
+ const SENSITIVE_FIELDS = ['apiKey', 'password', 'token', 'secret', 'authorization'];
9
+ /**
10
+ * Sanitizes sensitive information from log data
11
+ */
12
+ function sanitizeLogData(data) {
13
+ const sanitized = {};
14
+ for (const [key, value] of Object.entries(data)) {
15
+ // Check if key contains sensitive field names
16
+ if (SENSITIVE_FIELDS.some(field => key.toLowerCase().includes(field))) {
17
+ sanitized[key] = '[REDACTED]';
18
+ }
19
+ else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
20
+ // Recursively sanitize nested objects
21
+ sanitized[key] = sanitizeLogData(value);
22
+ }
23
+ else {
24
+ sanitized[key] = value;
25
+ }
26
+ }
27
+ return sanitized;
28
+ }
29
+ /**
30
+ * MCP-compliant logger that outputs to stderr in JSON format
31
+ * @param level - Log level (ERROR, WARN, INFO, DEBUG)
32
+ * @param message - Log message
33
+ * @param extra - Additional context data
34
+ */
35
+ const mcpLog = (level, message, extra = {}) => {
36
+ const sanitizedExtra = sanitizeLogData(extra);
37
+ const logEntry = {
38
+ level,
39
+ msg: message,
40
+ time: new Date().toISOString(),
41
+ ...sanitizedExtra
42
+ };
43
+ // MCP servers should log to stderr in JSON format
44
+ console.error(JSON.stringify(logEntry));
45
+ };
46
+ exports.mcpLog = mcpLog;
47
+ //# sourceMappingURL=logger.js.map