exponential-mcp 0.7.0 → 0.11.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 +7 -1
- package/dist/cli.js +0 -0
- package/dist/domains/databases.d.ts +2 -0
- package/dist/domains/databases.js +168 -0
- package/dist/domains/index.js +2 -0
- package/dist/domains/pages.js +84 -8
- package/dist/index.js +54 -16
- package/dist/runTools.d.ts +29 -0
- package/dist/runTools.js +98 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -137,7 +137,7 @@ and CLI can:
|
|
|
137
137
|
`actions` · `projects` · `workspaces` · `goals` · `key_results` · `meetings` ·
|
|
138
138
|
`time` · `decisions` · `contacts` · `organizations` · `deals` · `products` ·
|
|
139
139
|
`features` · `scopes` · `requirements` · `areas` · `stories` · `epics` ·
|
|
140
|
-
`tickets` · `labels` · `pages` · `comments`
|
|
140
|
+
`tickets` · `labels` · `pages` · `databases` · `comments`
|
|
141
141
|
|
|
142
142
|
Each takes `{ operation, params }`. The tool description lists every operation
|
|
143
143
|
with a one-line signature; `operation: "describe"` returns the full parameter
|
|
@@ -152,6 +152,12 @@ Invalid params come back as an error that includes the expected schema.
|
|
|
152
152
|
`comments` covers comments on actions, features, pages, goals and tickets — pass
|
|
153
153
|
`target` to choose which.
|
|
154
154
|
|
|
155
|
+
`databases` is the typed write path for tables inside pages (ADR-0078): a
|
|
156
|
+
database is a block in a page body and each row is a page. **Values are typed
|
|
157
|
+
per property** — a select takes an option name, a date an ISO string, a person
|
|
158
|
+
a user ID — and a wrong value is refused naming the property, so call `get`
|
|
159
|
+
first to learn the schema. Reading the page with `pages` shows the table.
|
|
160
|
+
|
|
155
161
|
### Asking about the day
|
|
156
162
|
|
|
157
163
|
Use **`get_todays_actions`**, not `get_actions`, for anything about today,
|
package/dist/cli.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { id, op } from './framework.js';
|
|
3
|
+
const note = z
|
|
4
|
+
.string()
|
|
5
|
+
.optional()
|
|
6
|
+
.describe('Why you made this change — one sentence. It is recorded on the row page\'s revision; a write without one reads "No reason given".');
|
|
7
|
+
const databaseId = id('Database');
|
|
8
|
+
const PROPERTY_TYPES = [
|
|
9
|
+
'text',
|
|
10
|
+
'number',
|
|
11
|
+
'select',
|
|
12
|
+
'multiSelect',
|
|
13
|
+
'date',
|
|
14
|
+
'checkbox',
|
|
15
|
+
'url',
|
|
16
|
+
'person',
|
|
17
|
+
'createdTime',
|
|
18
|
+
'lastEditedTime',
|
|
19
|
+
'createdBy',
|
|
20
|
+
];
|
|
21
|
+
const optionInput = z.object({
|
|
22
|
+
id: z.string().optional().describe('Pass to rename or recolour an existing option; omit for a new one'),
|
|
23
|
+
name: z.string().min(1),
|
|
24
|
+
color: z
|
|
25
|
+
.enum(['gray', 'red', 'pink', 'grape', 'violet', 'indigo', 'blue', 'cyan', 'teal', 'green', 'lime', 'yellow', 'orange'])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Palette name; defaults to the next free colour'),
|
|
28
|
+
});
|
|
29
|
+
const filterInput = z.object({
|
|
30
|
+
propertyId: z.string().describe('Property ID (not name)'),
|
|
31
|
+
op: z.enum(['eq', 'neq', 'contains', 'isEmpty', 'isNotEmpty', 'gt', 'lt', 'before', 'after', 'anyOf']),
|
|
32
|
+
value: z
|
|
33
|
+
.unknown()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Checked like a written value: a select by option name or id; anyOf a list; gt/lt a number; before/after an ISO date'),
|
|
36
|
+
});
|
|
37
|
+
const viewInput = z
|
|
38
|
+
.object({
|
|
39
|
+
sort: z.object({ propertyId: z.string(), direction: z.enum(['asc', 'desc']) }).optional(),
|
|
40
|
+
filters: z.array(filterInput).default([]),
|
|
41
|
+
hiddenPropertyIds: z.array(z.string()).default([]),
|
|
42
|
+
propertyOrder: z.array(z.string()).default([]).describe('Column order by property ID; unlisted properties follow in definition order'),
|
|
43
|
+
})
|
|
44
|
+
.describe('A whole view: { sort?, filters, hiddenPropertyIds, propertyOrder }. Every property it names must exist (by ID).');
|
|
45
|
+
/**
|
|
46
|
+
* Cell values: the one place agents get this wrong, so the description spells
|
|
47
|
+
* out the typing rules the server enforces.
|
|
48
|
+
*/
|
|
49
|
+
const values = z
|
|
50
|
+
.record(z.unknown())
|
|
51
|
+
.describe('Cell values keyed by property NAME or ID. Each value is typed by its property and a wrong one is refused naming the property: ' +
|
|
52
|
+
'title/text/url → string; number → number (or numeric string); select → an option NAME or id (not free text — add the option first with update_property); ' +
|
|
53
|
+
'multiSelect → list of option names/ids (or comma-separated string); date → ISO 8601 string; checkbox → boolean or "yes"/"no"; ' +
|
|
54
|
+
'person → user ID or list of them. null clears a cell. The title property\'s value becomes the row page\'s title. ' +
|
|
55
|
+
'createdTime/lastEditedTime/createdBy are read-only; relation values are set in V3.');
|
|
56
|
+
export const databases = {
|
|
57
|
+
name: 'databases',
|
|
58
|
+
description: 'Databases: typed tables inside pages (ADR-0078). A database is a block in a page body, owned by that page; each row is a page of its own — read its prose and history with the `pages` tool (`get` on the row ID shows its property header). ' +
|
|
59
|
+
'WRITES ARE TYPED: every value is checked against its property\'s type and a bad value is refused with the property named — read the database first (`get`) to learn the property names, types and select options. ' +
|
|
60
|
+
'Reading the holding page with `pages.get` shows the table; use this tool to write, or to read rows as data. ' +
|
|
61
|
+
'Not a work tracker: never put tasks, tickets or projects in a database — those have their own tools.',
|
|
62
|
+
operations: {
|
|
63
|
+
create: op({
|
|
64
|
+
summary: 'Create a database on a page with a title property, and (by default) place its block at the end of the page body. Then add properties and rows.',
|
|
65
|
+
params: z.object({
|
|
66
|
+
pageId: id('Page').describe('The page that will hold it; you need edit access'),
|
|
67
|
+
name: z.string().min(1).describe('e.g. "Metrics"'),
|
|
68
|
+
place: z
|
|
69
|
+
.boolean()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('Default true: append the marker line to the page body so the page shows the table. False returns the marker for you to place.'),
|
|
72
|
+
note,
|
|
73
|
+
}),
|
|
74
|
+
run: async (client, { pageId, name, place, note: why }) => {
|
|
75
|
+
const database = await client.databases.create({ pageId, name });
|
|
76
|
+
if (place === false || !database.marker)
|
|
77
|
+
return { ...database, placed: false };
|
|
78
|
+
const page = await client.pages.get(pageId);
|
|
79
|
+
const body = page.body?.trimEnd();
|
|
80
|
+
await client.pages.update({
|
|
81
|
+
id: pageId,
|
|
82
|
+
body: body ? `${body}\n\n${database.marker}` : database.marker,
|
|
83
|
+
baseVersion: page.docVersion,
|
|
84
|
+
note: why ?? `Add the ${database.name} database`,
|
|
85
|
+
});
|
|
86
|
+
return { ...database, placed: true };
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
get: op({
|
|
90
|
+
summary: 'One database: its properties (names, types, select options with ids), saved view, row count and holding page. Read this before writing rows.',
|
|
91
|
+
params: z.object({ id: databaseId }),
|
|
92
|
+
run: (client, { id }) => client.databases.get(id),
|
|
93
|
+
}),
|
|
94
|
+
list: op({
|
|
95
|
+
summary: 'The databases a page holds, detached ones included (detachedAt set: the block is out of the body; rows wait 30 days for the purge).',
|
|
96
|
+
params: z.object({ pageId: id('Page') }),
|
|
97
|
+
run: (client, { pageId }) => client.databases.list(pageId),
|
|
98
|
+
}),
|
|
99
|
+
update: op({
|
|
100
|
+
summary: 'Rename a database, or replace its saved view WHOLE (send the full view, not a patch).',
|
|
101
|
+
params: z.object({ id: databaseId, name: z.string().min(1).optional(), view: viewInput.optional() }),
|
|
102
|
+
run: (client, params) => client.databases.update(params),
|
|
103
|
+
}),
|
|
104
|
+
delete: op({
|
|
105
|
+
summary: 'Delete a database and every row with it (the rows are pages). Removing the block from the page only detaches; this is the delete.',
|
|
106
|
+
params: z.object({ id: databaseId }),
|
|
107
|
+
run: (client, { id }) => client.databases.delete(id),
|
|
108
|
+
}),
|
|
109
|
+
add_property: op({
|
|
110
|
+
summary: `Add a property (column). Types: ${PROPERTY_TYPES.join(', ')}. title exists from creation; relation arrives with V3. Select options get stable ids.`,
|
|
111
|
+
params: z.object({
|
|
112
|
+
id: databaseId,
|
|
113
|
+
name: z.string().min(1),
|
|
114
|
+
type: z.enum(PROPERTY_TYPES),
|
|
115
|
+
description: z.string().optional(),
|
|
116
|
+
options: z.array(optionInput).optional().describe('select/multiSelect only'),
|
|
117
|
+
}),
|
|
118
|
+
run: (client, params) => client.databases.addProperty(params),
|
|
119
|
+
}),
|
|
120
|
+
update_property: op({
|
|
121
|
+
summary: 'Rename, retype, describe or re-option a property. Ids stay, no row is rewritten. options replaces the whole list: include existing options with their id to keep them, leave one out to remove it.',
|
|
122
|
+
params: z.object({
|
|
123
|
+
id: databaseId,
|
|
124
|
+
propertyId: z.string().describe('Property ID or its (unique) name'),
|
|
125
|
+
name: z.string().min(1).optional(),
|
|
126
|
+
description: z.string().nullable().optional().describe('null clears it'),
|
|
127
|
+
type: z.enum(PROPERTY_TYPES).optional().describe('Not for the title property'),
|
|
128
|
+
options: z.array(optionInput).optional(),
|
|
129
|
+
}),
|
|
130
|
+
run: (client, params) => client.databases.updateProperty(params),
|
|
131
|
+
}),
|
|
132
|
+
remove_property: op({
|
|
133
|
+
summary: 'Remove a property from the schema and view (never the title). Row values under it stay until each row is next written.',
|
|
134
|
+
params: z.object({ id: databaseId, propertyId: z.string().describe('Property ID or name') }),
|
|
135
|
+
run: (client, { id, propertyId }) => client.databases.removeProperty(id, propertyId),
|
|
136
|
+
}),
|
|
137
|
+
reorder_properties: op({
|
|
138
|
+
summary: 'Set the column order; propertyIds must name every property exactly once.',
|
|
139
|
+
params: z.object({ id: databaseId, propertyIds: z.array(z.string()).min(1) }),
|
|
140
|
+
run: (client, { id, propertyIds }) => client.databases.reorderProperties(id, propertyIds),
|
|
141
|
+
}),
|
|
142
|
+
list_rows: op({
|
|
143
|
+
summary: 'Rows with their typed values (keyed by property ID; select values are option ids — map them with get), through the saved view or a view you pass. Paged: pass nextCursor back as cursor. columns = visible property ids in order.',
|
|
144
|
+
params: z.object({
|
|
145
|
+
id: databaseId,
|
|
146
|
+
view: viewInput.optional(),
|
|
147
|
+
limit: z.number().int().min(1).max(200).optional().describe('Default 50'),
|
|
148
|
+
cursor: z.string().optional(),
|
|
149
|
+
}),
|
|
150
|
+
run: (client, { id, ...options }) => client.databases.listRows(id, options),
|
|
151
|
+
}),
|
|
152
|
+
add_row: op({
|
|
153
|
+
summary: 'Add a row with typed values (see values). It becomes a page placed where the holding page is; the title property is its title.',
|
|
154
|
+
params: z.object({ id: databaseId, values: values.optional(), note }),
|
|
155
|
+
run: (client, { id, values: v, note: why }) => client.databases.createRow(id, v ?? {}, { note: why }),
|
|
156
|
+
}),
|
|
157
|
+
update_row: op({
|
|
158
|
+
summary: 'Write some of a row\'s cells (see values). Cells you do not name are kept; null clears one. Recorded as a revision on the row page.',
|
|
159
|
+
params: z.object({ rowId: id('Row page'), values, note }),
|
|
160
|
+
run: (client, { rowId, values: v, note: why }) => client.databases.updateRow(rowId, v, { note: why }),
|
|
161
|
+
}),
|
|
162
|
+
delete_row: op({
|
|
163
|
+
summary: 'Delete a row: the page and its search chunks.',
|
|
164
|
+
params: z.object({ rowId: id('Row page') }),
|
|
165
|
+
run: (client, { rowId }) => client.databases.deleteRow(rowId),
|
|
166
|
+
}),
|
|
167
|
+
},
|
|
168
|
+
};
|
package/dist/domains/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { actions } from './actions.js';
|
|
|
2
2
|
import { areas } from './areas.js';
|
|
3
3
|
import { comments } from './comments.js';
|
|
4
4
|
import { contacts } from './contacts.js';
|
|
5
|
+
import { databases } from './databases.js';
|
|
5
6
|
import { deals } from './deals.js';
|
|
6
7
|
import { decisions } from './decisions.js';
|
|
7
8
|
import { epics } from './epics.js';
|
|
@@ -44,5 +45,6 @@ export const DOMAINS = new Map([
|
|
|
44
45
|
tickets,
|
|
45
46
|
labels,
|
|
46
47
|
pages,
|
|
48
|
+
databases,
|
|
47
49
|
comments,
|
|
48
50
|
].map((domain) => [domain.name, domain]));
|
package/dist/domains/pages.js
CHANGED
|
@@ -1,44 +1,120 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { id, op, workspaceId } from './framework.js';
|
|
2
|
+
import { date, id, op, workspaceId } from './framework.js';
|
|
3
|
+
const note = z
|
|
4
|
+
.string()
|
|
5
|
+
.optional()
|
|
6
|
+
.describe('Why you made this change — one sentence. Always send it: it is shown in the page history, and a write without one reads "No reason given" to everyone.');
|
|
7
|
+
const source = z
|
|
8
|
+
.string()
|
|
9
|
+
.nullable()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('Provenance: where the facts come from — a URL, a document, a person. Empty/null clears it.');
|
|
12
|
+
const asOf = date('Provenance: the date the facts were true').nullable().optional();
|
|
3
13
|
export const pages = {
|
|
4
14
|
name: 'pages',
|
|
5
|
-
description: 'Knowledge pages: workspace-scoped Markdown documents (PRDs, research,
|
|
15
|
+
description: 'Knowledge pages: workspace-scoped Markdown documents (strategy, PRDs, research, specs), optionally filed under a project. Reads are Markdown-only (the editor doc is never sent); use `outline` then `get` with `section` on long pages. Every write is recorded in the page history — pass a `note` saying why, and `baseVersion` so you never overwrite a newer edit. Link one to a feature with `features` link_page; page comments are in the `comments` tool.',
|
|
6
16
|
operations: {
|
|
7
17
|
list: op({
|
|
8
|
-
summary: 'List pages you can view, most recently edited first.
|
|
18
|
+
summary: 'List pages you can view, most recently edited first. Metadata only (no body) — use get for the content, search to find pages by meaning.',
|
|
9
19
|
params: z.object({
|
|
10
20
|
workspaceId,
|
|
11
21
|
projectId: id('Project').optional(),
|
|
12
|
-
search: z.string().optional().describe('Case-insensitive match
|
|
22
|
+
search: z.string().optional().describe('Case-insensitive title match; use the search operation for content or meaning'),
|
|
13
23
|
}),
|
|
14
24
|
run: (client, params) => client.pages.list(params),
|
|
15
25
|
}),
|
|
26
|
+
search: op({
|
|
27
|
+
summary: 'Find pages by meaning: semantic hits from the Knowledge index first (nearest first, with the matching passage as snippet), then pages whose title or body contain the text. Only pages you can view.',
|
|
28
|
+
params: z.object({
|
|
29
|
+
workspaceId,
|
|
30
|
+
query: z.string().min(2).max(200).describe('What the page should be about'),
|
|
31
|
+
projectId: id('Project').optional(),
|
|
32
|
+
limit: z.number().int().min(1).max(25).optional().describe('Max pages (default 10)'),
|
|
33
|
+
}),
|
|
34
|
+
run: (client, params) => client.pages.search(params),
|
|
35
|
+
}),
|
|
16
36
|
get: op({
|
|
17
|
-
summary: 'Get one page
|
|
37
|
+
summary: 'Get one page: Markdown body, bodyBytes (size of the whole body) and canEdit. Pass section to read one heading only.',
|
|
38
|
+
params: z.object({
|
|
39
|
+
id: id('Page'),
|
|
40
|
+
section: z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe('Only this heading\'s section (case-insensitive; "## " prefix allowed). Unknown headings fail with the list that exists.'),
|
|
44
|
+
}),
|
|
45
|
+
run: (client, { id, section }) => client.pages.get(id, { format: 'markdown', section }),
|
|
46
|
+
}),
|
|
47
|
+
outline: op({
|
|
48
|
+
summary: 'The page\'s headings (level, text, line) and bodyBytes, no body — see a long page\'s shape before reading a section.',
|
|
18
49
|
params: z.object({ id: id('Page') }),
|
|
19
|
-
run: (client, { id }) => client.pages.
|
|
50
|
+
run: (client, { id }) => client.pages.outline(id),
|
|
20
51
|
}),
|
|
21
52
|
create: op({
|
|
22
|
-
summary: 'Create a page. Title defaults to "Untitled"; a non-empty body is indexed for search.',
|
|
53
|
+
summary: 'Create a page. Title defaults to "Untitled"; a non-empty body is indexed for search. The note lands on its first revision.',
|
|
23
54
|
params: z.object({
|
|
24
55
|
workspaceId,
|
|
25
56
|
projectId: z.string().nullable().optional().describe('Project ID to file it under (null/omit = workspace-level)'),
|
|
26
57
|
title: z.string().optional(),
|
|
27
58
|
body: z.string().optional().describe('Markdown body'),
|
|
28
59
|
includeInSearch: z.boolean().optional().describe('Default true'),
|
|
60
|
+
note,
|
|
61
|
+
source,
|
|
62
|
+
asOf,
|
|
29
63
|
}),
|
|
30
64
|
run: (client, params) => client.pages.create(params),
|
|
31
65
|
}),
|
|
32
66
|
update: op({
|
|
33
|
-
summary: 'Update a page. Only the fields you pass change; body replaces the whole document (comment anchors are carried across where their text survives).',
|
|
67
|
+
summary: 'Update a page. Only the fields you pass change; body replaces the whole document (comment anchors are carried across where their text survives). Send baseVersion (the docVersion you read) so a newer edit by someone else fails with CONFLICT instead of being overwritten.',
|
|
34
68
|
params: z.object({
|
|
35
69
|
id: id('Page'),
|
|
36
70
|
title: z.string().optional(),
|
|
37
71
|
projectId: z.string().nullable().optional().describe('Project ID (null to move to workspace-level)'),
|
|
38
72
|
includeInSearch: z.boolean().optional(),
|
|
39
73
|
body: z.string().optional().describe('Markdown body; replaces the existing body entirely'),
|
|
74
|
+
baseVersion: z.number().int().min(0).optional().describe('The docVersion you read before editing'),
|
|
75
|
+
note,
|
|
76
|
+
source,
|
|
77
|
+
asOf,
|
|
40
78
|
}),
|
|
41
79
|
run: (client, params) => client.pages.update(params),
|
|
42
80
|
}),
|
|
81
|
+
history: op({
|
|
82
|
+
summary: 'The page\'s revisions, newest first: who (authorHidden when names are withheld from you; baseline and automated rows have no author and the note says what wrote them), when, kind (baseline/create/editor/markdown/restore), note, provenance and body size. Never the bodies.',
|
|
83
|
+
params: z.object({
|
|
84
|
+
id: id('Page'),
|
|
85
|
+
limit: z.number().int().min(1).max(200).optional().describe('Default 50'),
|
|
86
|
+
cursor: z.string().optional().describe('nextCursor from a previous call'),
|
|
87
|
+
}),
|
|
88
|
+
run: (client, { id, ...options }) => client.pages.history(id, options),
|
|
89
|
+
}),
|
|
90
|
+
revision: op({
|
|
91
|
+
summary: 'One revision with its Markdown body.',
|
|
92
|
+
params: z.object({ id: id('Page'), revisionId: id('Revision') }),
|
|
93
|
+
run: (client, { id, revisionId }) => client.pages.revision(id, revisionId),
|
|
94
|
+
}),
|
|
95
|
+
diff: op({
|
|
96
|
+
summary: 'What a revision changed: a unified diff of the Markdown with added/removed counts, plus titleChanged and provenanceChanged (source/asOf on both sides). against: "previous" (default — the revision before it), "current" (the page now) or another revision id.',
|
|
97
|
+
params: z.object({
|
|
98
|
+
id: id('Page'),
|
|
99
|
+
revisionId: id('Revision'),
|
|
100
|
+
against: z.string().optional().describe('"previous" (default), "current", or a revision ID'),
|
|
101
|
+
}),
|
|
102
|
+
run: (client, { id, revisionId, against }) => client.pages.diff(id, revisionId, { against }),
|
|
103
|
+
}),
|
|
104
|
+
restore: op({
|
|
105
|
+
summary: 'Put a revision\'s title and body back as the page\'s current content. A forward write: docVersion bumps and a "restore" revision is recorded, so nothing is lost.',
|
|
106
|
+
params: z.object({
|
|
107
|
+
id: id('Page'),
|
|
108
|
+
revisionId: id('Revision'),
|
|
109
|
+
note,
|
|
110
|
+
baseVersion: z
|
|
111
|
+
.number()
|
|
112
|
+
.int()
|
|
113
|
+
.min(0)
|
|
114
|
+
.optional()
|
|
115
|
+
.describe('The newest revision\'s docVersion from history when you decided; a newer save makes this a CONFLICT. Always send it.'),
|
|
116
|
+
}),
|
|
117
|
+
run: (client, { id, revisionId, note, baseVersion }) => client.pages.restore(id, revisionId, { note, baseVersion }),
|
|
118
|
+
}),
|
|
43
119
|
},
|
|
44
120
|
};
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { homedir } from 'os';
|
|
|
12
12
|
import { dirname, join } from 'path';
|
|
13
13
|
import { fileURLToPath } from 'url';
|
|
14
14
|
import { DOMAINS, runDomainTool, toolDefinition } from './domains/index.js';
|
|
15
|
+
import { RUN_TOOLS, RUN_TOOL_NAMES, runContextFromEnv, runRunTool } from './runTools.js';
|
|
15
16
|
const LEGACY_CONFIG_PATH = join(homedir(), '.config', 'exponential-mcp', 'config.json');
|
|
16
17
|
// Report the real package version rather than a hand-maintained literal that drifts.
|
|
17
18
|
const PKG_VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8')).version;
|
|
@@ -73,23 +74,29 @@ function migrateLegacyConfig() {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
function loadClientConfig() {
|
|
77
|
+
// An explicit key in the environment wins over the stored config: a process
|
|
78
|
+
// that starts this server for a specific principal — `exponential runner
|
|
79
|
+
// start` launching it for an Assistant run with the Assistant's agent key —
|
|
80
|
+
// must act as that principal, not as whoever last ran `init` here.
|
|
81
|
+
const envToken = process.env.EXPONENTIAL_API_KEY || process.env.EXPONENTIAL_API_TOKEN;
|
|
82
|
+
if (envToken) {
|
|
83
|
+
assertTokenIsUsable(envToken, 'EXPONENTIAL_API_KEY');
|
|
84
|
+
return {
|
|
85
|
+
token: envToken,
|
|
86
|
+
apiUrl: process.env.EXPONENTIAL_API_URL ||
|
|
87
|
+
process.env.EXPONENTIAL_BASE_URL ||
|
|
88
|
+
'https://www.exponential.im',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
76
91
|
migrateLegacyConfig();
|
|
77
92
|
if (configStore.isAuthenticated()) {
|
|
78
93
|
const config = configStore.loadConfig();
|
|
79
94
|
assertTokenIsUsable(config.token, 'stored config');
|
|
80
95
|
return { token: config.token, apiUrl: config.apiUrl };
|
|
81
96
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'https://www.exponential.im';
|
|
86
|
-
if (!token) {
|
|
87
|
-
console.error('Error: No API key found.');
|
|
88
|
-
console.error('Run "npx exponential-mcp init" to set up, or set EXPONENTIAL_API_KEY env var.');
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
assertTokenIsUsable(token, 'EXPONENTIAL_API_KEY');
|
|
92
|
-
return { token, apiUrl };
|
|
97
|
+
console.error('Error: No API key found.');
|
|
98
|
+
console.error('Run "npx exponential-mcp init" to set up, or set EXPONENTIAL_API_KEY env var.');
|
|
99
|
+
process.exit(1);
|
|
93
100
|
}
|
|
94
101
|
/**
|
|
95
102
|
* `undefined` = leave the field alone, `null` = clear it, otherwise a Date.
|
|
@@ -524,21 +531,30 @@ const TOOLS = [
|
|
|
524
531
|
},
|
|
525
532
|
{
|
|
526
533
|
name: 'search',
|
|
527
|
-
description: "Global
|
|
534
|
+
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.",
|
|
528
535
|
inputSchema: {
|
|
529
536
|
type: 'object',
|
|
530
537
|
properties: {
|
|
531
538
|
query: {
|
|
532
539
|
type: 'string',
|
|
533
|
-
description: 'Search query'
|
|
540
|
+
description: 'Search query (3+ characters when semantic)'
|
|
534
541
|
},
|
|
535
542
|
workspaceId: {
|
|
536
543
|
type: 'string',
|
|
537
|
-
description: '
|
|
544
|
+
description: 'Workspace ID to restrict results to one workspace. Required when semantic is true.'
|
|
538
545
|
},
|
|
539
546
|
limit: {
|
|
540
547
|
type: 'number',
|
|
541
|
-
description: 'Max results per entity type (1-25, default 10)'
|
|
548
|
+
description: 'Max results per entity type (1-25, default 10); max sources when semantic (1-20, default 5)'
|
|
549
|
+
},
|
|
550
|
+
semantic: {
|
|
551
|
+
type: 'boolean',
|
|
552
|
+
description: 'Search by meaning over the Knowledge index instead of matching titles'
|
|
553
|
+
},
|
|
554
|
+
sourceTypes: {
|
|
555
|
+
type: 'array',
|
|
556
|
+
items: { type: 'string', enum: ['transcription', 'resource', 'document', 'page'] },
|
|
557
|
+
description: 'With semantic: restrict to these source kinds'
|
|
542
558
|
}
|
|
543
559
|
},
|
|
544
560
|
required: ['query']
|
|
@@ -569,13 +585,20 @@ async function main() {
|
|
|
569
585
|
},
|
|
570
586
|
});
|
|
571
587
|
// List available tools
|
|
588
|
+
// Started for an Agent run (`exponential runner start` sets EXPONENTIAL_RUN_ID):
|
|
589
|
+
// the session gets the three run tools on top of everything else.
|
|
590
|
+
const runContext = runContextFromEnv();
|
|
572
591
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
573
|
-
tools: [...TOOLS, ...[...DOMAINS.values()].map(toolDefinition)],
|
|
592
|
+
tools: [...(runContext ? RUN_TOOLS : []), ...TOOLS, ...[...DOMAINS.values()].map(toolDefinition)],
|
|
574
593
|
}));
|
|
575
594
|
// Handle tool calls
|
|
576
595
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
577
596
|
const { name, arguments: args } = request.params;
|
|
578
597
|
try {
|
|
598
|
+
if (runContext && RUN_TOOL_NAMES.has(name)) {
|
|
599
|
+
const result = await runRunTool(client, runContext, name, args);
|
|
600
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
601
|
+
}
|
|
579
602
|
const domain = DOMAINS.get(name);
|
|
580
603
|
if (domain) {
|
|
581
604
|
const result = await runDomainTool(domain, client, args);
|
|
@@ -890,6 +913,21 @@ async function main() {
|
|
|
890
913
|
};
|
|
891
914
|
}
|
|
892
915
|
case 'search': {
|
|
916
|
+
if (args?.semantic) {
|
|
917
|
+
const workspaceId = args?.workspaceId;
|
|
918
|
+
if (!workspaceId) {
|
|
919
|
+
throw new Error('semantic search runs one workspace at a time: pass workspaceId (see get_workspaces).');
|
|
920
|
+
}
|
|
921
|
+
const knowledge = await client.search.knowledge({
|
|
922
|
+
query: args?.query,
|
|
923
|
+
workspaceId,
|
|
924
|
+
limit: args?.limit,
|
|
925
|
+
sourceTypes: args?.sourceTypes,
|
|
926
|
+
});
|
|
927
|
+
return {
|
|
928
|
+
content: [{ type: 'text', text: JSON.stringify(knowledge, null, 2) }],
|
|
929
|
+
};
|
|
930
|
+
}
|
|
893
931
|
const results = await client.search.global({
|
|
894
932
|
query: args?.query,
|
|
895
933
|
workspaceId: args?.workspaceId,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run tools (Exponential ADR-0067, Agent PRD V2): how a session the local
|
|
3
|
+
* runner spawned talks to its Agent run. They exist only when the server was
|
|
4
|
+
* started for a run — `EXPONENTIAL_RUN_ID` set in the environment by
|
|
5
|
+
* `exponential runner start` (which also passes the Assistant's agent key as
|
|
6
|
+
* `EXPONENTIAL_API_KEY` and its name as `EXPONENTIAL_RUNNER_ID`). Outside a
|
|
7
|
+
* run they are not listed, so an ordinary MCP session never sees them.
|
|
8
|
+
*
|
|
9
|
+
* - `report_progress` — a one-line note for the run's transcript. The runner
|
|
10
|
+
* records it from the session's own tool stream, so this tool only
|
|
11
|
+
* acknowledges; nothing is written from here.
|
|
12
|
+
* - `ask_owner` — asks the owner and PAUSES the run: the app posts the question
|
|
13
|
+
* as a comment mentioning the owner and parks the run; the owner's reply
|
|
14
|
+
* starts a new run. The session must stop after calling it.
|
|
15
|
+
* - `finish_run` — closes the run with a public summary and whether the action
|
|
16
|
+
* is ready for the owner to confirm. The run never completes the action.
|
|
17
|
+
*/
|
|
18
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
19
|
+
import type { ExponentialClient } from 'exponential-sdk';
|
|
20
|
+
export interface RunContext {
|
|
21
|
+
runId: string;
|
|
22
|
+
runnerId?: string;
|
|
23
|
+
}
|
|
24
|
+
/** The run this server was started for, if any. */
|
|
25
|
+
export declare function runContextFromEnv(env?: NodeJS.ProcessEnv): RunContext | null;
|
|
26
|
+
export declare const RUN_TOOLS: Tool[];
|
|
27
|
+
export declare const RUN_TOOL_NAMES: Set<string>;
|
|
28
|
+
/** Dispatch one run tool. The caller has already checked `RUN_TOOL_NAMES.has(name)`. */
|
|
29
|
+
export declare function runRunTool(client: Pick<ExponentialClient, 'agentRuns'>, context: RunContext, name: string, args: Record<string, unknown> | undefined): Promise<unknown>;
|
package/dist/runTools.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run tools (Exponential ADR-0067, Agent PRD V2): how a session the local
|
|
3
|
+
* runner spawned talks to its Agent run. They exist only when the server was
|
|
4
|
+
* started for a run — `EXPONENTIAL_RUN_ID` set in the environment by
|
|
5
|
+
* `exponential runner start` (which also passes the Assistant's agent key as
|
|
6
|
+
* `EXPONENTIAL_API_KEY` and its name as `EXPONENTIAL_RUNNER_ID`). Outside a
|
|
7
|
+
* run they are not listed, so an ordinary MCP session never sees them.
|
|
8
|
+
*
|
|
9
|
+
* - `report_progress` — a one-line note for the run's transcript. The runner
|
|
10
|
+
* records it from the session's own tool stream, so this tool only
|
|
11
|
+
* acknowledges; nothing is written from here.
|
|
12
|
+
* - `ask_owner` — asks the owner and PAUSES the run: the app posts the question
|
|
13
|
+
* as a comment mentioning the owner and parks the run; the owner's reply
|
|
14
|
+
* starts a new run. The session must stop after calling it.
|
|
15
|
+
* - `finish_run` — closes the run with a public summary and whether the action
|
|
16
|
+
* is ready for the owner to confirm. The run never completes the action.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
20
|
+
/** The run this server was started for, if any. */
|
|
21
|
+
export function runContextFromEnv(env = process.env) {
|
|
22
|
+
const runId = env.EXPONENTIAL_RUN_ID?.trim();
|
|
23
|
+
if (!runId)
|
|
24
|
+
return null;
|
|
25
|
+
return { runId, runnerId: env.EXPONENTIAL_RUNNER_ID?.trim() || undefined };
|
|
26
|
+
}
|
|
27
|
+
const reportProgressParams = z.object({
|
|
28
|
+
text: z.string().min(1).max(500).describe('One line, present tense: what you are doing now'),
|
|
29
|
+
});
|
|
30
|
+
const askOwnerParams = z.object({
|
|
31
|
+
question: z
|
|
32
|
+
.string()
|
|
33
|
+
.min(1)
|
|
34
|
+
.max(10000)
|
|
35
|
+
.describe('The question, with enough context that the owner can answer from their inbox'),
|
|
36
|
+
});
|
|
37
|
+
const finishRunParams = z.object({
|
|
38
|
+
summary: z
|
|
39
|
+
.string()
|
|
40
|
+
.min(1)
|
|
41
|
+
.max(10000)
|
|
42
|
+
.describe('What you did, found or delegated. Public: the requester, the owner and their teammates read it'),
|
|
43
|
+
readyToClose: z
|
|
44
|
+
.boolean()
|
|
45
|
+
.describe('true when the work is done and the owner only needs to confirm; false when follow-up is needed'),
|
|
46
|
+
});
|
|
47
|
+
function schema(params) {
|
|
48
|
+
const { $schema: _ignored, ...rest } = zodToJsonSchema(params, {
|
|
49
|
+
target: 'jsonSchema7',
|
|
50
|
+
$refStrategy: 'none',
|
|
51
|
+
});
|
|
52
|
+
return rest;
|
|
53
|
+
}
|
|
54
|
+
export const RUN_TOOLS = [
|
|
55
|
+
{
|
|
56
|
+
name: 'report_progress',
|
|
57
|
+
description: 'Post a one-line progress note to this run\'s transcript (owner-visible only; nobody is notified). Use it when you move to a new phase of the work.',
|
|
58
|
+
inputSchema: schema(reportProgressParams),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'ask_owner',
|
|
62
|
+
description: 'Ask your owner a question you cannot answer yourself and PAUSE this run. The question is posted on the action mentioning the owner; their reply resumes the work in a new run. This must be your LAST call: do not call finish_run after it and do not keep working — stop immediately.',
|
|
63
|
+
inputSchema: schema(askOwnerParams),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'finish_run',
|
|
67
|
+
description: 'Finish this run. Call it exactly once, as your last action, with a public summary and whether the action is ready for the owner to close. Never mark the action complete yourself; the owner confirms from their inbox.',
|
|
68
|
+
inputSchema: schema(finishRunParams),
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
export const RUN_TOOL_NAMES = new Set(RUN_TOOLS.map((t) => t.name));
|
|
72
|
+
/** Dispatch one run tool. The caller has already checked `RUN_TOOL_NAMES.has(name)`. */
|
|
73
|
+
export async function runRunTool(client, context, name, args) {
|
|
74
|
+
switch (name) {
|
|
75
|
+
case 'report_progress': {
|
|
76
|
+
const { text } = reportProgressParams.parse(args ?? {});
|
|
77
|
+
return { ok: true, text };
|
|
78
|
+
}
|
|
79
|
+
case 'ask_owner': {
|
|
80
|
+
const { question } = askOwnerParams.parse(args ?? {});
|
|
81
|
+
const result = await client.agentRuns.finish(context.runId, { status: 'WAITING_ON_OWNER', question }, context.runnerId);
|
|
82
|
+
return {
|
|
83
|
+
...result,
|
|
84
|
+
stop: true,
|
|
85
|
+
message: result.finished
|
|
86
|
+
? 'Your question was posted and the run is now waiting on your owner. Stop here: make no further tool calls and end your turn.'
|
|
87
|
+
: 'The run is no longer running (it was cancelled); nothing was posted. Stop here.',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
case 'finish_run': {
|
|
91
|
+
const { summary, readyToClose } = finishRunParams.parse(args ?? {});
|
|
92
|
+
const result = await client.agentRuns.finish(context.runId, { status: 'SUCCEEDED', summary, readyToClose }, context.runnerId);
|
|
93
|
+
return { ...result, message: result.finished ? 'Run finished. End your turn.' : 'The run had already ended; nothing changed. End your turn.' };
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Unknown run tool "${name}"`);
|
|
97
|
+
}
|
|
98
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exponential-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "MCP server for Exponential - connect Claude to your projects, actions, goals, CRM, tickets and more",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
28
28
|
"commander": "^12.0.0",
|
|
29
|
-
"exponential-sdk": "^1.
|
|
29
|
+
"exponential-sdk": "^1.26.0",
|
|
30
30
|
"zod": "^3.22.0",
|
|
31
31
|
"zod-to-json-schema": "^3.25.2"
|
|
32
32
|
},
|