motionmcp 1.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +241 -450
  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 +324 -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.d.ts +15 -0
  60. package/dist/mcp-server.d.ts.map +1 -0
  61. package/dist/mcp-server.js +145 -0
  62. package/dist/mcp-server.js.map +1 -0
  63. package/dist/schemas/motion.d.ts +4971 -0
  64. package/dist/schemas/motion.d.ts.map +1 -0
  65. package/dist/schemas/motion.js +328 -0
  66. package/dist/schemas/motion.js.map +1 -0
  67. package/dist/services/motionApi.d.ts +199 -0
  68. package/dist/services/motionApi.d.ts.map +1 -0
  69. package/dist/services/motionApi.js +1950 -0
  70. package/dist/services/motionApi.js.map +1 -0
  71. package/dist/tools/ToolConfigurator.d.ts +19 -0
  72. package/dist/tools/ToolConfigurator.d.ts.map +1 -0
  73. package/dist/tools/ToolConfigurator.js +89 -0
  74. package/dist/tools/ToolConfigurator.js.map +1 -0
  75. package/dist/tools/ToolDefinitions.d.ts +25 -0
  76. package/dist/tools/ToolDefinitions.d.ts.map +1 -0
  77. package/dist/tools/ToolDefinitions.js +508 -0
  78. package/dist/tools/ToolDefinitions.js.map +1 -0
  79. package/dist/tools/ToolRegistry.d.ts +16 -0
  80. package/dist/tools/ToolRegistry.d.ts.map +1 -0
  81. package/dist/tools/ToolRegistry.js +89 -0
  82. package/dist/tools/ToolRegistry.js.map +1 -0
  83. package/dist/tools/index.d.ts +4 -0
  84. package/dist/tools/index.d.ts.map +1 -0
  85. package/dist/tools/index.js +21 -0
  86. package/dist/tools/index.js.map +1 -0
  87. package/dist/types/mcp-tool-args.d.ts +123 -0
  88. package/dist/types/mcp-tool-args.d.ts.map +1 -0
  89. package/dist/types/mcp-tool-args.js +7 -0
  90. package/dist/types/mcp-tool-args.js.map +1 -0
  91. package/dist/types/mcp.d.ts +32 -0
  92. package/dist/types/mcp.d.ts.map +1 -0
  93. package/dist/types/mcp.js +3 -0
  94. package/dist/types/mcp.js.map +1 -0
  95. package/dist/types/motion.d.ts +304 -0
  96. package/dist/types/motion.d.ts.map +1 -0
  97. package/dist/types/motion.js +3 -0
  98. package/dist/types/motion.js.map +1 -0
  99. package/dist/utils/cache.d.ts +25 -0
  100. package/dist/utils/cache.d.ts.map +1 -0
  101. package/dist/utils/cache.js +135 -0
  102. package/dist/utils/cache.js.map +1 -0
  103. package/dist/utils/constants.d.ts +88 -0
  104. package/dist/utils/constants.d.ts.map +1 -0
  105. package/dist/utils/constants.js +188 -0
  106. package/dist/utils/constants.js.map +1 -0
  107. package/dist/utils/errorHandling.d.ts +50 -0
  108. package/dist/utils/errorHandling.d.ts.map +1 -0
  109. package/dist/utils/errorHandling.js +86 -0
  110. package/dist/utils/errorHandling.js.map +1 -0
  111. package/dist/utils/index.d.ts +13 -0
  112. package/dist/utils/index.d.ts.map +1 -0
  113. package/dist/utils/index.js +38 -0
  114. package/dist/utils/index.js.map +1 -0
  115. package/dist/utils/logger.d.ts +13 -0
  116. package/dist/utils/logger.d.ts.map +1 -0
  117. package/dist/utils/logger.js +47 -0
  118. package/dist/utils/logger.js.map +1 -0
  119. package/dist/utils/pagination.d.ts +61 -0
  120. package/dist/utils/pagination.d.ts.map +1 -0
  121. package/dist/utils/pagination.js +168 -0
  122. package/dist/utils/pagination.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 +95 -0
  132. package/dist/utils/responseFormatters.d.ts.map +1 -0
  133. package/dist/utils/responseFormatters.js +342 -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 +138 -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 -179
  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
package/src/worker.js DELETED
@@ -1,248 +0,0 @@
1
- class MotionApiService {
2
- constructor(apiKey) {
3
- this.apiKey = apiKey;
4
- this.baseUrl = 'https://api.usemotion.com/v1';
5
- }
6
-
7
- async makeRequest(path, options = {}) {
8
- const url = `${this.baseUrl}${path}`;
9
- const defaultOptions = {
10
- headers: {
11
- 'Authorization': `Bearer ${this.apiKey}`,
12
- 'Content-Type': 'application/json',
13
- ...options.headers
14
- }
15
- };
16
-
17
- const response = await fetch(url, { ...defaultOptions, ...options });
18
-
19
- if (!response.ok) {
20
- throw new Error(`Motion API error: ${response.status} ${response.statusText}`);
21
- }
22
-
23
- return response.json();
24
- }
25
-
26
- async getProjects() {
27
- return this.makeRequest('/projects');
28
- }
29
-
30
- async createProject(projectData) {
31
- return this.makeRequest('/projects', {
32
- method: 'POST',
33
- body: JSON.stringify(projectData)
34
- });
35
- }
36
-
37
- async getProject(projectId) {
38
- return this.makeRequest(`/projects/${projectId}`);
39
- }
40
-
41
- async updateProject(projectId, projectData) {
42
- return this.makeRequest(`/projects/${projectId}`, {
43
- method: 'PATCH',
44
- body: JSON.stringify(projectData)
45
- });
46
- }
47
-
48
- async deleteProject(projectId) {
49
- await this.makeRequest(`/projects/${projectId}`, {
50
- method: 'DELETE'
51
- });
52
- return { success: true };
53
- }
54
-
55
- async getTasks(options = {}) {
56
- const params = new URLSearchParams();
57
- if (options.projectId) params.append('projectId', options.projectId);
58
- if (options.status) params.append('status', options.status);
59
- if (options.assigneeId) params.append('assigneeId', options.assigneeId);
60
-
61
- const query = params.toString();
62
- return this.makeRequest(`/tasks${query ? '?' + query : ''}`);
63
- }
64
-
65
- async createTask(taskData) {
66
- return this.makeRequest('/tasks', {
67
- method: 'POST',
68
- body: JSON.stringify(taskData)
69
- });
70
- }
71
-
72
- async getTask(taskId) {
73
- return this.makeRequest(`/tasks/${taskId}`);
74
- }
75
-
76
- async updateTask(taskId, taskData) {
77
- return this.makeRequest(`/tasks/${taskId}`, {
78
- method: 'PATCH',
79
- body: JSON.stringify(taskData)
80
- });
81
- }
82
-
83
- async deleteTask(taskId) {
84
- await this.makeRequest(`/tasks/${taskId}`, {
85
- method: 'DELETE'
86
- });
87
- return { success: true };
88
- }
89
-
90
- async getWorkspaces() {
91
- return this.makeRequest('/workspaces');
92
- }
93
-
94
- async getUsers() {
95
- return this.makeRequest('/users');
96
- }
97
- }
98
-
99
- function corsHeaders() {
100
- return {
101
- 'Access-Control-Allow-Origin': '*',
102
- 'Access-Control-Allow-Methods': 'GET, POST, PATCH, DELETE, OPTIONS',
103
- 'Access-Control-Allow-Headers': 'Content-Type, Authorization',
104
- };
105
- }
106
-
107
- function jsonResponse(data, status = 200) {
108
- return new Response(JSON.stringify(data), {
109
- status,
110
- headers: {
111
- 'Content-Type': 'application/json',
112
- ...corsHeaders()
113
- }
114
- });
115
- }
116
-
117
- function errorResponse(message, status = 500) {
118
- return jsonResponse({ error: message }, status);
119
- }
120
-
121
- async function handleRequest(request, env) {
122
- if (request.method === 'OPTIONS') {
123
- return new Response(null, { headers: corsHeaders() });
124
- }
125
-
126
- if (!env.MOTION_API_KEY) {
127
- return errorResponse('Motion API key not configured', 503);
128
- }
129
-
130
- const url = new URL(request.url);
131
- const path = url.pathname;
132
- const motionService = new MotionApiService(env.MOTION_API_KEY);
133
-
134
- try {
135
- if (path === '/health') {
136
- return jsonResponse({ status: 'ok', timestamp: new Date().toISOString() });
137
- }
138
-
139
- if (!path.startsWith('/api/motion/')) {
140
- return errorResponse('Not found', 404);
141
- }
142
-
143
- const apiPath = path.replace('/api/motion', '');
144
- const method = request.method;
145
- const searchParams = url.searchParams;
146
-
147
- if (apiPath === '/projects') {
148
- if (method === 'GET') {
149
- const projects = await motionService.getProjects();
150
- return jsonResponse(projects);
151
- }
152
- if (method === 'POST') {
153
- const body = await request.json();
154
- if (!body.name) {
155
- return errorResponse('Project name is required', 400);
156
- }
157
- const project = await motionService.createProject(body);
158
- return jsonResponse(project, 201);
159
- }
160
- }
161
-
162
- if (apiPath.startsWith('/projects/')) {
163
- const projectId = apiPath.split('/')[2];
164
- if (method === 'GET') {
165
- const project = await motionService.getProject(projectId);
166
- return jsonResponse(project);
167
- }
168
- if (method === 'PATCH') {
169
- const body = await request.json();
170
- if (Object.keys(body).length === 0) {
171
- return errorResponse('No valid fields to update', 400);
172
- }
173
- const project = await motionService.updateProject(projectId, body);
174
- return jsonResponse(project);
175
- }
176
- if (method === 'DELETE') {
177
- await motionService.deleteProject(projectId);
178
- return new Response(null, { status: 204, headers: corsHeaders() });
179
- }
180
- }
181
-
182
- if (apiPath === '/tasks') {
183
- if (method === 'GET') {
184
- const options = {};
185
- if (searchParams.get('projectId')) options.projectId = searchParams.get('projectId');
186
- if (searchParams.get('status')) options.status = searchParams.get('status');
187
- if (searchParams.get('assigneeId')) options.assigneeId = searchParams.get('assigneeId');
188
-
189
- const tasks = await motionService.getTasks(options);
190
- return jsonResponse(tasks);
191
- }
192
- if (method === 'POST') {
193
- const body = await request.json();
194
- if (!body.name) {
195
- return errorResponse('Task name is required', 400);
196
- }
197
- const task = await motionService.createTask(body);
198
- return jsonResponse(task, 201);
199
- }
200
- }
201
-
202
- if (apiPath.startsWith('/tasks/')) {
203
- const taskId = apiPath.split('/')[2];
204
- if (method === 'GET') {
205
- const task = await motionService.getTask(taskId);
206
- return jsonResponse(task);
207
- }
208
- if (method === 'PATCH') {
209
- const body = await request.json();
210
- if (Object.keys(body).length === 0) {
211
- return errorResponse('No valid fields to update', 400);
212
- }
213
- const task = await motionService.updateTask(taskId, body);
214
- return jsonResponse(task);
215
- }
216
- if (method === 'DELETE') {
217
- await motionService.deleteTask(taskId);
218
- return new Response(null, { status: 204, headers: corsHeaders() });
219
- }
220
- }
221
-
222
- if (apiPath === '/workspaces' && method === 'GET') {
223
- const workspaces = await motionService.getWorkspaces();
224
- return jsonResponse(workspaces);
225
- }
226
-
227
- if (apiPath === '/users' && method === 'GET') {
228
- const users = await motionService.getUsers();
229
- return jsonResponse(users);
230
- }
231
-
232
- return errorResponse('Not found', 404);
233
-
234
- } catch (error) {
235
- console.error('Worker error:', error);
236
- if (error.message.includes('Motion API error')) {
237
- const statusCode = error.message.includes('not found') ? 404 : 400;
238
- return errorResponse(error.message, statusCode);
239
- }
240
- return errorResponse('Internal server error', 500);
241
- }
242
- }
243
-
244
- export default {
245
- async fetch(request, env, ctx) {
246
- return handleRequest(request, env);
247
- }
248
- };