@monadsag/productive-mcp 1.2.53 → 1.2.62
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/README.md +1 -1
- package/build/api/client.js +17 -0
- package/build/prompts/registry.js +24 -0
- package/build/server.js +3 -17
- package/build/tools/projects.js +2 -1
- package/build/tools/registry.js +4 -1
- package/build/tools/timers.js +76 -0
- package/build/tools/toolsets.js +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -232,7 +232,7 @@ Productive's UI calls this resource a "folder"; the API models it as a "board" (
|
|
|
232
232
|
| ---------------------------------------------------------------------------------------------------- | -------------------------------- |
|
|
233
233
|
| `list_time_entries` / `create_time_entry` / `update_time_entry` | Time entry CRUD |
|
|
234
234
|
| `set_time_entry_approval` | Approval workflow (action param) |
|
|
235
|
-
| `start_timer` / `stop_timer` / `get_timer`
|
|
235
|
+
| `start_timer` / `stop_timer` / `get_timer` / `get_running_timer` | Real-time timers |
|
|
236
236
|
| `list_services` / `get_project_services` / `list_project_deals` / `list_deal_services` | Budget & service lookup |
|
|
237
237
|
| `create_budget_service` / `update_budget_service` | Budget service (line item) CRUD |
|
|
238
238
|
| `list_budget_sections` / `create_budget_section` / `update_budget_section` / `delete_budget_section` | Budget sections (service groups) |
|
package/build/api/client.js
CHANGED
|
@@ -587,6 +587,23 @@ export class ProductiveAPIClient {
|
|
|
587
587
|
async getTimerWithTimeEntry(timerId) {
|
|
588
588
|
return this.makeRequest(`timers/${timerId}?include=time_entry`);
|
|
589
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
* A person's running timers with time entry, service and deal (budget) in one request.
|
|
592
|
+
*
|
|
593
|
+
* Live-verified (production org, 2026-11-01): an empty `filter[stopped_at]` returns only
|
|
594
|
+
* running timers -- 0 of a person's 20 stopped timers, and the one running timer of 24 in
|
|
595
|
+
* the org. `filter[stopped_at]=null` (also with `[eq]`) answers 400, "Expected a value of
|
|
596
|
+
* type 'Date'". The nested include carries the links, so the included time entry points to
|
|
597
|
+
* its service and the service to its deal.
|
|
598
|
+
*/
|
|
599
|
+
async listRunningTimers(personId) {
|
|
600
|
+
const queryParams = new URLSearchParams();
|
|
601
|
+
queryParams.append('filter[person_id]', personId);
|
|
602
|
+
queryParams.append('filter[stopped_at]', '');
|
|
603
|
+
queryParams.append('sort', '-started_at');
|
|
604
|
+
queryParams.append('include', 'time_entry,time_entry.service,time_entry.service.deal');
|
|
605
|
+
return this.makeRequest(`timers?${queryParams.toString()}`);
|
|
606
|
+
}
|
|
590
607
|
/**
|
|
591
608
|
* Create and start a new timer
|
|
592
609
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { generateTimesheetPrompt, timesheetPromptDefinition, generateQuickTimesheetPrompt, quickTimesheetPromptDefinition, } from './timesheet.js';
|
|
3
|
+
/**
|
|
4
|
+
* Register the prompt handlers on a server. Shared by both entry points (stdio
|
|
5
|
+
* and Worker), like `registerToolsOnServer`; the server must declare the
|
|
6
|
+
* `prompts` capability. The prompts are static guidance and need no API token,
|
|
7
|
+
* so the Worker registers them on the no-token path as well.
|
|
8
|
+
*/
|
|
9
|
+
export function registerPromptsOnServer(server) {
|
|
10
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
11
|
+
prompts: [timesheetPromptDefinition, quickTimesheetPromptDefinition],
|
|
12
|
+
}));
|
|
13
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
14
|
+
const { name, arguments: args } = request.params;
|
|
15
|
+
switch (name) {
|
|
16
|
+
case 'timesheet_entry':
|
|
17
|
+
return await generateTimesheetPrompt(args);
|
|
18
|
+
case 'timesheet_step':
|
|
19
|
+
return await generateQuickTimesheetPrompt(args);
|
|
20
|
+
default:
|
|
21
|
+
throw new Error(`Unknown prompt: ${name}`);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
package/build/server.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
4
|
import { getConfig } from './config/index.js';
|
|
6
5
|
import { ProductiveAPIClient } from './api/client.js';
|
|
7
6
|
import { withSelfPersonId } from './auth/self-resolver.js';
|
|
8
7
|
import { registerToolsOnServer } from './tools/registry.js';
|
|
9
8
|
import { getEnabledToolNames } from './tools/toolsets.js';
|
|
10
9
|
import { LOGO_DATA_URI } from './auth/logo.js';
|
|
11
|
-
import {
|
|
10
|
+
import { registerPromptsOnServer } from './prompts/registry.js';
|
|
12
11
|
// The npm release sets the patch per CI run, so the version lives only in
|
|
13
12
|
// package.json. Resolves from both src/ (tests) and build/ (the package).
|
|
14
13
|
const { version } = createRequire(import.meta.url)('../package.json');
|
|
@@ -33,21 +32,8 @@ export async function createServer() {
|
|
|
33
32
|
const enabledToolNames = getEnabledToolNames(config.PRODUCTIVE_TOOLSETS);
|
|
34
33
|
// Register all tools via shared registry
|
|
35
34
|
registerToolsOnServer(server, apiClient, config, enabledToolNames);
|
|
36
|
-
// Register prompt handlers
|
|
37
|
-
server
|
|
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
|
-
});
|
|
35
|
+
// Register prompt handlers via shared registry
|
|
36
|
+
registerPromptsOnServer(server);
|
|
51
37
|
// Connect to stdio transport
|
|
52
38
|
const transport = new StdioServerTransport();
|
|
53
39
|
await server.connect(transport);
|
package/build/tools/projects.js
CHANGED
|
@@ -30,8 +30,9 @@ export async function listProjectsTool(client, args) {
|
|
|
30
30
|
.map((project) => {
|
|
31
31
|
const companyId = project.relationships?.company?.data?.id;
|
|
32
32
|
const companyName = resolveName(nameMap, 'companies', companyId);
|
|
33
|
+
const archived = !!project.attributes.archived_at || project.attributes.status === 2;
|
|
33
34
|
return `• ${project.attributes.name} (ID: ${project.id})
|
|
34
|
-
Status: ${
|
|
35
|
+
Status: ${archived ? 'archived' : 'active'}
|
|
35
36
|
${companyName ? `Company: ${companyName}` : companyId ? `Company ID: ${companyId}` : ''}`;
|
|
36
37
|
})
|
|
37
38
|
.join('\n\n');
|
package/build/tools/registry.js
CHANGED
|
@@ -17,7 +17,7 @@ import { listTimeEntresTool, createTimeEntryTool, listServicesTool, getProjectSe
|
|
|
17
17
|
import { updateTimeEntryTool, updateTimeEntryDefinition } from './time-entry-update.js';
|
|
18
18
|
import { deleteTimeEntryTool, deleteTimeEntryDefinition } from './time-entry-delete.js';
|
|
19
19
|
import { setTimeEntryApprovalTool, setTimeEntryApprovalDefinition } from './time-entry-approval.js';
|
|
20
|
-
import { getTimerTool, getTimerDefinition, startTimerTool, startTimerDefinition, stopTimerTool, stopTimerDefinition, } from './timers.js';
|
|
20
|
+
import { getTimerTool, getTimerDefinition, getRunningTimerTool, getRunningTimerDefinition, startTimerTool, startTimerDefinition, stopTimerTool, stopTimerDefinition, } from './timers.js';
|
|
21
21
|
import { moveTaskToList, moveTaskToListTool } from './task-list-move.js';
|
|
22
22
|
import { addToBacklog, addToBacklogTool } from './task-backlog.js';
|
|
23
23
|
import { taskRepositionTool, taskRepositionDefinition, } from './task-reposition.js';
|
|
@@ -81,6 +81,7 @@ export function getToolDefinitions(enabledToolNames) {
|
|
|
81
81
|
deleteTimeEntryDefinition,
|
|
82
82
|
setTimeEntryApprovalDefinition,
|
|
83
83
|
getTimerDefinition,
|
|
84
|
+
getRunningTimerDefinition,
|
|
84
85
|
startTimerDefinition,
|
|
85
86
|
stopTimerDefinition,
|
|
86
87
|
listCustomFieldsDefinition,
|
|
@@ -248,6 +249,8 @@ export async function handleToolCall(name, args, apiClient, config, enabledToolN
|
|
|
248
249
|
return await setTimeEntryApprovalTool(apiClient, args);
|
|
249
250
|
case 'get_timer':
|
|
250
251
|
return await getTimerTool(apiClient, args);
|
|
252
|
+
case 'get_running_timer':
|
|
253
|
+
return await getRunningTimerTool(apiClient, args, config);
|
|
251
254
|
case 'start_timer':
|
|
252
255
|
return await startTimerTool(apiClient, args);
|
|
253
256
|
case 'stop_timer':
|
package/build/tools/timers.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { formatMinutesDisplay } from './time-entries.js';
|
|
3
|
+
import { resolvePersonId } from './tool-helpers.js';
|
|
3
4
|
import { toMcpError } from '../utils/errors.js';
|
|
4
5
|
const getTimerSchema = z.object({
|
|
5
6
|
timer_id: z.string().min(1, 'Timer ID is required'),
|
|
@@ -12,6 +13,9 @@ const startTimerSchema = z.object({
|
|
|
12
13
|
const stopTimerSchema = z.object({
|
|
13
14
|
timer_id: z.string().min(1, 'Timer ID is required'),
|
|
14
15
|
});
|
|
16
|
+
const getRunningTimerSchema = z.object({
|
|
17
|
+
person_id: z.string().min(1).default('me'),
|
|
18
|
+
});
|
|
15
19
|
function formatTimerResponse(action, timer) {
|
|
16
20
|
const isRunning = timer.attributes.stopped_at === null;
|
|
17
21
|
let text = `Timer ${action}!\n`;
|
|
@@ -127,6 +131,78 @@ export async function stopTimerTool(client, args) {
|
|
|
127
131
|
throw toMcpError(error);
|
|
128
132
|
}
|
|
129
133
|
}
|
|
134
|
+
/** Note, service, budget and time-entry lines of a running timer, read from `included`. */
|
|
135
|
+
function describeTimerContext(timer, included) {
|
|
136
|
+
const find = (type, id) => id ? included.find((r) => r.type === type && r.id === id) : undefined;
|
|
137
|
+
const timeEntryId = timer.relationships?.time_entry?.data?.id;
|
|
138
|
+
const entry = find('time_entries', timeEntryId);
|
|
139
|
+
const serviceId = entry?.relationships?.service?.data?.id;
|
|
140
|
+
const service = find('services', serviceId);
|
|
141
|
+
const dealId = service?.relationships?.deal?.data?.id;
|
|
142
|
+
const deal = find('deals', dealId);
|
|
143
|
+
let text = '';
|
|
144
|
+
if (entry?.attributes.note) {
|
|
145
|
+
text += `\nNote: ${entry.attributes.note}`;
|
|
146
|
+
}
|
|
147
|
+
if (service) {
|
|
148
|
+
text += `\nService: ${service.attributes.name} (ID: ${serviceId})`;
|
|
149
|
+
}
|
|
150
|
+
if (deal) {
|
|
151
|
+
text += `\nBudget: ${deal.attributes.name} (ID: ${dealId})`;
|
|
152
|
+
}
|
|
153
|
+
if (timeEntryId) {
|
|
154
|
+
text += `\nTime Entry ID: ${timeEntryId}`;
|
|
155
|
+
}
|
|
156
|
+
return text;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The running timer of a person, wherever it was started (web app, phone, start_timer).
|
|
160
|
+
* One request returns it with its time entry, service and budget (see listRunningTimers).
|
|
161
|
+
*/
|
|
162
|
+
export async function getRunningTimerTool(client, args, config) {
|
|
163
|
+
try {
|
|
164
|
+
const params = getRunningTimerSchema.parse(args ?? {});
|
|
165
|
+
const personId = resolvePersonId(params.person_id, config);
|
|
166
|
+
const who = `person ${personId}${params.person_id === 'me' ? ' (me)' : ''}`;
|
|
167
|
+
const response = await client.listRunningTimers(personId);
|
|
168
|
+
// The API filters both; checked again so that a filter that stops working never shows a
|
|
169
|
+
// stopped timer or another person's timer.
|
|
170
|
+
const own = response.data.filter((t) => String(t.attributes.person_id) === personId);
|
|
171
|
+
const timer = own.find((t) => t.attributes.stopped_at === null);
|
|
172
|
+
if (!timer) {
|
|
173
|
+
if (own.length < response.data.length) {
|
|
174
|
+
// Other people's timers came back: the person's timer may sit beyond this page.
|
|
175
|
+
throw new Error(`Productive ignored the person filter, so whether ${who} has a running timer is unknown.`);
|
|
176
|
+
}
|
|
177
|
+
return { content: [{ type: 'text', text: `No running timer for ${who}.` }] };
|
|
178
|
+
}
|
|
179
|
+
const minutes = Math.max(0, Math.floor((Date.now() - new Date(timer.attributes.started_at).getTime()) / 60000));
|
|
180
|
+
let text = `Running timer for ${who}\n`;
|
|
181
|
+
text += `ID: ${timer.id}\n`;
|
|
182
|
+
text += `Started at: ${timer.attributes.started_at}\n`;
|
|
183
|
+
text += `Running for: ${formatMinutesDisplay(minutes)}`;
|
|
184
|
+
text += describeTimerContext(timer, response.included ?? []);
|
|
185
|
+
return { content: [{ type: 'text', text }] };
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
throw toMcpError(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export const getRunningTimerDefinition = {
|
|
192
|
+
name: 'get_running_timer',
|
|
193
|
+
description: 'Find the timer that is running right now for a person, no matter where it was started (Productive web app, phone, or start_timer) -- unlike get_timer, which needs the timer ID. Returns the timer ID, start time, how long it has been running, the note, the service and budget, and the linked time-entry ID, or says that no timer is running. Read-only.',
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
person_id: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
description: 'Person whose running timer to find. "me" uses PRODUCTIVE_USER_ID. Default "me".',
|
|
200
|
+
default: 'me',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
annotations: { title: 'Get running timer', readOnlyHint: true, openWorldHint: true },
|
|
205
|
+
};
|
|
130
206
|
export const getTimerDefinition = {
|
|
131
207
|
name: 'get_timer',
|
|
132
208
|
description: "Read a timer's current state by ID — returns whether it is running or stopped, its start time, elapsed total_time, and the linked time-entry ID. Call this after start_timer to poll a running timer's progress without changing it; it is the read-only companion to start_timer/stop_timer and never mutates the timer (unlike stop_timer, which ends it).",
|
package/build/tools/toolsets.js
CHANGED
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monadsag/productive-mcp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.62",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@monadsag/productive-mcp",
|
|
9
|
-
"version": "1.2.
|
|
9
|
+
"version": "1.2.62",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@modelcontextprotocol/sdk": "^1.13.2",
|