exponential-mcp 0.13.1 → 0.14.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/dist/index.js CHANGED
@@ -5,15 +5,14 @@
5
5
  */
6
6
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
7
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
- import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
8
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
9
9
  import { ExponentialClient, createConfigStore } from 'exponential-sdk';
10
10
  import { readFileSync, existsSync } from 'fs';
11
11
  import { homedir } from 'os';
12
12
  import { dirname, join } from 'path';
13
13
  import { fileURLToPath } from 'url';
14
- import { DOMAINS, runDomainTool, toolDefinition } from './domains/index.js';
15
- import { AGENT_GUIDANCE_TOOLS, AGENT_GUIDANCE_TOOL_NAMES, runAgentGuidanceTool } from './agentGuidance.js';
16
- import { RUN_TOOLS, RUN_TOOL_NAMES, runContextFromEnv, runRunTool } from './runTools.js';
14
+ import { runContextFromEnv } from './runTools.js';
15
+ import { callTool, listTools } from './tools.js';
17
16
  const LEGACY_CONFIG_PATH = join(homedir(), '.config', 'exponential-mcp', 'config.json');
18
17
  // Report the real package version rather than a hand-maintained literal that drifts.
19
18
  const PKG_VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8')).version;
@@ -99,484 +98,12 @@ function loadClientConfig() {
99
98
  console.error('Run "npx exponential-mcp init" to set up, or set EXPONENTIAL_API_KEY env var.');
100
99
  process.exit(1);
101
100
  }
102
- /**
103
- * `undefined` = leave the field alone, `null` = clear it, otherwise a Date.
104
- * MCP arguments arrive as JSON, so an explicit clear can be either a real null
105
- * or the string "null" depending on how the model emits it.
106
- */
107
- function parseDateArg(raw) {
108
- if (raw === undefined)
109
- return undefined;
110
- if (raw === null || raw === 'null')
111
- return null;
112
- const parsed = new Date(raw);
113
- if (isNaN(parsed.getTime())) {
114
- throw new Error(`Invalid date "${String(raw)}". Use an ISO datetime, or null to clear.`);
115
- }
116
- return parsed;
117
- }
118
- const SUMMARY_PREVIEW_CHARS = 400;
119
- const DEFAULT_MEETING_LIMIT = 30;
120
- /**
121
- * A meeting row as it comes off the list read is ~3k characters of metadata
122
- * plus the full transcript, summary and notes bodies — a single hour-long
123
- * transcript is easily 50k+ characters, and the server offers no limit or
124
- * projection. The list tool sends a compact row with a summary preview; the
125
- * detail tool sends everything except the transcript unless asked.
126
- */
127
- function meetingListRow(m) {
128
- const summary = m.summary ?? null;
129
- const truncated = summary !== null && summary.length > SUMMARY_PREVIEW_CHARS;
130
- return {
131
- id: m.id,
132
- title: m.title,
133
- description: m.description,
134
- meetingDate: m.meetingDate,
135
- createdAt: m.createdAt,
136
- durationSeconds: m.durationSeconds ?? null,
137
- participantCount: m.participantCount ?? null,
138
- projectId: m.projectId,
139
- project: m.project ?? null,
140
- workspaceId: m.workspaceId,
141
- archivedAt: m.archivedAt,
142
- source: m.sourceIntegration?.provider ?? null,
143
- participants: (m.participants ?? []).map((p) => ({ id: p.id, name: p.name, email: p.email })),
144
- actions: m.actions ?? [],
145
- summaryPreview: truncated ? summary.slice(0, SUMMARY_PREVIEW_CHARS) + '…' : summary,
146
- summaryTruncated: truncated,
147
- hasNotes: Boolean(m.notes),
148
- hasTranscript: Boolean(m.transcription),
149
- };
150
- }
151
- function meetingDetail(m, includeTranscript) {
152
- // sentencesJson / analyticsJson are the server's internal processing
153
- // artefacts; they are not part of the SDK type and never useful to a model.
154
- const { transcription, sentencesJson, analyticsJson, ...rest } = m;
155
- return {
156
- ...rest,
157
- hasTranscript: Boolean(transcription),
158
- ...(includeTranscript ? { transcription } : {}),
159
- };
160
- }
161
- // Tool definitions
162
- const TOOLS = [
163
- {
164
- name: 'get_projects',
165
- description: 'List all projects in Exponential. Returns project names, status, and progress.',
166
- inputSchema: {
167
- type: 'object',
168
- properties: {
169
- workspaceId: {
170
- type: 'string',
171
- description: 'Optional workspace ID to filter projects'
172
- }
173
- }
174
- }
175
- },
176
- {
177
- name: 'get_project',
178
- description: 'Fetch one project with its relations: the objectives and key results it is linked to, DRI, team, dates, description, and linked meetings. get_projects returns none of the OKR links, so this is the tool for "what is this project driving?". It does NOT include the project\'s tasks — use get_actions with projectId for those. Accepts a project ID, a slug, or the slug-id form from app URLs.',
179
- inputSchema: {
180
- type: 'object',
181
- properties: {
182
- id: {
183
- type: 'string',
184
- description: 'Project ID, slug, or the compound slug-id from an app URL'
185
- }
186
- },
187
- required: ['id']
188
- }
189
- },
190
- {
191
- name: 'update_project',
192
- description: 'Update a project: rename, change status or priority, edit the description, set dates, or re-link it to objectives / key results. Only the fields you pass are changed. goalIds and keyResultIds REPLACE the existing links wholesale — read get_project first and pass the full set you want to keep. An empty keyResultIds clears the key-result links; an empty goalIds is ignored by the server.',
193
- inputSchema: {
194
- type: 'object',
195
- properties: {
196
- id: { type: 'string', description: 'Project ID' },
197
- name: { type: 'string', description: 'New name' },
198
- description: {
199
- type: 'string',
200
- description: 'New description. Pass an empty string to blank it.'
201
- },
202
- status: {
203
- type: 'string',
204
- enum: ['ACTIVE', 'ON_HOLD', 'COMPLETED', 'CANCELLED'],
205
- description: 'New lifecycle status'
206
- },
207
- priority: {
208
- type: 'string',
209
- enum: ['HIGH', 'MEDIUM', 'LOW', 'NONE'],
210
- description: 'New priority'
211
- },
212
- driId: {
213
- type: 'string',
214
- description: 'User ID of the directly responsible individual, or null to clear'
215
- },
216
- goalIds: {
217
- type: 'array',
218
- items: { type: 'string' },
219
- description: 'Objective IDs (integers, passed as strings) to link — replaces the current set'
220
- },
221
- keyResultIds: {
222
- type: 'array',
223
- items: { type: 'string' },
224
- description: 'Key result IDs to link — replaces the current set; [] clears'
225
- },
226
- startDate: { type: 'string', description: 'ISO datetime, or null to clear' },
227
- endDate: { type: 'string', description: 'ISO datetime, or null to clear' },
228
- reviewDate: { type: 'string', description: 'ISO datetime, or null to clear' },
229
- nextActionDate: { type: 'string', description: 'ISO datetime, or null to clear' }
230
- },
231
- required: ['id']
232
- }
233
- },
234
- {
235
- name: 'get_actions',
236
- description: 'List actions/tasks, optionally filtered by project or status. This is a flat list with no date filtering — to answer "what should I work on today" or "what am I behind on", use get_todays_actions instead.',
237
- inputSchema: {
238
- type: 'object',
239
- properties: {
240
- projectId: {
241
- type: 'string',
242
- description: 'Filter by project ID'
243
- },
244
- status: {
245
- type: 'string',
246
- enum: ['ACTIVE', 'COMPLETED', 'CANCELLED'],
247
- description: 'Filter by status (default: ACTIVE)'
248
- }
249
- }
250
- }
251
- },
252
- {
253
- name: 'get_todays_actions',
254
- description: "What is on the user's plate right now, split into overdue / today / inbox. This is the same set the /today page renders, across all workspaces. Use this FIRST for any question about today, this week, priorities, what to work on, or what the user is behind on — it is the only tool that surfaces overdue work. Returns action IDs, so pair it with update_action, defer_actions, or reschedule_actions to act on what it finds.",
255
- inputSchema: {
256
- type: 'object',
257
- properties: {
258
- workspaceId: {
259
- type: 'string',
260
- description: 'Optional workspace ID. Omit to span all workspaces (usually what you want).'
261
- }
262
- }
263
- }
264
- },
265
- {
266
- name: 'get_overdue_triage',
267
- description: 'Explain WHY the overdue pile is the size it is, before proposing what to do about it. Splits overdue actions into "cohorts" — groups sharing one exact timestamp, the fingerprint of a bulk write like a generated project plan, which were almost certainly never individually due — and "loose" individually-dated actions, which are real missed commitments. Use this whenever the user has a lot of overdue work: recommend defer_actions (amnesty) for cohorts and a real decision for loose items. Rescheduling a cohort just re-inflicts the pile tomorrow.',
268
- inputSchema: {
269
- type: 'object',
270
- properties: {
271
- workspaceId: {
272
- type: 'string',
273
- description: 'Optional workspace ID. Omit to span all workspaces.'
274
- }
275
- }
276
- }
277
- },
278
- {
279
- name: 'update_action',
280
- description: 'Update an action: rename, re-prioritise, move project, change status, or set its dates. scheduledStart is the "do date" — when the user plans to work on it — and it is what /today partitions on, taking precedence over dueDate. To move something out of the overdue bucket you must set scheduledStart; changing dueDate alone will not do it.',
281
- inputSchema: {
282
- type: 'object',
283
- properties: {
284
- id: { type: 'string', description: 'Action ID' },
285
- name: { type: 'string', description: 'New name' },
286
- description: { type: 'string', description: 'New description' },
287
- projectId: { type: 'string', description: 'Move to this project ID' },
288
- status: {
289
- type: 'string',
290
- enum: ['ACTIVE', 'COMPLETED', 'CANCELLED'],
291
- description: 'New status'
292
- },
293
- dueDate: {
294
- type: 'string',
295
- description: 'Deadline as an ISO datetime, or null to clear'
296
- },
297
- scheduledStart: {
298
- type: 'string',
299
- description: 'Do-date as an ISO datetime (e.g. 2026-08-05T09:00:00Z), or null to clear'
300
- },
301
- scheduledEnd: {
302
- type: 'string',
303
- description: 'End of the time block as an ISO datetime, or null to clear'
304
- }
305
- },
306
- required: ['id']
307
- }
308
- },
309
- {
310
- name: 'defer_actions',
311
- description: 'Amnesty: clear the dates on these actions so they fall back to their project backlog untimed. Use for work that was never really due on the date it carries — most often a bulk-created cohort from get_overdue_triage. The actions stay ACTIVE and are not deleted or archived; they simply stop counting as overdue. Prefer this over reschedule_actions when the dates were never a real commitment.',
312
- inputSchema: {
313
- type: 'object',
314
- properties: {
315
- actionIds: {
316
- type: 'array',
317
- items: { type: 'string' },
318
- description: 'Action IDs to defer'
319
- }
320
- },
321
- required: ['actionIds']
322
- }
323
- },
324
- {
325
- name: 'reschedule_actions',
326
- description: 'Move actions to a new do-date, for work that genuinely is still due, just later. Sets scheduledStart, pushing dueDate forward only where it would otherwise fall before it. If the actions were bulk-created and never individually due, use defer_actions instead — rescheduling them only re-inflicts the same pile tomorrow.',
327
- inputSchema: {
328
- type: 'object',
329
- properties: {
330
- actionIds: {
331
- type: 'array',
332
- items: { type: 'string' },
333
- description: 'Action IDs to reschedule'
334
- },
335
- date: {
336
- type: 'string',
337
- description: 'New do-date as an ISO datetime (e.g. 2026-08-05T09:00:00Z)'
338
- }
339
- },
340
- required: ['actionIds', 'date']
341
- }
342
- },
343
- {
344
- name: 'create_action',
345
- description: 'Create a new action/task. Supports natural language with dates and project names.',
346
- inputSchema: {
347
- type: 'object',
348
- properties: {
349
- text: {
350
- type: 'string',
351
- description: 'Action description (can include "tomorrow", "next week", project names, etc.)'
352
- }
353
- },
354
- required: ['text']
355
- }
356
- },
357
- {
358
- name: 'complete_action',
359
- description: 'Mark an action as completed',
360
- inputSchema: {
361
- type: 'object',
362
- properties: {
363
- id: {
364
- type: 'string',
365
- description: 'Action ID to complete'
366
- }
367
- },
368
- required: ['id']
369
- }
370
- },
371
- {
372
- name: 'get_goals',
373
- description: "List objectives (goals). Each objective carries its linked projects, which is how work ladders up to an OKR: every action has a projectId. Objectives have INTEGER ids — key results, which are separate, have CUIDs (see get_key_results). Use tree: true for the annual → quarterly cascade.",
374
- inputSchema: {
375
- type: 'object',
376
- properties: {
377
- workspaceId: {
378
- type: 'string',
379
- description: 'Optional workspace ID. With it the list is workspace-wide (every member\'s objectives); without it you get your own.'
380
- },
381
- period: {
382
- type: 'string',
383
- description: 'Optional period filter, e.g. "Q3-2026" or "Annual-2026"'
384
- },
385
- status: {
386
- type: 'string',
387
- description: 'Optional status: planned, active, completed, archived, on-hold'
388
- },
389
- tree: {
390
- type: 'boolean',
391
- description: 'Return objectives nested parent → child (up to 5 levels), each with its projects and key results, instead of a flat list'
392
- }
393
- }
394
- }
395
- },
396
- {
397
- name: 'get_key_results',
398
- description: "List key results — the measurable half of an OKR. By default groups them under their objectives (the richest read: one call for 'how is the quarter going'). Pass flat: true for a bare list. Key result ids are CUIDs; the goalId tying one to its objective is an integer.",
399
- inputSchema: {
400
- type: 'object',
401
- properties: {
402
- workspaceId: {
403
- type: 'string',
404
- description: "Optional workspace ID. With it the list is workspace-wide (every member's key results); without it you get your own."
405
- },
406
- period: {
407
- type: 'string',
408
- description: 'Optional period filter, e.g. "Q3-2026"'
409
- },
410
- goalId: {
411
- type: 'number',
412
- description: 'Optional objective ID (an integer). Only applies with flat: true.'
413
- },
414
- status: {
415
- type: 'string',
416
- description: 'Optional status: not-started, on-track, at-risk, off-track, achieved. Only applies with flat: true.'
417
- },
418
- flat: {
419
- type: 'boolean',
420
- description: 'Return a flat list of key results rather than grouping them by objective'
421
- }
422
- }
423
- }
424
- },
425
- {
426
- name: 'get_meetings',
427
- description: 'List meetings the user can see — ones they own or attended, plus those on their projects and workspaces — newest first. Each row has metadata, participants, linked actions and a short preview of the AI summary; the full summary, notes and transcript are only in get_meeting. Use this to answer "when did I last meet Y" or to find a meeting ID, then get_meeting for what was actually said.',
428
- inputSchema: {
429
- type: 'object',
430
- properties: {
431
- workspaceId: {
432
- type: 'string',
433
- description: 'Optional workspace ID to restrict to one workspace'
434
- },
435
- meetingType: {
436
- type: 'string',
437
- enum: ['all', 'mine', 'one_on_one'],
438
- description: 'all (default) — everything visible; mine — meetings the user owns or attended; one_on_one — exactly two participants'
439
- },
440
- includeArchived: {
441
- type: 'boolean',
442
- description: 'Include archived meetings (default false)'
443
- },
444
- limit: {
445
- type: 'number',
446
- description: 'Max meetings to return, newest first (default 30)'
447
- }
448
- }
449
- }
450
- },
451
- {
452
- name: 'get_meeting',
453
- description: 'Fetch one meeting in full: participants with speaker labels, linked actions, the AI summary, and the meeting notes. The raw transcript is omitted unless includeTranscript is true — it can be tens of thousands of characters, so only pull it when the summary and notes are not enough.',
454
- inputSchema: {
455
- type: 'object',
456
- properties: {
457
- id: { type: 'string', description: 'Meeting ID' },
458
- includeTranscript: {
459
- type: 'boolean',
460
- description: 'Also return the raw transcript text (default false)'
461
- }
462
- },
463
- required: ['id']
464
- }
465
- },
466
- {
467
- name: 'create_meeting',
468
- description: 'Record a meeting in Exponential from a transcript or notes the user gives you. transcription is required by the server — if the user only has notes, put the notes text there too. A project-linked meeting inherits its project\'s workspace.',
469
- inputSchema: {
470
- type: 'object',
471
- properties: {
472
- title: { type: 'string', description: 'Meeting title' },
473
- transcription: {
474
- type: 'string',
475
- description: 'Raw transcript text (required, at least one character)'
476
- },
477
- notes: { type: 'string', description: 'Meeting notes (Markdown)' },
478
- description: { type: 'string', description: 'Short description' },
479
- meetingDate: {
480
- type: 'string',
481
- description: 'When the meeting happened, as an ISO datetime (defaults to now)'
482
- },
483
- projectId: { type: 'string', description: 'Link to this project' },
484
- workspaceId: { type: 'string', description: 'Workspace ID (ignored when projectId is set)' },
485
- participants: {
486
- type: 'array',
487
- description: 'Who attended. Each entry needs at least one of userId, contactId, or email.',
488
- items: {
489
- type: 'object',
490
- properties: {
491
- userId: { type: 'string' },
492
- contactId: { type: 'string' },
493
- email: { type: 'string' },
494
- name: { type: 'string' }
495
- }
496
- }
497
- }
498
- },
499
- required: ['title', 'transcription']
500
- }
501
- },
502
- {
503
- name: 'update_meeting',
504
- description: 'Edit a meeting\'s title, description, summary, date, or REPLACE its notes wholesale. To add to existing notes without rewriting them, use append_meeting_notes instead. Only the fields you pass are changed.',
505
- inputSchema: {
506
- type: 'object',
507
- properties: {
508
- id: { type: 'string', description: 'Meeting ID' },
509
- title: { type: 'string', description: 'New title' },
510
- description: { type: 'string', description: 'New description' },
511
- summary: { type: 'string', description: 'New summary' },
512
- notes: { type: 'string', description: 'Replacement notes body (Markdown)' },
513
- meetingDate: {
514
- type: 'string',
515
- description: 'When the meeting happened, as an ISO datetime, or null to clear'
516
- }
517
- },
518
- required: ['id']
519
- }
520
- },
521
- {
522
- name: 'append_meeting_notes',
523
- description: 'Append a block of text to a meeting\'s notes, separated by a blank line, creating the notes if there are none yet. This is the safe way to add a follow-up, decision, or action list to a meeting without clobbering what is already there.',
524
- inputSchema: {
525
- type: 'object',
526
- properties: {
527
- id: { type: 'string', description: 'Meeting ID' },
528
- text: { type: 'string', description: 'Text to append (Markdown)' }
529
- },
530
- required: ['id', 'text']
531
- }
532
- },
533
- {
534
- name: 'search',
535
- description: "Global search across everything the user can access — projects, actions/tasks, goals, workspaces, pages, meetings and more. Same coverage as the app's Cmd+K palette; matches titles. Set semantic: true to search the workspace's Knowledge index by meaning instead (meetings, resources, documents and pages, each with its best-matching passage) — that needs workspaceId. For pages only, the `pages` tool's search operation is more precise. Returns typed results with ids, workspace, and app URL.",
536
- inputSchema: {
537
- type: 'object',
538
- properties: {
539
- query: {
540
- type: 'string',
541
- description: 'Search query (3+ characters when semantic)'
542
- },
543
- workspaceId: {
544
- type: 'string',
545
- description: 'Workspace ID to restrict results to one workspace. Required when semantic is true.'
546
- },
547
- limit: {
548
- type: 'number',
549
- description: 'Max results per entity type (1-25, default 10); max sources when semantic (1-20, default 5)'
550
- },
551
- semantic: {
552
- type: 'boolean',
553
- description: 'Search by meaning over the Knowledge index instead of matching titles'
554
- },
555
- sourceTypes: {
556
- type: 'array',
557
- items: { type: 'string', enum: ['transcription', 'resource', 'document', 'page'] },
558
- description: 'With semantic: restrict to these source kinds'
559
- }
560
- },
561
- required: ['query']
562
- }
563
- },
564
- {
565
- name: 'get_workspaces',
566
- description: 'List all workspaces the user has access to',
567
- inputSchema: {
568
- type: 'object',
569
- properties: {}
570
- }
571
- }
572
- ];
573
101
  async function main() {
574
102
  const config = loadClientConfig();
575
103
  const client = new ExponentialClient({
576
104
  token: config.token,
577
105
  apiUrl: config.apiUrl,
578
106
  });
579
- const trpcClient = client.client;
580
107
  const server = new Server({
581
108
  name: 'exponential-mcp',
582
109
  version: PKG_VERSION,
@@ -590,389 +117,12 @@ async function main() {
590
117
  // the session gets the three run tools on top of everything else.
591
118
  const runContext = runContextFromEnv();
592
119
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
593
- tools: [...(runContext ? RUN_TOOLS : []), ...TOOLS, ...AGENT_GUIDANCE_TOOLS, ...[...DOMAINS.values()].map(toolDefinition)],
120
+ tools: listTools({ runContext }),
594
121
  }));
595
122
  // Handle tool calls
596
123
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
597
124
  const { name, arguments: args } = request.params;
598
- try {
599
- if (runContext && RUN_TOOL_NAMES.has(name)) {
600
- const result = await runRunTool(client, runContext, name, args);
601
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
602
- }
603
- if (AGENT_GUIDANCE_TOOL_NAMES.has(name)) {
604
- return await runAgentGuidanceTool(client, name, args);
605
- }
606
- const domain = DOMAINS.get(name);
607
- if (domain) {
608
- const result = await runDomainTool(domain, client, args);
609
- return {
610
- content: [
611
- {
612
- type: 'text',
613
- text: JSON.stringify(result, null, 2),
614
- },
615
- ],
616
- };
617
- }
618
- switch (name) {
619
- case 'get_projects': {
620
- const projects = await client.projects.list({
621
- workspaceId: args?.workspaceId,
622
- });
623
- return {
624
- content: [
625
- {
626
- type: 'text',
627
- text: JSON.stringify(projects, null, 2),
628
- },
629
- ],
630
- };
631
- }
632
- case 'get_project': {
633
- const project = await client.projects.get(args?.id);
634
- return {
635
- content: [
636
- {
637
- type: 'text',
638
- text: JSON.stringify(project, null, 2),
639
- },
640
- ],
641
- };
642
- }
643
- case 'update_project': {
644
- // `null` clears driId; the string "null" is the JSON-as-text form the
645
- // model sometimes emits, same as parseDateArg handles for dates.
646
- const rawDri = args?.driId;
647
- const driId = rawDri === undefined ? undefined : rawDri === null || rawDri === 'null' ? null : rawDri;
648
- const project = await client.projects.update({
649
- id: args?.id,
650
- name: args?.name,
651
- description: args?.description,
652
- status: args?.status,
653
- priority: args?.priority,
654
- driId,
655
- goalIds: args?.goalIds,
656
- keyResultIds: args?.keyResultIds,
657
- startDate: parseDateArg(args?.startDate),
658
- endDate: parseDateArg(args?.endDate),
659
- reviewDate: parseDateArg(args?.reviewDate),
660
- nextActionDate: parseDateArg(args?.nextActionDate),
661
- });
662
- return {
663
- content: [
664
- {
665
- type: 'text',
666
- text: `Updated project: ${project.name} (ID: ${project.id})`,
667
- },
668
- ],
669
- };
670
- }
671
- case 'get_actions': {
672
- const status = args?.status;
673
- const projectId = args?.projectId;
674
- let actions;
675
- if (status === 'COMPLETED') {
676
- actions = await client.actions.getKanban({
677
- projectId,
678
- status: 'DONE',
679
- });
680
- }
681
- else if (status === 'CANCELLED') {
682
- actions = await client.actions.getKanban({
683
- projectId,
684
- status: 'CANCELLED',
685
- });
686
- }
687
- else {
688
- actions = await client.actions.list({ projectId });
689
- }
690
- return {
691
- content: [
692
- {
693
- type: 'text',
694
- text: JSON.stringify(actions, null, 2),
695
- },
696
- ],
697
- };
698
- }
699
- case 'get_todays_actions': {
700
- const todays = await client.actions.getTodaysActions(args?.workspaceId);
701
- return {
702
- content: [
703
- {
704
- type: 'text',
705
- text: JSON.stringify(todays, null, 2),
706
- },
707
- ],
708
- };
709
- }
710
- case 'get_overdue_triage': {
711
- const triage = await client.actions.getOverdueTriage(args?.workspaceId);
712
- return {
713
- content: [
714
- {
715
- type: 'text',
716
- text: JSON.stringify(triage, null, 2),
717
- },
718
- ],
719
- };
720
- }
721
- case 'create_action': {
722
- // quickCreate's input field is `name`, not `text` -- it parses natural
723
- // language out of the name itself (dates, project names) when
724
- // parseNaturalLanguage is on, which it is by default.
725
- const action = await trpcClient.action.quickCreate.mutate({
726
- name: args?.text,
727
- });
728
- return {
729
- content: [
730
- {
731
- type: 'text',
732
- text: `Created action: ${action.name} (ID: ${action.id})`,
733
- },
734
- ],
735
- };
736
- }
737
- case 'update_action': {
738
- const action = await client.actions.update({
739
- id: args?.id,
740
- name: args?.name,
741
- description: args?.description,
742
- projectId: args?.projectId,
743
- status: args?.status,
744
- dueDate: parseDateArg(args?.dueDate),
745
- scheduledStart: parseDateArg(args?.scheduledStart),
746
- scheduledEnd: parseDateArg(args?.scheduledEnd),
747
- });
748
- return {
749
- content: [
750
- {
751
- type: 'text',
752
- text: `Updated: ${action.name} (ID: ${action.id})`,
753
- },
754
- ],
755
- };
756
- }
757
- case 'defer_actions': {
758
- const result = await client.actions.bulkDefer(args?.actionIds);
759
- return {
760
- content: [
761
- {
762
- type: 'text',
763
- text: result.message,
764
- },
765
- ],
766
- };
767
- }
768
- case 'reschedule_actions': {
769
- const when = new Date(args?.date);
770
- if (isNaN(when.getTime())) {
771
- throw new Error(`Invalid date "${String(args?.date)}". Use an ISO datetime.`);
772
- }
773
- const result = await client.actions.bulkReschedule(args?.actionIds, when);
774
- return {
775
- content: [
776
- {
777
- type: 'text',
778
- text: `Rescheduled ${result.count} action${result.count === 1 ? '' : 's'} to ${when.toISOString()}`,
779
- },
780
- ],
781
- };
782
- }
783
- case 'complete_action': {
784
- const action = await client.actions.update({
785
- id: args?.id,
786
- status: 'COMPLETED',
787
- });
788
- return {
789
- content: [
790
- {
791
- type: 'text',
792
- text: `Completed: ${action.name}`,
793
- },
794
- ],
795
- };
796
- }
797
- // Goes through the SDK's GoalsApi rather than a raw tRPC path. The old
798
- // implementation called `goal.list`, which does not exist — the tool
799
- // hard-errored with `No procedure found on path "goal.list"` on every
800
- // invocation.
801
- case 'get_goals': {
802
- const workspaceId = args?.workspaceId;
803
- const period = args?.period;
804
- const status = args?.status;
805
- const goals = args?.tree
806
- ? await client.goals.tree({ workspaceId, status })
807
- : await client.goals.list({ workspaceId, period, status });
808
- return {
809
- content: [
810
- {
811
- type: 'text',
812
- text: JSON.stringify(goals, null, 2),
813
- },
814
- ],
815
- };
816
- }
817
- case 'get_key_results': {
818
- const workspaceId = args?.workspaceId;
819
- const period = args?.period;
820
- const keyResults = args?.flat
821
- ? await client.goals.keyResults.list({
822
- workspaceId,
823
- period,
824
- goalId: args?.goalId,
825
- status: args?.status,
826
- })
827
- : await client.goals.keyResults.byObjective({ workspaceId, period });
828
- return {
829
- content: [
830
- {
831
- type: 'text',
832
- text: JSON.stringify(keyResults, null, 2),
833
- },
834
- ],
835
- };
836
- }
837
- case 'get_meetings': {
838
- const meetings = await client.meetings.list({
839
- workspaceId: args?.workspaceId,
840
- meetingType: args?.meetingType,
841
- includeArchived: args?.includeArchived,
842
- });
843
- const limit = Math.max(1, Number(args?.limit) || DEFAULT_MEETING_LIMIT);
844
- const when = (m) => new Date(m.meetingDate ?? m.createdAt).getTime();
845
- const rows = [...meetings]
846
- .sort((a, b) => when(b) - when(a))
847
- .slice(0, limit)
848
- .map(meetingListRow);
849
- return {
850
- content: [
851
- {
852
- type: 'text',
853
- text: JSON.stringify({ total: meetings.length, returned: rows.length, meetings: rows }, null, 2),
854
- },
855
- ],
856
- };
857
- }
858
- case 'get_meeting': {
859
- const meeting = await client.meetings.get(args?.id);
860
- return {
861
- content: [
862
- {
863
- type: 'text',
864
- text: JSON.stringify(meetingDetail(meeting, Boolean(args?.includeTranscript)), null, 2),
865
- },
866
- ],
867
- };
868
- }
869
- case 'create_meeting': {
870
- const meetingDate = parseDateArg(args?.meetingDate);
871
- const meeting = await client.meetings.create({
872
- title: args?.title,
873
- transcription: args?.transcription,
874
- notes: args?.notes,
875
- description: args?.description,
876
- meetingDate: meetingDate ?? undefined,
877
- projectId: args?.projectId,
878
- workspaceId: args?.workspaceId,
879
- participants: args?.participants,
880
- });
881
- return {
882
- content: [
883
- {
884
- type: 'text',
885
- text: `Created meeting: ${meeting.title ?? '(untitled)'} (ID: ${meeting.id})`,
886
- },
887
- ],
888
- };
889
- }
890
- case 'update_meeting': {
891
- const meeting = await client.meetings.update({
892
- id: args?.id,
893
- title: args?.title,
894
- description: args?.description,
895
- summary: args?.summary,
896
- notes: args?.notes,
897
- meetingDate: parseDateArg(args?.meetingDate),
898
- });
899
- return {
900
- content: [
901
- {
902
- type: 'text',
903
- text: `Updated meeting: ${meeting.title ?? '(untitled)'} (ID: ${meeting.id})`,
904
- },
905
- ],
906
- };
907
- }
908
- case 'append_meeting_notes': {
909
- const meeting = await client.meetings.appendNotes(args?.id, args?.text);
910
- return {
911
- content: [
912
- {
913
- type: 'text',
914
- text: `Appended to notes of: ${meeting.title ?? '(untitled)'} (ID: ${meeting.id})`,
915
- },
916
- ],
917
- };
918
- }
919
- case 'search': {
920
- if (args?.semantic) {
921
- const workspaceId = args?.workspaceId;
922
- if (!workspaceId) {
923
- throw new Error('semantic search runs one workspace at a time: pass workspaceId (see get_workspaces).');
924
- }
925
- const knowledge = await client.search.knowledge({
926
- query: args?.query,
927
- workspaceId,
928
- limit: args?.limit,
929
- sourceTypes: args?.sourceTypes,
930
- });
931
- return {
932
- content: [{ type: 'text', text: JSON.stringify(knowledge, null, 2) }],
933
- };
934
- }
935
- const results = await client.search.global({
936
- query: args?.query,
937
- workspaceId: args?.workspaceId,
938
- limit: args?.limit,
939
- });
940
- return {
941
- content: [
942
- {
943
- type: 'text',
944
- text: JSON.stringify(results, null, 2),
945
- },
946
- ],
947
- };
948
- }
949
- case 'get_workspaces': {
950
- const workspaces = await client.workspaces.list();
951
- return {
952
- content: [
953
- {
954
- type: 'text',
955
- text: JSON.stringify(workspaces, null, 2),
956
- },
957
- ],
958
- };
959
- }
960
- default:
961
- throw new Error(`Unknown tool: ${name}`);
962
- }
963
- }
964
- catch (error) {
965
- const message = error instanceof Error ? error.message : 'Unknown error';
966
- return {
967
- content: [
968
- {
969
- type: 'text',
970
- text: `Error: ${message}`,
971
- },
972
- ],
973
- isError: true,
974
- };
975
- }
125
+ return callTool(client, name, args, { runContext });
976
126
  });
977
127
  // Start server
978
128
  const transport = new StdioServerTransport();