@hapticpaper/mcp-server 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/hapticPaperClient.js +4 -0
- package/dist/index.js +21 -3
- package/dist/tools/tasks.js +43 -0
- package/package.json +1 -1
|
@@ -53,6 +53,10 @@ export class HapticPaperClient {
|
|
|
53
53
|
const response = await this.client.post(`/gpt/tasks/${taskId}/cancel`, { reason }, { headers: await this.authHeaders(accessToken) });
|
|
54
54
|
return response.data;
|
|
55
55
|
}
|
|
56
|
+
async updateTask(taskId, data, accessToken) {
|
|
57
|
+
const response = await this.client.patch(`/gpt/tasks/${taskId}`, data, { headers: await this.authHeaders(accessToken) });
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
56
60
|
// Worker Methods
|
|
57
61
|
async searchWorkers(params, accessToken) {
|
|
58
62
|
const response = await this.client.post('/gpt/workers/search', params, { headers: await this.authHeaders(accessToken) });
|
package/dist/index.js
CHANGED
|
@@ -303,11 +303,29 @@ ${widgetJs}
|
|
|
303
303
|
}
|
|
304
304
|
const tokenVerifier = {
|
|
305
305
|
verifyAccessToken: async (token) => {
|
|
306
|
+
const publicKey = process.env.JWT_PUBLIC_KEY ? process.env.JWT_PUBLIC_KEY.replace(/\\n/g, '\n') : undefined;
|
|
306
307
|
const secret = process.env.JWT_SECRET;
|
|
307
|
-
|
|
308
|
-
|
|
308
|
+
let decoded;
|
|
309
|
+
if (publicKey) {
|
|
310
|
+
try {
|
|
311
|
+
decoded = jwt.verify(token, publicKey, { algorithms: ['ES256'] });
|
|
312
|
+
}
|
|
313
|
+
catch (e) {
|
|
314
|
+
// If ES256 fails, and we have a secret, try HS256 (migration path)
|
|
315
|
+
if (secret && e.message === 'invalid signature') {
|
|
316
|
+
decoded = jwt.verify(token, secret, { algorithms: ['HS256'] });
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
throw e;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
else if (secret) {
|
|
324
|
+
decoded = jwt.verify(token, secret, { algorithms: ['HS256'] });
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
throw new Error('Server misconfigured: Neither JWT_PUBLIC_KEY nor JWT_SECRET is set');
|
|
309
328
|
}
|
|
310
|
-
const decoded = jwt.verify(token, secret);
|
|
311
329
|
if (!decoded || typeof decoded !== 'object') {
|
|
312
330
|
throw new Error('Invalid token');
|
|
313
331
|
}
|
package/dist/tools/tasks.js
CHANGED
|
@@ -243,4 +243,47 @@ export function registerTaskTools(server, client) {
|
|
|
243
243
|
_meta: toolDescriptorMeta(cancelTaskInvoking, cancelTaskInvoked, ['tasks:write']),
|
|
244
244
|
}, cancelTaskHandler);
|
|
245
245
|
}
|
|
246
|
+
const updateTaskInvoking = 'Updating task';
|
|
247
|
+
const updateTaskInvoked = 'Task updated';
|
|
248
|
+
const updateTaskHandler = async (args, extra) => {
|
|
249
|
+
try {
|
|
250
|
+
const auth = requireScopes(extra, ['tasks:write']);
|
|
251
|
+
const task = await client.updateTask(args.taskId, args, auth?.token);
|
|
252
|
+
const widgetSessionId = `task:${args.taskId}`;
|
|
253
|
+
return {
|
|
254
|
+
structuredContent: {
|
|
255
|
+
task: {
|
|
256
|
+
id: task.id,
|
|
257
|
+
title: task.title,
|
|
258
|
+
status: task.status,
|
|
259
|
+
budget: task.budget,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
content: [{ type: 'text', text: `Updated task ${task.id}.` }],
|
|
263
|
+
_meta: {
|
|
264
|
+
...toolInvocationMeta(updateTaskInvoking, updateTaskInvoked, widgetSessionId),
|
|
265
|
+
task,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
return {
|
|
271
|
+
content: [{ type: 'text', text: `Error: ${err.message}` }],
|
|
272
|
+
isError: true,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
for (const toolName of ['update_task', 'tasks_update']) {
|
|
277
|
+
server.registerTool(toolName, {
|
|
278
|
+
title: 'Update task',
|
|
279
|
+
description: 'Update an existing task.',
|
|
280
|
+
inputSchema: CreateTaskSchema.partial().extend({ taskId: z.string().uuid() }),
|
|
281
|
+
annotations: {
|
|
282
|
+
readOnlyHint: false,
|
|
283
|
+
openWorldHint: false,
|
|
284
|
+
destructiveHint: false, // Generally safe to update
|
|
285
|
+
},
|
|
286
|
+
_meta: toolDescriptorMeta(updateTaskInvoking, updateTaskInvoked, ['tasks:write']),
|
|
287
|
+
}, updateTaskHandler);
|
|
288
|
+
}
|
|
246
289
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hapticpaper/mcp-server",
|
|
3
3
|
"mcpName": "com.hapticpaper/mcp",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.14",
|
|
5
5
|
"description": "Official MCP Server for Haptic Paper - Connect your account to create human tasks from agentic pipelines.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|