@idea-base/mcp-server 2.1.0 → 2.2.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.
- package/README.md +18 -2
- package/package.json +1 -1
- package/src/index.js +157 -5
package/README.md
CHANGED
|
@@ -85,8 +85,24 @@ Ask Claude to manage your projects:
|
|
|
85
85
|
| Tool | Description |
|
|
86
86
|
|------|-------------|
|
|
87
87
|
| `log_time` | Log time against a task with notes |
|
|
88
|
-
| `start_working` |
|
|
89
|
-
| `
|
|
88
|
+
| `start_working` | Open a timed work session on a task, and mark yourself actively working (surfaces the saved resume context + recent work notes so a cold session re-orients). Calling it twice never opens a second session — it resumes or reports the one you have |
|
|
89
|
+
| `pause_working` | Pause the open session without ending it, with a required `reason` |
|
|
90
|
+
| `resume_working` | Close the pause and carry on in the same session |
|
|
91
|
+
| `stop_working` | Close the session with a UTC end instant and drop the active flag (optionally capture a `note` and/or `resume_context` on the way out). Fails if you have no open session |
|
|
92
|
+
|
|
93
|
+
**Sessions are measured, and the pause reason decides the number.** `start_working`
|
|
94
|
+
records a UTC start instant, `stop_working` a UTC end instant, and each pause in
|
|
95
|
+
between records both its boundaries plus why work stopped:
|
|
96
|
+
|
|
97
|
+
| `reason` | Effect on worked time |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `waiting_on_human` | **Excluded.** A person has to act before you can continue |
|
|
100
|
+
| `waiting_on_agent` | **Counted.** A sub-agent blocked on another *active* sub-agent is still working |
|
|
101
|
+
| `other` | Counted |
|
|
102
|
+
|
|
103
|
+
Only waiting on the human is not working. Use `pause_working` rather than
|
|
104
|
+
`stop_working` whenever you intend to carry on — `stop_working` ends the session
|
|
105
|
+
and the reason is lost.
|
|
90
106
|
|
|
91
107
|
### Activity & Audit Trail
|
|
92
108
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -226,6 +226,7 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
226
226
|
|
|
227
227
|
if (!response.ok) {
|
|
228
228
|
let message = `API error: ${response.status}`;
|
|
229
|
+
let code = null;
|
|
229
230
|
const contentType = (response.headers.get('content-type') || '');
|
|
230
231
|
if (contentType.includes('json')) {
|
|
231
232
|
try {
|
|
@@ -233,11 +234,20 @@ async function apiRequest(endpoint, options = {}) {
|
|
|
233
234
|
if (typeof body?.error === 'string' && body.error) {
|
|
234
235
|
message = body.error.slice(0, MAX_ERROR_CHARS);
|
|
235
236
|
}
|
|
237
|
+
// Machine-readable discriminator, when the endpoint supplies one. A
|
|
238
|
+
// handler needs to tell "you have no open session" (a real answer the
|
|
239
|
+
// caller must see) apart from "that endpoint is not deployed yet"
|
|
240
|
+
// (an infrastructure fact it should degrade around), and string-matching
|
|
241
|
+
// a prose error message to decide that is how quiet bugs get written.
|
|
242
|
+
if (typeof body?.code === 'string' && body.code) code = body.code;
|
|
236
243
|
} catch {
|
|
237
244
|
// fall through to the generic status message
|
|
238
245
|
}
|
|
239
246
|
}
|
|
240
|
-
|
|
247
|
+
const error = new Error(redact(message));
|
|
248
|
+
error.status = response.status;
|
|
249
|
+
if (code) error.code = code;
|
|
250
|
+
throw error;
|
|
241
251
|
}
|
|
242
252
|
|
|
243
253
|
return parseJsonBody(text, response);
|
|
@@ -750,7 +760,7 @@ const tools = [
|
|
|
750
760
|
},
|
|
751
761
|
{
|
|
752
762
|
name: 'start_working',
|
|
753
|
-
description: '
|
|
763
|
+
description: 'Start work on a task. Two things happen: you are shown to the team as actively working on it (and a todo task moves to in_progress), and a TIMED WORK SESSION is opened with a UTC start instant, so how long the task was actually worked becomes measurable instead of guessed.\n\nCalling it a second time on the same task NEVER opens a second session. If your session is paused it is resumed; if it is already running you are told so, with how long it has been going. The response always says which of the three happened.\n\nIt also orients a cold session: the response carries the task\'s resume context and its recent work notes, so read the whole thing before you start. Pair it with stop_working, and use pause_working when you have to wait on something.',
|
|
754
764
|
inputSchema: {
|
|
755
765
|
type: 'object',
|
|
756
766
|
properties: {
|
|
@@ -764,7 +774,7 @@ const tools = [
|
|
|
764
774
|
},
|
|
765
775
|
{
|
|
766
776
|
name: 'stop_working',
|
|
767
|
-
description: '
|
|
777
|
+
description: 'Stop working on a task: close your open work session with a UTC end instant, and drop the "actively working" flag (you stay assigned). The closed session is what makes the task\'s worked duration reportable.\n\nRequires an open session — if you have none this FAILS and writes nothing, rather than inventing a session with no start. Call start_working first.\n\nThis ENDS the session. If you are only waiting on something and intend to carry on afterwards, use pause_working instead: a pause keeps the session open and records why you stopped, which is what decides whether the interval counts as worked time.\n\nOptionally capture your state on the way out: pass `note` to append a work note and/or `resume_context` to overwrite the resume block, so the next session can pick up where you left off.',
|
|
768
778
|
inputSchema: {
|
|
769
779
|
type: 'object',
|
|
770
780
|
properties: {
|
|
@@ -784,6 +794,43 @@ const tools = [
|
|
|
784
794
|
required: ['task_id'],
|
|
785
795
|
},
|
|
786
796
|
},
|
|
797
|
+
{
|
|
798
|
+
name: 'pause_working',
|
|
799
|
+
description: 'Pause your open work session without ending it, and record WHY. Use this whenever work stops but is not finished — you asked the human a question, you are waiting on another agent, you are blocked on a build.\n\nTHE REASON IS THE POINT, and it decides the number:\n waiting_on_human — you are blocked on a person and CANNOT proceed. The paused interval is EXCLUDED from worked time.\n waiting_on_agent — you are blocked on another agent or an automated run that is itself active. The interval IS COUNTED as worked time: a sub-agent blocked on another active sub-agent is still working.\n other — anything else. Counted as worked.\n\nOnly waiting on the human is not working. Choose waiting_on_human ONLY when a person has to act before you can continue; if a machine or another agent is doing the work, it is waiting_on_agent.\n\nResume with resume_working. Do NOT use stop_working for a pause — that ends the session and the reason is lost.',
|
|
800
|
+
inputSchema: {
|
|
801
|
+
type: 'object',
|
|
802
|
+
properties: {
|
|
803
|
+
task_id: {
|
|
804
|
+
type: 'number',
|
|
805
|
+
description: 'The ID of the task whose session to pause',
|
|
806
|
+
},
|
|
807
|
+
reason: {
|
|
808
|
+
type: 'string',
|
|
809
|
+
enum: ['waiting_on_human', 'waiting_on_agent', 'other'],
|
|
810
|
+
description: 'Why work stopped. waiting_on_human EXCLUDES this interval from worked time; waiting_on_agent and other INCLUDE it. Required — there is no default, because the whole worked-time figure turns on this value.',
|
|
811
|
+
},
|
|
812
|
+
detail: {
|
|
813
|
+
type: 'string',
|
|
814
|
+
description: 'Optional free text: what specifically you are waiting on (e.g. "asked whether to merge PR #280").',
|
|
815
|
+
},
|
|
816
|
+
},
|
|
817
|
+
required: ['task_id', 'reason'],
|
|
818
|
+
},
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: 'resume_working',
|
|
822
|
+
description: 'Resume your paused work session — closes the pause by recording the UTC instant you came back, so the paused interval has both boundaries and can be measured. The session itself was never closed and keeps its original start.\n\nFails if the session is not paused, rather than pretending to resume something. start_working also resumes a paused session, so use whichever reads better; this one does not re-fetch the orientation block.',
|
|
823
|
+
inputSchema: {
|
|
824
|
+
type: 'object',
|
|
825
|
+
properties: {
|
|
826
|
+
task_id: {
|
|
827
|
+
type: 'number',
|
|
828
|
+
description: 'The ID of the task whose session to resume',
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
required: ['task_id'],
|
|
832
|
+
},
|
|
833
|
+
},
|
|
787
834
|
{
|
|
788
835
|
name: 'add_work_note',
|
|
789
836
|
description: 'Append a timestamped work note (status update) to a task\'s activity log. Use this to record progress so a future session can pick up where you left off (e.g. "finished auth handler, tests green, next: wire the callback"). Notes are append-only and never overwrite each other.',
|
|
@@ -1293,11 +1340,36 @@ const toolHandlers = {
|
|
|
1293
1340
|
},
|
|
1294
1341
|
|
|
1295
1342
|
async start_working({ task_id }) {
|
|
1343
|
+
// Presence first, and unchanged: this is what writes the `started_working`
|
|
1344
|
+
// task_events row and promotes a todo task to in_progress. The timed session
|
|
1345
|
+
// below sits ALONGSIDE that audit trail, it does not replace it.
|
|
1296
1346
|
await apiRequest(`/tasks/${task_id}/assignments`, {
|
|
1297
1347
|
method: 'POST',
|
|
1298
1348
|
body: JSON.stringify({ is_active: true }),
|
|
1299
1349
|
});
|
|
1300
1350
|
|
|
1351
|
+
// Open (or resume, or report) the work session. Non-fatal by design: the
|
|
1352
|
+
// presence write already succeeded, and a session failure must not make
|
|
1353
|
+
// start_working look like it did nothing.
|
|
1354
|
+
let timing = '';
|
|
1355
|
+
try {
|
|
1356
|
+
const result = await apiRequest(`/tasks/${task_id}/work-session`, {
|
|
1357
|
+
method: 'POST',
|
|
1358
|
+
body: JSON.stringify({}),
|
|
1359
|
+
});
|
|
1360
|
+
const s = result.session || {};
|
|
1361
|
+
if (result.action === 'resumed') {
|
|
1362
|
+
const p = result.resumed_pause || {};
|
|
1363
|
+
timing = `\n\nResumed work session #${s.id}, open since ${s.started_at} — the ${p.reason} pause that began at ${p.paused_at} is now closed. No second session was opened.`;
|
|
1364
|
+
} else if (result.action === 'already_running') {
|
|
1365
|
+
timing = `\n\nWork session #${s.id} was ALREADY running (started ${s.started_at}, ${s.worked_minutes} min worked so far). No second session was opened.`;
|
|
1366
|
+
} else {
|
|
1367
|
+
timing = `\n\nWork session #${s.id} opened at ${s.started_at} (UTC). Close it with stop_working; if you have to wait on something, use pause_working so the reason is recorded.`;
|
|
1368
|
+
}
|
|
1369
|
+
} catch (error) {
|
|
1370
|
+
timing = `\n\n(Work session NOT recorded: ${error.message} — your presence flag is set, but no duration will be measured for this stretch.)`;
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1301
1373
|
// Orient a cold-starting session: surface the resume context + recent work notes.
|
|
1302
1374
|
let orientation = '';
|
|
1303
1375
|
try {
|
|
@@ -1330,7 +1402,7 @@ const toolHandlers = {
|
|
|
1330
1402
|
content: [
|
|
1331
1403
|
{
|
|
1332
1404
|
type: 'text',
|
|
1333
|
-
text: `Started working on task #${task_id}. Other team members can now see you are actively working on this task.${orientation}`,
|
|
1405
|
+
text: `Started working on task #${task_id}. Other team members can now see you are actively working on this task.${timing}${orientation}`,
|
|
1334
1406
|
},
|
|
1335
1407
|
],
|
|
1336
1408
|
};
|
|
@@ -1353,6 +1425,42 @@ const toolHandlers = {
|
|
|
1353
1425
|
captured.push('resume context');
|
|
1354
1426
|
}
|
|
1355
1427
|
|
|
1428
|
+
// Close the session BEFORE dropping presence, so a task with no open
|
|
1429
|
+
// session fails here and nothing at all is changed.
|
|
1430
|
+
//
|
|
1431
|
+
// A missing session is a real answer, not an infrastructure hiccup: it means
|
|
1432
|
+
// the caller believes it was timing work that was never timed. Report it and
|
|
1433
|
+
// stop, rather than writing a session row with no start or silently clearing
|
|
1434
|
+
// the flag as if a duration had been recorded. Any OTHER session failure
|
|
1435
|
+
// (the endpoint being unreachable, say) must not strand the presence flag,
|
|
1436
|
+
// so that one is reported and the stop continues.
|
|
1437
|
+
let timing = '';
|
|
1438
|
+
let sessionError = null;
|
|
1439
|
+
try {
|
|
1440
|
+
const result = await apiRequest(`/tasks/${task_id}/work-session`, {
|
|
1441
|
+
method: 'DELETE',
|
|
1442
|
+
body: JSON.stringify({ state: 'completed' }),
|
|
1443
|
+
});
|
|
1444
|
+
const s = result.session || {};
|
|
1445
|
+
const paused = Number(s.paused_minutes || 0);
|
|
1446
|
+
const pausedText = paused > 0
|
|
1447
|
+
? ` (${s.elapsed_minutes} min elapsed, ${paused} min of that paused)`
|
|
1448
|
+
: '';
|
|
1449
|
+
timing = ` Work session #${s.id} closed at ${s.ended_at} — ${s.worked_minutes} minutes worked${pausedText}.`;
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
sessionError = error;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
if (sessionError?.code === 'NO_OPEN_SESSION') {
|
|
1455
|
+
throw new Error(
|
|
1456
|
+
`${sessionError.message} Nothing was changed: no session row was written and ` +
|
|
1457
|
+
'your active-work flag was left as it was.'
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
if (sessionError) {
|
|
1461
|
+
timing = ` (Work session NOT closed: ${sessionError.message})`;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1356
1464
|
await apiRequest(`/tasks/${task_id}/assignments?stop_only=true`, {
|
|
1357
1465
|
method: 'DELETE',
|
|
1358
1466
|
});
|
|
@@ -1362,7 +1470,51 @@ const toolHandlers = {
|
|
|
1362
1470
|
content: [
|
|
1363
1471
|
{
|
|
1364
1472
|
type: 'text',
|
|
1365
|
-
text: `Stopped working on task #${task_id}. You are still assigned to the task but no longer marked as actively working.${capturedText}`,
|
|
1473
|
+
text: `Stopped working on task #${task_id}. You are still assigned to the task but no longer marked as actively working.${timing}${capturedText}`,
|
|
1474
|
+
},
|
|
1475
|
+
],
|
|
1476
|
+
};
|
|
1477
|
+
},
|
|
1478
|
+
|
|
1479
|
+
async pause_working({ task_id, reason, detail }) {
|
|
1480
|
+
const result = await apiRequest(`/tasks/${task_id}/work-session/pause`, {
|
|
1481
|
+
method: 'POST',
|
|
1482
|
+
body: JSON.stringify({ reason, note: detail }),
|
|
1483
|
+
});
|
|
1484
|
+
const p = result.pause || {};
|
|
1485
|
+
const s = result.session || {};
|
|
1486
|
+
const counted = result.counts_as_worked
|
|
1487
|
+
? 'This interval WILL count as worked time.'
|
|
1488
|
+
: 'This interval will NOT count as worked time.';
|
|
1489
|
+
return {
|
|
1490
|
+
content: [
|
|
1491
|
+
{
|
|
1492
|
+
type: 'text',
|
|
1493
|
+
text:
|
|
1494
|
+
`Paused work session #${s.id} on task #${task_id} at ${p.paused_at} (reason: ${reason}). ` +
|
|
1495
|
+
`${counted} ${s.worked_minutes} minutes worked so far. ` +
|
|
1496
|
+
'The session is still open — call resume_working when you are back.',
|
|
1497
|
+
},
|
|
1498
|
+
],
|
|
1499
|
+
};
|
|
1500
|
+
},
|
|
1501
|
+
|
|
1502
|
+
async resume_working({ task_id }) {
|
|
1503
|
+
const result = await apiRequest(`/tasks/${task_id}/work-session/resume`, {
|
|
1504
|
+
method: 'POST',
|
|
1505
|
+
body: JSON.stringify({}),
|
|
1506
|
+
});
|
|
1507
|
+
const p = result.resumed_pause || {};
|
|
1508
|
+
const s = result.session || {};
|
|
1509
|
+
return {
|
|
1510
|
+
content: [
|
|
1511
|
+
{
|
|
1512
|
+
type: 'text',
|
|
1513
|
+
text:
|
|
1514
|
+
`Resumed work session #${s.id} on task #${task_id} at ${p.resumed_at}. ` +
|
|
1515
|
+
`The ${p.reason} pause ran ${p.minutes} minutes and ` +
|
|
1516
|
+
`${p.counts_as_worked ? 'COUNTS as worked time' : 'is EXCLUDED from worked time'}. ` +
|
|
1517
|
+
`${s.worked_minutes} minutes worked on this session so far.`,
|
|
1366
1518
|
},
|
|
1367
1519
|
],
|
|
1368
1520
|
};
|