@monadsag/productive-mcp 1.2.48
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/LICENSE +190 -0
- package/NOTICE +6 -0
- package/README.md +353 -0
- package/build/api/bookings-client.js +249 -0
- package/build/api/capacity.js +279 -0
- package/build/api/client.js +1296 -0
- package/build/api/errors.js +50 -0
- package/build/api/invoice-time-entries.js +256 -0
- package/build/api/pages-tree.js +106 -0
- package/build/api/time-entry-notes.js +75 -0
- package/build/api/types.js +1 -0
- package/build/auth/logo.js +21 -0
- package/build/auth/self-resolver.js +61 -0
- package/build/config/index.js +24 -0
- package/build/index.js +15 -0
- package/build/prompts/timesheet.js +285 -0
- package/build/server.js +55 -0
- package/build/tools/absences.js +502 -0
- package/build/tools/activities.js +140 -0
- package/build/tools/bookings.js +531 -0
- package/build/tools/budget-services.js +168 -0
- package/build/tools/budgets.js +276 -0
- package/build/tools/capacity.js +281 -0
- package/build/tools/changeset.js +41 -0
- package/build/tools/comments.js +469 -0
- package/build/tools/companies.js +73 -0
- package/build/tools/custom-field-resolver.js +92 -0
- package/build/tools/custom-fields.js +155 -0
- package/build/tools/folders.js +516 -0
- package/build/tools/include-resolver.js +45 -0
- package/build/tools/invoice-actions.js +476 -0
- package/build/tools/invoice-defaults.js +65 -0
- package/build/tools/invoice-time-entries.js +320 -0
- package/build/tools/invoices.js +657 -0
- package/build/tools/my-tasks.js +100 -0
- package/build/tools/page-children.js +129 -0
- package/build/tools/pages.js +466 -0
- package/build/tools/people.js +147 -0
- package/build/tools/projects.js +77 -0
- package/build/tools/recent-updates.js +112 -0
- package/build/tools/registry.js +409 -0
- package/build/tools/subtasks.js +245 -0
- package/build/tools/task-backlog.js +106 -0
- package/build/tools/task-dependencies.js +244 -0
- package/build/tools/task-list-move.js +65 -0
- package/build/tools/task-lists.js +535 -0
- package/build/tools/task-reposition.js +199 -0
- package/build/tools/task-status.js +178 -0
- package/build/tools/tasks.js +738 -0
- package/build/tools/time-entries.js +736 -0
- package/build/tools/time-entry-approval.js +103 -0
- package/build/tools/time-entry-delete.js +72 -0
- package/build/tools/time-entry-update.js +126 -0
- package/build/tools/timers.js +195 -0
- package/build/tools/todos.js +342 -0
- package/build/tools/tool-helpers.js +114 -0
- package/build/tools/toolsets.js +153 -0
- package/build/tools/whoami.js +64 -0
- package/build/tools/workflow-statuses.js +81 -0
- package/build/utils/errors.js +67 -0
- package/build/utils/mentions.js +98 -0
- package/npm-shrinkwrap.json +1159 -0
- package/package.json +79 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { toMcpError } from '../utils/errors.js';
|
|
3
|
+
/** Coerce "true"/"false" strings to booleans (some MCP clients send strings). */
|
|
4
|
+
const coerceBoolean = z.preprocess((v) => (v === 'true' ? true : v === 'false' ? false : v), z.boolean());
|
|
5
|
+
export const taskRepositionSchema = z.object({
|
|
6
|
+
taskId: z.string().describe('The ID of the task to reposition'),
|
|
7
|
+
move_before_id: z.string().optional().describe('Position the task before this task ID'),
|
|
8
|
+
move_after_id: z.string().optional().describe('Position the task after this task ID'),
|
|
9
|
+
moveToTop: coerceBoolean.optional().describe('Move the task to the top of its list'),
|
|
10
|
+
moveToBottom: coerceBoolean.optional().describe('Move the task to the bottom of its list'),
|
|
11
|
+
});
|
|
12
|
+
export const repositionTask = async (apiClient, data) => {
|
|
13
|
+
const { taskId, move_before_id, move_after_id, moveToTop, moveToBottom } = data;
|
|
14
|
+
// Get the current task to determine its task list
|
|
15
|
+
const currentTask = await apiClient.getTask(taskId);
|
|
16
|
+
// Check if the task list ID is available in the response
|
|
17
|
+
const taskListId = currentTask.data.relationships?.task_list?.data?.id;
|
|
18
|
+
// If we can't find the task list ID, we'll try a different approach
|
|
19
|
+
if (!taskListId) {
|
|
20
|
+
console.warn('Task list ID not found for task', taskId);
|
|
21
|
+
// Get all tasks and try to find suitable ones to position against
|
|
22
|
+
const allTasks = await apiClient.listTasks({
|
|
23
|
+
limit: 100,
|
|
24
|
+
});
|
|
25
|
+
// Filter out the current task from the list
|
|
26
|
+
const otherTasks = allTasks.data.filter((task) => task.id !== taskId);
|
|
27
|
+
// Move to top of list (find task with lowest placement and move before it)
|
|
28
|
+
if (moveToTop && otherTasks.length > 0) {
|
|
29
|
+
const sortedTasks = [...otherTasks].sort((a, b) => {
|
|
30
|
+
const placementA = a.attributes.placement || 0;
|
|
31
|
+
const placementB = b.attributes.placement || 0;
|
|
32
|
+
return placementA - placementB;
|
|
33
|
+
});
|
|
34
|
+
if (sortedTasks.length > 0) {
|
|
35
|
+
return await apiClient.repositionTask(taskId, {
|
|
36
|
+
move_before_id: sortedTasks[0].id,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Move to bottom of list (find task with highest placement and move after it)
|
|
41
|
+
if (moveToBottom && otherTasks.length > 0) {
|
|
42
|
+
const sortedTasks = [...otherTasks].sort((a, b) => {
|
|
43
|
+
const placementA = a.attributes.placement || 0;
|
|
44
|
+
const placementB = b.attributes.placement || 0;
|
|
45
|
+
return placementB - placementA; // Descending order
|
|
46
|
+
});
|
|
47
|
+
if (sortedTasks.length > 0) {
|
|
48
|
+
return await apiClient.repositionTask(taskId, {
|
|
49
|
+
move_after_id: sortedTasks[0].id,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// We have a task list ID, so we can filter tasks by that list
|
|
56
|
+
const tasksInList = await apiClient.listTasks({
|
|
57
|
+
limit: 100,
|
|
58
|
+
});
|
|
59
|
+
// Filter tasks in the same list
|
|
60
|
+
const tasksInSameList = tasksInList.data.filter((task) => task.relationships?.task_list?.data?.id === taskListId && task.id !== taskId);
|
|
61
|
+
// Move to top of list
|
|
62
|
+
if (moveToTop && tasksInSameList.length > 0) {
|
|
63
|
+
const sortedTasks = [...tasksInSameList].sort((a, b) => {
|
|
64
|
+
const placementA = a.attributes.placement || 0;
|
|
65
|
+
const placementB = b.attributes.placement || 0;
|
|
66
|
+
return placementA - placementB;
|
|
67
|
+
});
|
|
68
|
+
if (sortedTasks.length > 0) {
|
|
69
|
+
return await apiClient.repositionTask(taskId, {
|
|
70
|
+
move_before_id: sortedTasks[0].id,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Move to bottom of list
|
|
75
|
+
if (moveToBottom && tasksInSameList.length > 0) {
|
|
76
|
+
const sortedTasks = [...tasksInSameList].sort((a, b) => {
|
|
77
|
+
const placementA = a.attributes.placement || 0;
|
|
78
|
+
const placementB = b.attributes.placement || 0;
|
|
79
|
+
return placementB - placementA; // Descending order
|
|
80
|
+
});
|
|
81
|
+
if (sortedTasks.length > 0) {
|
|
82
|
+
return await apiClient.repositionTask(taskId, {
|
|
83
|
+
move_after_id: sortedTasks[0].id,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Handle explicit positioning parameters if provided
|
|
89
|
+
if (move_before_id || move_after_id) {
|
|
90
|
+
const attributes = {};
|
|
91
|
+
if (move_before_id)
|
|
92
|
+
attributes.move_before_id = move_before_id;
|
|
93
|
+
if (move_after_id)
|
|
94
|
+
attributes.move_after_id = move_after_id;
|
|
95
|
+
return await apiClient.repositionTask(taskId, attributes);
|
|
96
|
+
}
|
|
97
|
+
// As a last resort, try default API behavior with empty attributes
|
|
98
|
+
console.warn('Using default repositioning with empty attributes');
|
|
99
|
+
return await apiClient.repositionTask(taskId, {});
|
|
100
|
+
};
|
|
101
|
+
export const taskRepositionDefinition = {
|
|
102
|
+
name: 'reposition_task',
|
|
103
|
+
description: 'Move a task to a specific position within its task list. Provide exactly one positioning method: ' +
|
|
104
|
+
'move_before_id/move_after_id (place relative to another task) OR moveToTop/moveToBottom (place at an end). ' +
|
|
105
|
+
"Does not change the task's assignee, status, or list membership -- use move_task_to_list for that.",
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
taskId: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
description: 'The ID of the task to reposition',
|
|
112
|
+
},
|
|
113
|
+
move_before_id: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Place the task immediately before this task ID in the list. Do not combine with moveToTop/moveToBottom.',
|
|
116
|
+
},
|
|
117
|
+
move_after_id: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Place the task immediately after this task ID in the list. Do not combine with moveToTop/moveToBottom.',
|
|
120
|
+
},
|
|
121
|
+
moveToTop: {
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
description: 'Move the task to the top of its list. Use instead of move_before_id/move_after_id, not together.',
|
|
124
|
+
},
|
|
125
|
+
moveToBottom: {
|
|
126
|
+
type: 'boolean',
|
|
127
|
+
description: 'Move the task to the bottom of its list. Use instead of move_before_id/move_after_id, not together.',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
required: ['taskId'],
|
|
131
|
+
examples: [
|
|
132
|
+
{ taskId: '123', move_before_id: '456' },
|
|
133
|
+
{ taskId: '123', moveToTop: true },
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
annotations: {
|
|
137
|
+
title: 'Reposition task',
|
|
138
|
+
readOnlyHint: false,
|
|
139
|
+
destructiveHint: false,
|
|
140
|
+
idempotentHint: true,
|
|
141
|
+
openWorldHint: true,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
export const taskRepositionTool = async (apiClient, args) => {
|
|
145
|
+
try {
|
|
146
|
+
const result = await repositionTask(apiClient, args);
|
|
147
|
+
// Format the response to match the MCP tool expected format
|
|
148
|
+
// Handle the new response format which is a success object
|
|
149
|
+
if (result.success) {
|
|
150
|
+
return {
|
|
151
|
+
content: [
|
|
152
|
+
{
|
|
153
|
+
type: 'text',
|
|
154
|
+
text: `Task ${args.taskId} repositioned successfully.
|
|
155
|
+
The task has been moved ${args.moveToTop
|
|
156
|
+
? 'to the top of the list'
|
|
157
|
+
: args.moveToBottom
|
|
158
|
+
? 'to the bottom of the list'
|
|
159
|
+
: args.move_before_id
|
|
160
|
+
? `before task ${args.move_before_id}`
|
|
161
|
+
: args.move_after_id
|
|
162
|
+
? `after task ${args.move_after_id}`
|
|
163
|
+
: 'to a new position'}.`,
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
else if (result.data) {
|
|
169
|
+
// Fallback for old response format if somehow returned
|
|
170
|
+
return {
|
|
171
|
+
content: [
|
|
172
|
+
{
|
|
173
|
+
type: 'text',
|
|
174
|
+
text: `Task ${result.data.id} repositioned successfully.
|
|
175
|
+
Title: ${result.data.attributes?.title || 'Unknown'}
|
|
176
|
+
Position updated according to the requested parameters.`,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Generic success if neither format is matched
|
|
183
|
+
return {
|
|
184
|
+
content: [
|
|
185
|
+
{
|
|
186
|
+
type: 'text',
|
|
187
|
+
text: `Task repositioning operation completed successfully.`,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
// This used to return the failure as a *successful* tool result -- error
|
|
195
|
+
// text in a content block, no isError flag -- so a client and the model both
|
|
196
|
+
// read a failed reposition as a completed one. Throw like every other tool.
|
|
197
|
+
throw toMcpError(error);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { toMcpError } from '../utils/errors.js';
|
|
4
|
+
const updateTaskStatusSchema = z.object({
|
|
5
|
+
task_id: z.string().min(1, 'Task ID is required'),
|
|
6
|
+
workflow_status_id: z.string().optional().describe('Exact workflow status ID (use if known)'),
|
|
7
|
+
status_name: z
|
|
8
|
+
.string()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe('Status name to match, e.g. "In Progress", "Done", "QA Review"'),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the workflow for a task by going through its project,
|
|
14
|
+
* then lists all statuses in that workflow (including custom ones).
|
|
15
|
+
* Path: task → project (include=workflow) → workflow_id → list statuses
|
|
16
|
+
*
|
|
17
|
+
* Uses the per-request API client so calls run under the user's own PAT (BYOT).
|
|
18
|
+
*/
|
|
19
|
+
async function resolveWorkflowStatuses(client, taskId) {
|
|
20
|
+
// Step 1: Get the task with project included to find its project ID
|
|
21
|
+
const taskRes = await client.getTask(taskId);
|
|
22
|
+
const projectId = taskRes.data.relationships?.project?.data?.id;
|
|
23
|
+
if (!projectId) {
|
|
24
|
+
throw new Error('Task has no project assigned');
|
|
25
|
+
}
|
|
26
|
+
// Step 2: Get the project with workflow included to find workflow_id
|
|
27
|
+
const projRes = await client.getProject(projectId);
|
|
28
|
+
const workflowId = projRes.data.relationships?.workflow?.data?.id;
|
|
29
|
+
if (!workflowId) {
|
|
30
|
+
throw new Error('Project has no workflow configured');
|
|
31
|
+
}
|
|
32
|
+
// Step 3: List all statuses in this workflow
|
|
33
|
+
const statusRes = await client.listWorkflowStatuses({ workflow_id: workflowId, limit: 200 });
|
|
34
|
+
const statuses = statusRes.data.map((s) => ({
|
|
35
|
+
id: s.id,
|
|
36
|
+
name: s.attributes.name,
|
|
37
|
+
categoryId: s.attributes.category_id,
|
|
38
|
+
}));
|
|
39
|
+
return { workflowId, statuses };
|
|
40
|
+
}
|
|
41
|
+
function categoryLabel(categoryId) {
|
|
42
|
+
if (categoryId === 1)
|
|
43
|
+
return 'Not Started';
|
|
44
|
+
if (categoryId === 2)
|
|
45
|
+
return 'Started';
|
|
46
|
+
if (categoryId === 3)
|
|
47
|
+
return 'Closed';
|
|
48
|
+
return `Category ${categoryId}`;
|
|
49
|
+
}
|
|
50
|
+
function formatStatusList(statuses) {
|
|
51
|
+
return statuses
|
|
52
|
+
.map((s) => ` • "${s.name}" (ID: ${s.id}) — ${categoryLabel(s.categoryId)}`)
|
|
53
|
+
.join('\n');
|
|
54
|
+
}
|
|
55
|
+
export async function updateTaskStatusTool(client, args) {
|
|
56
|
+
try {
|
|
57
|
+
const params = updateTaskStatusSchema.parse(args);
|
|
58
|
+
if (!params.workflow_status_id && !params.status_name) {
|
|
59
|
+
throw new McpError(ErrorCode.InvalidParams, 'Either workflow_status_id or status_name must be provided');
|
|
60
|
+
}
|
|
61
|
+
let resolvedStatusId = params.workflow_status_id;
|
|
62
|
+
let resolvedStatusName = '';
|
|
63
|
+
// If status_name provided, resolve it to an ID
|
|
64
|
+
if (params.status_name && !resolvedStatusId) {
|
|
65
|
+
const { statuses } = await resolveWorkflowStatuses(client, params.task_id);
|
|
66
|
+
const needle = params.status_name.toLowerCase().trim();
|
|
67
|
+
// 1. Exact match (case-insensitive)
|
|
68
|
+
let matches = statuses.filter((s) => s.name.toLowerCase() === needle);
|
|
69
|
+
// 2. Starts-with match
|
|
70
|
+
if (matches.length === 0) {
|
|
71
|
+
matches = statuses.filter((s) => s.name.toLowerCase().startsWith(needle));
|
|
72
|
+
}
|
|
73
|
+
// 3. Contains match
|
|
74
|
+
if (matches.length === 0) {
|
|
75
|
+
matches = statuses.filter((s) => s.name.toLowerCase().includes(needle));
|
|
76
|
+
}
|
|
77
|
+
if (matches.length === 0) {
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: 'text',
|
|
82
|
+
text: `No workflow status matching "${params.status_name}" found.\n\nAvailable statuses:\n${formatStatusList(statuses)}`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (matches.length > 1) {
|
|
88
|
+
// Check if one is an exact match among the multiple
|
|
89
|
+
const exact = matches.filter((s) => s.name.toLowerCase() === needle);
|
|
90
|
+
if (exact.length === 1) {
|
|
91
|
+
matches = exact;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: `Multiple statuses match "${params.status_name}":\n${formatStatusList(matches)}\n\nPlease be more specific, or use the workflow_status_id directly.`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
resolvedStatusId = matches[0].id;
|
|
105
|
+
resolvedStatusName = matches[0].name;
|
|
106
|
+
}
|
|
107
|
+
// Apply the status
|
|
108
|
+
const taskUpdate = {
|
|
109
|
+
data: {
|
|
110
|
+
type: 'tasks',
|
|
111
|
+
id: params.task_id,
|
|
112
|
+
relationships: {
|
|
113
|
+
workflow_status: {
|
|
114
|
+
data: {
|
|
115
|
+
id: resolvedStatusId,
|
|
116
|
+
type: 'workflow_statuses',
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const response = await client.updateTask(params.task_id, taskUpdate);
|
|
123
|
+
let text = `Task status updated successfully!\n`;
|
|
124
|
+
text += `Task: ${response.data.attributes.title} (ID: ${response.data.id})\n`;
|
|
125
|
+
if (resolvedStatusName) {
|
|
126
|
+
text += `Status: ${resolvedStatusName} (ID: ${resolvedStatusId})`;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
text += `Workflow Status ID: ${resolvedStatusId}`;
|
|
130
|
+
}
|
|
131
|
+
if (response.data.attributes.closed !== undefined) {
|
|
132
|
+
text += `\nTask is now: ${response.data.attributes.closed ? 'closed' : 'open'}`;
|
|
133
|
+
}
|
|
134
|
+
if (response.data.attributes.updated_at) {
|
|
135
|
+
text += `\nUpdated at: ${response.data.attributes.updated_at}`;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
content: [
|
|
139
|
+
{
|
|
140
|
+
type: 'text',
|
|
141
|
+
text,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw toMcpError(error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export const updateTaskStatusDefinition = {
|
|
151
|
+
name: 'update_task_status',
|
|
152
|
+
description: 'Update the status of a task in Productive.io. You can provide a status_name (e.g. "In Progress", "Done", "QA Review") and it will automatically resolve to the correct workflow status for that task. Supports custom workflow statuses. Falls back to workflow_status_id if provided directly.',
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
task_id: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'ID of the task to update (required)',
|
|
159
|
+
},
|
|
160
|
+
status_name: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
description: 'Name of the status to set (e.g. "In Progress", "Done", "To Do"). Case-insensitive, supports partial matching. If ambiguous, returns available options.',
|
|
163
|
+
},
|
|
164
|
+
workflow_status_id: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Exact workflow status ID (optional — use status_name instead for convenience)',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
required: ['task_id'],
|
|
170
|
+
},
|
|
171
|
+
annotations: {
|
|
172
|
+
title: 'Update task status',
|
|
173
|
+
readOnlyHint: false,
|
|
174
|
+
destructiveHint: false,
|
|
175
|
+
idempotentHint: true,
|
|
176
|
+
openWorldHint: true,
|
|
177
|
+
},
|
|
178
|
+
};
|