@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,285 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
// Zod schema for timesheet prompt arguments
|
|
4
|
+
const timesheetPromptSchema = z.object({
|
|
5
|
+
project_name: z.string().optional().describe('Optional project name or ID to start with'),
|
|
6
|
+
date: z.string().optional().describe('Date for time entry (today, yesterday, or YYYY-MM-DD)'),
|
|
7
|
+
time: z.string().optional().describe('Time duration (e.g., "2h", "120m", "1.5h")'),
|
|
8
|
+
work_description: z.string().optional().describe('Brief description of work performed'),
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Generate a guided timesheet entry prompt that walks users through the complete workflow
|
|
12
|
+
*/
|
|
13
|
+
export async function generateTimesheetPrompt(args) {
|
|
14
|
+
try {
|
|
15
|
+
const params = timesheetPromptSchema.parse(args);
|
|
16
|
+
const projectHint = params.project_name ? `for project "${params.project_name}"` : '';
|
|
17
|
+
const dateHint = params.date ? ` on ${params.date}` : '';
|
|
18
|
+
const timeHint = params.time ? ` (${params.time})` : '';
|
|
19
|
+
const workflowGuidance = `I'll help you create a timesheet entry${projectHint}${dateHint}${timeHint}.
|
|
20
|
+
|
|
21
|
+
**TIMESHEET WORKFLOW OVERVIEW:**
|
|
22
|
+
This requires 5 steps to ensure your time is logged to the correct budget and service:
|
|
23
|
+
|
|
24
|
+
1. **🏢 Project Selection** - Find the right project
|
|
25
|
+
2. **💰 Budget/Deal Selection** - Choose the correct budget or deal within the project
|
|
26
|
+
3. **⚙️ Service Selection** - Pick the specific service type for this work
|
|
27
|
+
4. **📋 Task Selection** - Link to a specific task (recommended)
|
|
28
|
+
5. **📝 Time Entry Creation** - Preview and confirm your time entry before creation
|
|
29
|
+
|
|
30
|
+
**IMPORTANT: CONFIRMATION REQUIRED**
|
|
31
|
+
In Step 5, I will show you exactly what will be created and ask for your confirmation before actually logging the time. This prevents accidental entries.
|
|
32
|
+
|
|
33
|
+
**WHY THIS WORKFLOW?**
|
|
34
|
+
Productive.io follows a strict hierarchy: Project → Budget/Deal → Service → Task → Time Entry
|
|
35
|
+
Each time entry must be linked to a specific service within a budget to ensure proper billing and tracking.
|
|
36
|
+
|
|
37
|
+
Let's start the workflow:`;
|
|
38
|
+
let messages = [
|
|
39
|
+
{
|
|
40
|
+
role: 'user',
|
|
41
|
+
content: {
|
|
42
|
+
type: 'text',
|
|
43
|
+
text: `Please help me create a timesheet entry${projectHint}${dateHint}${timeHint}${params.work_description ? ` for: ${params.work_description}` : ''}`,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
role: 'assistant',
|
|
48
|
+
content: {
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: workflowGuidance,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
// Add project-specific guidance if project name provided
|
|
55
|
+
if (params.project_name) {
|
|
56
|
+
messages.push({
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
content: {
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: `**STEP 1: 🏢 Project Selection**
|
|
61
|
+
Since you mentioned "${params.project_name}", let me search for matching projects:
|
|
62
|
+
|
|
63
|
+
\`\`\`
|
|
64
|
+
I'll use: list_projects to find projects matching "${params.project_name}"
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
Once we find your project, we'll move to budget selection.`,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
messages.push({
|
|
73
|
+
role: 'assistant',
|
|
74
|
+
content: {
|
|
75
|
+
type: 'text',
|
|
76
|
+
text: `**STEP 1: 🏢 Project Selection**
|
|
77
|
+
First, let's find the project you worked on:
|
|
78
|
+
|
|
79
|
+
\`\`\`
|
|
80
|
+
I'll use: list_projects to show available projects
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
Please tell me which project you worked on, or I can list all active projects for you to choose from.`,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
messages.push({
|
|
88
|
+
role: 'assistant',
|
|
89
|
+
content: {
|
|
90
|
+
type: 'text',
|
|
91
|
+
text: `**NEXT STEPS PREVIEW:**
|
|
92
|
+
|
|
93
|
+
**Step 2:** Once we have your project_id, I'll run:
|
|
94
|
+
\`list_project_deals project_id="[PROJECT_ID]"\` to show budgets/deals for that project
|
|
95
|
+
|
|
96
|
+
**Step 3:** After you select a budget, I'll run:
|
|
97
|
+
\`list_deal_services deal_id="[DEAL_ID]"\` to show available services
|
|
98
|
+
|
|
99
|
+
**Step 4:** With the project_id, I'll run:
|
|
100
|
+
\`get_project_tasks project_id="[PROJECT_ID]"\` to show tasks you can link to (recommended)
|
|
101
|
+
|
|
102
|
+
**Step 5:** Finally, I'll prepare your time entry for confirmation:
|
|
103
|
+
\`create_time_entry\` with all the selected details plus your detailed work description
|
|
104
|
+
- First call: Shows you a preview of what will be created
|
|
105
|
+
- You confirm: I'll call again with \`confirm: true\` to actually create the entry
|
|
106
|
+
|
|
107
|
+
**CONFIRMATION PROCESS:**
|
|
108
|
+
Before any time is logged, you'll see:
|
|
109
|
+
- The exact date, time, and duration
|
|
110
|
+
- Which project, service, and task it's linked to
|
|
111
|
+
- Your work description
|
|
112
|
+
- Who the time is being logged for
|
|
113
|
+
|
|
114
|
+
Only after you explicitly confirm will the time entry be created.
|
|
115
|
+
|
|
116
|
+
**READY TO START?**
|
|
117
|
+
Tell me the project name or say "list projects" to see all available projects.`,
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
description: `Guided timesheet entry workflow${projectHint}${dateHint}${timeHint}`,
|
|
122
|
+
messages,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error instanceof z.ZodError) {
|
|
127
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid prompt arguments: ${error.errors.map((e) => e.message).join(', ')}`);
|
|
128
|
+
}
|
|
129
|
+
throw new McpError(ErrorCode.InternalError, error instanceof Error ? error.message : 'Unknown error occurred');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Schema for quick timesheet prompt
|
|
133
|
+
const quickTimesheetSchema = z.object({
|
|
134
|
+
step: z
|
|
135
|
+
.enum(['project', 'budget', 'service', 'task', 'create'])
|
|
136
|
+
.describe('Current step in workflow'),
|
|
137
|
+
project_id: z.string().optional().describe('Selected project ID'),
|
|
138
|
+
deal_id: z.string().optional().describe('Selected deal/budget ID'),
|
|
139
|
+
service_id: z.string().optional().describe('Selected service ID'),
|
|
140
|
+
task_id: z.string().optional().describe('Selected task ID'),
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* Generate step-by-step guidance for timesheet workflow
|
|
144
|
+
*/
|
|
145
|
+
export async function generateQuickTimesheetPrompt(args) {
|
|
146
|
+
try {
|
|
147
|
+
const params = quickTimesheetSchema.parse(args);
|
|
148
|
+
let stepGuidance = '';
|
|
149
|
+
let nextAction = '';
|
|
150
|
+
switch (params.step) {
|
|
151
|
+
case 'project':
|
|
152
|
+
stepGuidance =
|
|
153
|
+
'**STEP 1: 🏢 PROJECT SELECTION**\nI need to find the project you worked on.';
|
|
154
|
+
nextAction =
|
|
155
|
+
'Use: `list_projects` to see available projects, then tell me the project name or ID.';
|
|
156
|
+
break;
|
|
157
|
+
case 'budget':
|
|
158
|
+
stepGuidance =
|
|
159
|
+
'**STEP 2: 💰 BUDGET/DEAL SELECTION**\nNow I need to find the correct budget or deal for this project.';
|
|
160
|
+
nextAction = `Use: \`list_project_deals project_id="${params.project_id}"\` to see available budgets/deals.`;
|
|
161
|
+
break;
|
|
162
|
+
case 'service':
|
|
163
|
+
stepGuidance =
|
|
164
|
+
'**STEP 3: ⚙️ SERVICE SELECTION**\nTime to pick the specific service type for your work.';
|
|
165
|
+
nextAction = `Use: \`list_deal_services deal_id="${params.deal_id}"\` to see services for this budget.`;
|
|
166
|
+
break;
|
|
167
|
+
case 'task':
|
|
168
|
+
stepGuidance =
|
|
169
|
+
"**STEP 4: 📋 TASK SELECTION (Recommended)**\nLet's link your time to a specific task.";
|
|
170
|
+
nextAction = `Use: \`get_project_tasks project_id="${params.project_id}"\` to see available tasks.`;
|
|
171
|
+
break;
|
|
172
|
+
case 'create':
|
|
173
|
+
stepGuidance =
|
|
174
|
+
'**STEP 5: 📝 CREATE TIME ENTRY WITH CONFIRMATION**\nReady to preview and confirm your time entry before creation.';
|
|
175
|
+
nextAction = `Use: \`create_time_entry\` with service_id="${params.service_id}"${params.task_id ? `, task_id="${params.task_id}"` : ''}, detailed notes, date, and time.\n\n**IMPORTANT CONFIRMATION PROCESS:**\n1. First call without \`confirm: true\` - Shows preview of what will be created\n2. Review the details carefully\n3. If correct, call again with \`confirm: true\` to actually create the entry\n\nThis two-step process prevents accidental time entries.`;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
description: `Timesheet workflow step: ${params.step}`,
|
|
180
|
+
messages: [
|
|
181
|
+
{
|
|
182
|
+
role: 'user',
|
|
183
|
+
content: {
|
|
184
|
+
type: 'text',
|
|
185
|
+
text: `Help me with timesheet entry step: ${params.step}`,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
role: 'assistant',
|
|
190
|
+
content: {
|
|
191
|
+
type: 'text',
|
|
192
|
+
text: `${stepGuidance}
|
|
193
|
+
|
|
194
|
+
**NEXT ACTION:**
|
|
195
|
+
${nextAction}
|
|
196
|
+
|
|
197
|
+
**PROGRESS:** ${getProgressIndicator(params.step)}
|
|
198
|
+
|
|
199
|
+
**REMEMBER:** Each timesheet entry requires:
|
|
200
|
+
- ✅ Valid service_id from the project → budget → service hierarchy
|
|
201
|
+
- ✅ Detailed work description (minimum 10 characters)
|
|
202
|
+
- ✅ Specific date and time duration
|
|
203
|
+
- 📝 Optional but recommended: task_id for better tracking`,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
if (error instanceof z.ZodError) {
|
|
211
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid prompt arguments: ${error.errors.map((e) => e.message).join(', ')}`);
|
|
212
|
+
}
|
|
213
|
+
throw new McpError(ErrorCode.InternalError, error instanceof Error ? error.message : 'Unknown error occurred');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function getProgressIndicator(currentStep) {
|
|
217
|
+
const steps = ['project', 'budget', 'service', 'task', 'create'];
|
|
218
|
+
const currentIndex = steps.indexOf(currentStep);
|
|
219
|
+
return (steps
|
|
220
|
+
.map((_, index) => {
|
|
221
|
+
if (index < currentIndex)
|
|
222
|
+
return '✅';
|
|
223
|
+
if (index === currentIndex)
|
|
224
|
+
return '🔄';
|
|
225
|
+
return '⏳';
|
|
226
|
+
})
|
|
227
|
+
.join(' ') + ` (Step ${currentIndex + 1}/5)`);
|
|
228
|
+
}
|
|
229
|
+
export const timesheetPromptDefinition = {
|
|
230
|
+
name: 'timesheet_entry',
|
|
231
|
+
description: 'Guided workflow for creating timesheet entries in Productive.io. Walks you through project → budget → service → task → time entry selection with proper validation.',
|
|
232
|
+
arguments: [
|
|
233
|
+
{
|
|
234
|
+
name: 'project_name',
|
|
235
|
+
description: 'Optional: Project name or ID to start with',
|
|
236
|
+
required: false,
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: 'date',
|
|
240
|
+
description: 'Optional: Date for time entry (today, yesterday, or YYYY-MM-DD format)',
|
|
241
|
+
required: false,
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: 'time',
|
|
245
|
+
description: 'Optional: Time duration (e.g., "2h", "120m", "1.5h")',
|
|
246
|
+
required: false,
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: 'work_description',
|
|
250
|
+
description: 'Optional: Brief description of work performed',
|
|
251
|
+
required: false,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
};
|
|
255
|
+
export const quickTimesheetPromptDefinition = {
|
|
256
|
+
name: 'timesheet_step',
|
|
257
|
+
description: 'Step-by-step guidance for timesheet workflow. Use this to get specific help for each step: project, budget, service, task, or create.',
|
|
258
|
+
arguments: [
|
|
259
|
+
{
|
|
260
|
+
name: 'step',
|
|
261
|
+
description: 'Current workflow step: project, budget, service, task, or create',
|
|
262
|
+
required: true,
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'project_id',
|
|
266
|
+
description: 'Project ID if already selected',
|
|
267
|
+
required: false,
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: 'deal_id',
|
|
271
|
+
description: 'Deal/Budget ID if already selected',
|
|
272
|
+
required: false,
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'service_id',
|
|
276
|
+
description: 'Service ID if already selected',
|
|
277
|
+
required: false,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: 'task_id',
|
|
281
|
+
description: 'Task ID if already selected',
|
|
282
|
+
required: false,
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
};
|
package/build/server.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { getConfig } from './config/index.js';
|
|
6
|
+
import { ProductiveAPIClient } from './api/client.js';
|
|
7
|
+
import { withSelfPersonId } from './auth/self-resolver.js';
|
|
8
|
+
import { registerToolsOnServer } from './tools/registry.js';
|
|
9
|
+
import { getEnabledToolNames } from './tools/toolsets.js';
|
|
10
|
+
import { LOGO_DATA_URI } from './auth/logo.js';
|
|
11
|
+
import { generateTimesheetPrompt, timesheetPromptDefinition, generateQuickTimesheetPrompt, quickTimesheetPromptDefinition, } from './prompts/timesheet.js';
|
|
12
|
+
// The npm release sets the patch per CI run, so the version lives only in
|
|
13
|
+
// package.json. Resolves from both src/ (tests) and build/ (the package).
|
|
14
|
+
const { version } = createRequire(import.meta.url)('../package.json');
|
|
15
|
+
export async function createServer() {
|
|
16
|
+
const baseConfig = getConfig();
|
|
17
|
+
const apiClient = new ProductiveAPIClient(baseConfig);
|
|
18
|
+
// MCPHub-style deployments pass only the token; resolve "me" from it unless
|
|
19
|
+
// PRODUCTIVE_USER_ID is set. Must run before the description below reads it.
|
|
20
|
+
const config = await withSelfPersonId(baseConfig, apiClient);
|
|
21
|
+
const hasConfiguredUser = !!config.PRODUCTIVE_USER_ID;
|
|
22
|
+
const server = new Server({
|
|
23
|
+
name: 'Productive Remote MCP',
|
|
24
|
+
version,
|
|
25
|
+
icons: [{ src: LOGO_DATA_URI, mimeType: 'image/svg+xml', sizes: ['any'] }],
|
|
26
|
+
description: `MCP server for Productive.io API integration. Productive has a hierarchical structure: Customers → Projects → Boards → Task Lists → Tasks.${hasConfiguredUser ? ` IMPORTANT: When users say "me" or "assign to me", use "me" as the assignee_id value - it automatically resolves to the configured user ID ${config.PRODUCTIVE_USER_ID}.` : ' No user configured - set PRODUCTIVE_USER_ID to enable "me" context.'} Use the 'whoami' tool to check current user context.`,
|
|
27
|
+
}, {
|
|
28
|
+
capabilities: {
|
|
29
|
+
tools: {},
|
|
30
|
+
prompts: {},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const enabledToolNames = getEnabledToolNames(config.PRODUCTIVE_TOOLSETS);
|
|
34
|
+
// Register all tools via shared registry
|
|
35
|
+
registerToolsOnServer(server, apiClient, config, enabledToolNames);
|
|
36
|
+
// Register prompt handlers
|
|
37
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
38
|
+
prompts: [timesheetPromptDefinition, quickTimesheetPromptDefinition],
|
|
39
|
+
}));
|
|
40
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
41
|
+
const { name, arguments: args } = request.params;
|
|
42
|
+
switch (name) {
|
|
43
|
+
case 'timesheet_entry':
|
|
44
|
+
return await generateTimesheetPrompt(args);
|
|
45
|
+
case 'timesheet_step':
|
|
46
|
+
return await generateQuickTimesheetPrompt(args);
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(`Unknown prompt: ${name}`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// Connect to stdio transport
|
|
52
|
+
const transport = new StdioServerTransport();
|
|
53
|
+
await server.connect(transport);
|
|
54
|
+
return server;
|
|
55
|
+
}
|