exponential-mcp 0.13.0 → 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/README.md +122 -41
- package/dist/agentGuidance.js +3 -0
- package/dist/annotations.d.ts +11 -0
- package/dist/annotations.js +4 -0
- package/dist/cli.js +50 -52
- package/dist/clientConfig.d.ts +53 -0
- package/dist/clientConfig.js +103 -0
- package/dist/domains/actions.js +12 -0
- package/dist/domains/areas.js +2 -0
- package/dist/domains/comments.js +7 -0
- package/dist/domains/contacts.js +7 -0
- package/dist/domains/databases.js +13 -0
- package/dist/domains/deals.js +8 -0
- package/dist/domains/decisions.js +14 -0
- package/dist/domains/epics.js +5 -0
- package/dist/domains/features.js +7 -0
- package/dist/domains/framework.d.ts +11 -0
- package/dist/domains/framework.js +18 -0
- package/dist/domains/goals.js +11 -0
- package/dist/domains/keyResults.js +11 -0
- package/dist/domains/labels.js +4 -0
- package/dist/domains/meetings.js +9 -0
- package/dist/domains/organizations.js +3 -0
- package/dist/domains/pages.js +10 -0
- package/dist/domains/positions.js +7 -0
- package/dist/domains/products.js +5 -0
- package/dist/domains/projects.js +4 -0
- package/dist/domains/requirements.js +4 -0
- package/dist/domains/scopes.js +4 -0
- package/dist/domains/stories.js +4 -0
- package/dist/domains/tickets.js +10 -0
- package/dist/domains/time.js +5 -0
- package/dist/domains/workspaces.js +2 -0
- package/dist/index.js +5 -855
- package/dist/runTools.js +5 -0
- package/dist/tools.d.ts +27 -0
- package/dist/tools.js +899 -0
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Connect Claude to your [Exponential](https://exponential.im) workspace. Manage p
|
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
9
|
+
You need [Node.js](https://nodejs.org) 18 or later and an Exponential account. Setup is two steps: create an agent, then connect your app.
|
|
10
|
+
|
|
9
11
|
### 1. Create an Agent
|
|
10
12
|
|
|
11
13
|
Open [exponential.im/settings/agents/new](https://www.exponential.im/settings/agents/new):
|
|
@@ -15,38 +17,61 @@ Open [exponential.im/settings/agents/new](https://www.exponential.im/settings/ag
|
|
|
15
17
|
|
|
16
18
|
The agent is its own identity: what Claude does in Exponential is attributed to it, not to you.
|
|
17
19
|
|
|
18
|
-
### 2.
|
|
20
|
+
### 2. Connect Your App
|
|
21
|
+
|
|
22
|
+
Find your app below. `<key>` is the key from step 1.
|
|
23
|
+
|
|
24
|
+
#### Claude Desktop
|
|
19
25
|
|
|
20
26
|
```bash
|
|
21
27
|
npx exponential-mcp init
|
|
22
28
|
```
|
|
23
29
|
|
|
24
|
-
Paste the
|
|
30
|
+
Paste the key when prompted, then quit and reopen Claude Desktop. `init` saves the key on this machine and adds the server to Claude Desktop's config file on macOS, Windows and Linux.
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
#### Claude Code
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
```bash
|
|
35
|
+
claude mcp add --scope user exponential -e EXPONENTIAL_API_KEY=<key> -- npx -y exponential-mcp serve
|
|
36
|
+
```
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
- The server uses `.mcp.json` in your project directory
|
|
34
|
-
- Reload your VSCode window (`Cmd+Shift+P` → "Developer: Reload Window")
|
|
35
|
-
- The server will be available in your current project
|
|
38
|
+
`--scope user` makes the server available in every project. Leave it out to add the server to the current project only.
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
#### Cursor
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
Add to `~/.cursor/mcp.json` (every project) or `.cursor/mcp.json` (one project):
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"exponential": {
|
|
48
|
+
"command": "npx",
|
|
49
|
+
"args": ["-y", "exponential-mcp", "serve"],
|
|
50
|
+
"env": { "EXPONENTIAL_API_KEY": "<key>" }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
#### VS Code
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
Add to `.vscode/mcp.json`. VS Code names the top-level key `servers`, not `mcpServers`:
|
|
44
59
|
|
|
45
|
-
```
|
|
46
|
-
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"servers": {
|
|
63
|
+
"exponential": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["-y", "exponential-mcp", "serve"],
|
|
66
|
+
"env": { "EXPONENTIAL_API_KEY": "<key>" }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
47
70
|
```
|
|
48
71
|
|
|
49
|
-
|
|
72
|
+
#### Codex
|
|
73
|
+
|
|
74
|
+
Add to `~/.codex/config.toml`:
|
|
50
75
|
|
|
51
76
|
```toml
|
|
52
77
|
[mcp_servers.exponential]
|
|
@@ -55,9 +80,27 @@ args = ["-y", "exponential-mcp", "serve"]
|
|
|
55
80
|
env = { EXPONENTIAL_API_KEY = "<key>" }
|
|
56
81
|
```
|
|
57
82
|
|
|
58
|
-
|
|
83
|
+
#### Any Other MCP Client
|
|
59
84
|
|
|
60
|
-
|
|
85
|
+
Run the command `npx` with the arguments `-y exponential-mcp serve`, and set the environment variable `EXPONENTIAL_API_KEY` to your key. The server speaks MCP over stdio.
|
|
86
|
+
|
|
87
|
+
### 3. Ask
|
|
88
|
+
|
|
89
|
+
Restart the app, then try: "What's on my plate today?"
|
|
90
|
+
|
|
91
|
+
## One Key per App
|
|
92
|
+
|
|
93
|
+
Create a separate agent for each app, so that what each app does in Exponential is attributed to its own agent. The config blocks above do this: each one carries its own key in `EXPONENTIAL_API_KEY`.
|
|
94
|
+
|
|
95
|
+
`init` works differently. It saves one key on the machine, and any app whose config has no `EXPONENTIAL_API_KEY` falls back to it. `EXPONENTIAL_API_KEY` always overrides the saved key.
|
|
96
|
+
|
|
97
|
+
To give Claude Desktop its own key, add `"env": { "EXPONENTIAL_API_KEY": "<key>" }` to the `exponential` entry in its config file (see [Claude Desktop by Hand](#claude-desktop-by-hand)). Re-running `init` rewrites that entry, including its `env`.
|
|
98
|
+
|
|
99
|
+
A personal API key from [Settings → API keys](https://www.exponential.im/settings/api-keys) also works in place of an agent key, but then the app acts as you.
|
|
100
|
+
|
|
101
|
+
### Self-Hosted Exponential
|
|
102
|
+
|
|
103
|
+
Point the server at your own instance with `npx exponential-mcp init --base-url https://your-host`, or set `EXPONENTIAL_API_URL` next to `EXPONENTIAL_API_KEY` in the app's config.
|
|
61
104
|
|
|
62
105
|
## What Claude Can Do
|
|
63
106
|
|
|
@@ -73,44 +116,47 @@ Once connected, Claude can:
|
|
|
73
116
|
- **Run the product backlog** – tickets, features, epics, stories, pages and decisions
|
|
74
117
|
- **Track time** – log, confirm and report on the day
|
|
75
118
|
|
|
76
|
-
##
|
|
119
|
+
## Claude Desktop by Hand
|
|
77
120
|
|
|
78
|
-
|
|
121
|
+
`npx exponential-mcp init` edits Claude Desktop's config file for you. To do it yourself, open the file for your platform:
|
|
79
122
|
|
|
80
|
-
|
|
81
|
-
|
|
123
|
+
| Platform | Config file |
|
|
124
|
+
|----------|-------------|
|
|
125
|
+
| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
126
|
+
| Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
127
|
+
| Linux | `~/.config/Claude/claude_desktop_config.json` |
|
|
82
128
|
|
|
83
|
-
Add
|
|
129
|
+
Add the `exponential` entry under `mcpServers`, keeping any servers already there:
|
|
84
130
|
|
|
85
131
|
```json
|
|
86
132
|
{
|
|
87
133
|
"mcpServers": {
|
|
88
134
|
"exponential": {
|
|
89
|
-
"command": "
|
|
90
|
-
"args": ["
|
|
135
|
+
"command": "npx",
|
|
136
|
+
"args": ["-y", "exponential-mcp", "serve"],
|
|
137
|
+
"env": { "EXPONENTIAL_API_KEY": "<key>" }
|
|
91
138
|
}
|
|
92
139
|
}
|
|
93
140
|
}
|
|
94
141
|
```
|
|
95
142
|
|
|
96
|
-
|
|
143
|
+
Then quit and reopen Claude Desktop.
|
|
97
144
|
|
|
98
|
-
|
|
145
|
+
If you installed Node with nvm, fnm, asdf or similar, a bare `npx` will not work here: Claude Desktop does not start servers with your shell's `PATH`. Use the entry that `npx exponential-mcp doctor` prints. It names `npx` by its full path and puts Node's directory on `PATH`. `init` writes that same entry.
|
|
99
146
|
|
|
100
|
-
|
|
101
|
-
{
|
|
102
|
-
"mcpServers": {
|
|
103
|
-
"exponential": {
|
|
104
|
-
"command": "npx",
|
|
105
|
-
"args": ["-y", "exponential-mcp", "serve"]
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
```
|
|
147
|
+
## Troubleshooting
|
|
110
148
|
|
|
111
|
-
|
|
149
|
+
Start with `npx exponential-mcp doctor`. It checks the saved key and Claude Desktop's config, and prints a config entry that works on your machine.
|
|
112
150
|
|
|
113
|
-
|
|
151
|
+
| Symptom | Fix |
|
|
152
|
+
|---------|-----|
|
|
153
|
+
| The tools don't appear | Quit the app completely and reopen it. MCP servers load only at startup. |
|
|
154
|
+
| Claude Desktop logs `npx: command not found` or `env: node: No such file or directory` | Node is outside the system `PATH` (nvm and similar). Run `npx exponential-mcp init` again, or copy the entry `doctor` prints. |
|
|
155
|
+
| It worked, then stopped starting | Versions before 0.13.1 pointed Claude Desktop at npx's cache, which npx may delete. Run `npx exponential-mcp init` again. |
|
|
156
|
+
| On Windows, `init` succeeded but Claude Desktop shows nothing | Versions before 0.13.1 wrote to a file Claude Desktop does not read. Run `npx exponential-mcp init` again. |
|
|
157
|
+
| `Cannot find package …` when the server starts | npx's cache holds a half-finished install. Delete the `_npx` folder inside your npm cache (`~/.npm/_npx` on macOS and Linux) and restart the app. |
|
|
158
|
+
| The key is rejected, or the app acts as the wrong agent | `npx exponential-mcp config` shows the saved key and URL. An `EXPONENTIAL_API_KEY` in the app's config overrides the saved key. |
|
|
159
|
+
| You want the newest version | `npx -y exponential-mcp@latest --version` fetches it; then restart the app. |
|
|
114
160
|
|
|
115
161
|
## Commands
|
|
116
162
|
|
|
@@ -204,11 +250,46 @@ is `defer_actions` (amnesty); `reschedule_actions` would just re-inflict the
|
|
|
204
250
|
same pile tomorrow. Individually-dated **loose** actions are the ones that
|
|
205
251
|
deserve a real decision.
|
|
206
252
|
|
|
253
|
+
### Annotations
|
|
254
|
+
|
|
255
|
+
Every tool carries MCP tool annotations: a `title`, `readOnlyHint` and
|
|
256
|
+
`destructiveHint`. A domain tool is read-only only when every operation reads,
|
|
257
|
+
and destructive when any operation deletes. No hand-written tool deletes
|
|
258
|
+
anything.
|
|
259
|
+
|
|
260
|
+
## Using the tools in your own server
|
|
261
|
+
|
|
262
|
+
The tool registry is also exported on its own, as `exponential-mcp/tools`, so
|
|
263
|
+
another server can offer the same tools over a different transport. The
|
|
264
|
+
hosted endpoint in the Exponential app is built on it. Importing it has no side
|
|
265
|
+
effects: it reads no config, touches no files and never exits the process. You
|
|
266
|
+
build the `ExponentialClient`, so you choose who the tools act as.
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
import { ExponentialClient } from 'exponential-sdk';
|
|
270
|
+
import { listTools, callTool } from 'exponential-mcp/tools';
|
|
271
|
+
|
|
272
|
+
const client = new ExponentialClient({ token: process.env.EXPONENTIAL_API_KEY!, apiUrl: 'https://www.exponential.im' });
|
|
273
|
+
|
|
274
|
+
listTools(); // Tool[] for tools/list
|
|
275
|
+
await callTool(client, 'get_workspaces', {}); // CallToolResult for tools/call
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
- `listTools(options?)` returns every tool in `tools/list` order.
|
|
279
|
+
- `callTool(client, name, args, options?)` runs one tool. A failure comes back as
|
|
280
|
+
a result with `isError: true` rather than a throw.
|
|
281
|
+
- The three run tools (`report_progress`, `ask_owner`, `finish_run`) exist only
|
|
282
|
+
for a session serving an Agent run. They are listed and callable only when
|
|
283
|
+
`options.runContext` (`{ runId, runnerId? }`) is passed; leave it out otherwise.
|
|
284
|
+
|
|
285
|
+
The stdio server (`exponential-mcp serve`) calls the same two functions, so both
|
|
286
|
+
offer the same tools from the same release.
|
|
287
|
+
|
|
207
288
|
## Development
|
|
208
289
|
|
|
209
290
|
```bash
|
|
210
291
|
# Clone the repo
|
|
211
|
-
git clone https://github.com/
|
|
292
|
+
git clone https://github.com/exponential-im/exponential-mcp
|
|
212
293
|
cd exponential-mcp
|
|
213
294
|
|
|
214
295
|
# Install dependencies
|
package/dist/agentGuidance.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { reads } from './annotations.js';
|
|
1
2
|
const GUIDANCE_NOTE = 'This is GUIDANCE, NOT AUTHORITY (ADR-0071): it informs how to work but never grants permission for anything — check permissions and ask the user as you normally would.';
|
|
2
3
|
export const AGENT_GUIDANCE_TOOLS = [
|
|
3
4
|
{
|
|
4
5
|
name: 'get_agent_context',
|
|
6
|
+
annotations: reads('Get agent context'),
|
|
5
7
|
description: [
|
|
6
8
|
"Get the agent context for a workspace (and optionally a project): the workspace's and project's AI instructions, the project's accepted decisions (label, statement, link; `omitted` counts the rest) and, for callers with a write role, accepted ADRs (label, title, link).",
|
|
7
9
|
'Call it before starting work in a workspace or project. Fetch a decision or ADR link for its full reasoning.',
|
|
@@ -18,6 +20,7 @@ export const AGENT_GUIDANCE_TOOLS = [
|
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
name: 'get_agent_method',
|
|
23
|
+
annotations: reads('Get agent method'),
|
|
21
24
|
description: [
|
|
22
25
|
'Get the current published Exponential method: the documents (Markdown) describing how work is planned and run, with version and content hash.',
|
|
23
26
|
GUIDANCE_NOTE,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool annotations (MCP `ToolAnnotations`) for the hand-written, guidance and
|
|
3
|
+
* run tools. Domain tools derive theirs from their operations' effects
|
|
4
|
+
* (`domains/framework.ts`). No hand-written tool deletes anything.
|
|
5
|
+
*/
|
|
6
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
export type ToolAnnotations = NonNullable<Tool['annotations']>;
|
|
8
|
+
/** A tool that changes nothing. */
|
|
9
|
+
export declare const reads: (title: string) => ToolAnnotations;
|
|
10
|
+
/** A tool that creates or changes data and deletes nothing. */
|
|
11
|
+
export declare const writes: (title: string) => ToolAnnotations;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A tool that changes nothing. */
|
|
2
|
+
export const reads = (title) => ({ title, readOnlyHint: true, destructiveHint: false });
|
|
3
|
+
/** A tool that creates or changes data and deletes nothing. */
|
|
4
|
+
export const writes = (title) => ({ title, readOnlyHint: false, destructiveHint: false });
|
package/dist/cli.js
CHANGED
|
@@ -10,11 +10,18 @@ import { homedir } from 'os';
|
|
|
10
10
|
import { dirname, join } from 'path';
|
|
11
11
|
import * as readline from 'readline';
|
|
12
12
|
import { fileURLToPath } from 'url';
|
|
13
|
+
import { claudeDesktopConfigPath, diagnoseServerEntry, isClaudeDesktopInstalled, serverEntry, } from './clientConfig.js';
|
|
14
|
+
// Report the real package version rather than a hand-maintained literal that drifts.
|
|
15
|
+
const PKG_VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf-8')).version;
|
|
13
16
|
const CONFIG_DIR = join(homedir(), '.config', 'exponential-mcp');
|
|
14
17
|
const LEGACY_CONFIG_PATH = join(CONFIG_DIR, 'config.json');
|
|
15
18
|
const configStore = createConfigStore({ projectName: 'exponential-mcp' });
|
|
16
|
-
const
|
|
17
|
-
|
|
19
|
+
const HOST = {
|
|
20
|
+
platform: process.platform,
|
|
21
|
+
home: homedir(),
|
|
22
|
+
env: process.env,
|
|
23
|
+
exists: existsSync,
|
|
24
|
+
};
|
|
18
25
|
function prompt(question) {
|
|
19
26
|
const rl = readline.createInterface({
|
|
20
27
|
input: process.stdin,
|
|
@@ -45,23 +52,16 @@ function migrateLegacyConfig() {
|
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
function getClaudeConfigPath() {
|
|
48
|
-
|
|
49
|
-
if (existsSync(MACOS_CLAUDE_CONFIG_PATH)) {
|
|
50
|
-
return MACOS_CLAUDE_CONFIG_PATH;
|
|
51
|
-
}
|
|
52
|
-
if (existsSync(LEGACY_CLAUDE_CONFIG_PATH)) {
|
|
53
|
-
return LEGACY_CLAUDE_CONFIG_PATH;
|
|
54
|
-
}
|
|
55
|
-
return MACOS_CLAUDE_CONFIG_PATH;
|
|
56
|
-
}
|
|
57
|
-
return LEGACY_CLAUDE_CONFIG_PATH;
|
|
55
|
+
return claudeDesktopConfigPath(HOST);
|
|
58
56
|
}
|
|
59
57
|
function getServerEntry() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
return serverEntry(HOST, {
|
|
59
|
+
execPath: process.execPath,
|
|
60
|
+
serverPath: fileURLToPath(new URL('./index.js', import.meta.url)),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function printServerEntry() {
|
|
64
|
+
console.log(JSON.stringify({ mcpServers: { exponential: getServerEntry() } }, null, 2));
|
|
65
65
|
}
|
|
66
66
|
const DEFAULT_BASE_URL = 'https://www.exponential.im';
|
|
67
67
|
// Plain text when piped, so logs and CI output stay readable.
|
|
@@ -75,12 +75,14 @@ function printOtherAppsHelp() {
|
|
|
75
75
|
console.log('Create a separate agent for each app, then set its key in that app\'s');
|
|
76
76
|
console.log('MCP config. EXPONENTIAL_API_KEY overrides the key saved by init.\n');
|
|
77
77
|
console.log(` ${dim('Claude Code')}`);
|
|
78
|
-
console.log(' claude mcp add exponential -e EXPONENTIAL_API_KEY=<key> -- npx -y exponential-mcp serve\n');
|
|
78
|
+
console.log(' claude mcp add --scope user exponential -e EXPONENTIAL_API_KEY=<key> -- npx -y exponential-mcp serve\n');
|
|
79
79
|
console.log(` ${dim('Codex ~/.codex/config.toml')}`);
|
|
80
80
|
console.log(' [mcp_servers.exponential]');
|
|
81
81
|
console.log(' command = "npx"');
|
|
82
82
|
console.log(' args = ["-y", "exponential-mcp", "serve"]');
|
|
83
83
|
console.log(' env = { EXPONENTIAL_API_KEY = "<key>" }\n');
|
|
84
|
+
console.log(` ${dim('Cursor, VS Code and others')}`);
|
|
85
|
+
console.log(' https://github.com/exponential-im/exponential-mcp#quick-start\n');
|
|
84
86
|
console.log(dim('Restart the app afterwards. Re-running init resets the Claude Desktop entry.'));
|
|
85
87
|
}
|
|
86
88
|
function ensureParentDir(filePath) {
|
|
@@ -92,7 +94,7 @@ function ensureParentDir(filePath) {
|
|
|
92
94
|
program
|
|
93
95
|
.name('exponential-mcp')
|
|
94
96
|
.description('MCP server for Exponential - connect Claude to your productivity data')
|
|
95
|
-
.version(
|
|
97
|
+
.version(PKG_VERSION);
|
|
96
98
|
program
|
|
97
99
|
.command('init')
|
|
98
100
|
.description('Set up Exponential MCP with an agent key')
|
|
@@ -122,9 +124,13 @@ program
|
|
|
122
124
|
apiUrl: baseUrl,
|
|
123
125
|
});
|
|
124
126
|
console.log(`${green('✓')} Key saved ${dim(configStore.getConfigPath())}`);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
const claudeDesktopReady = updateClaudeConfig();
|
|
128
|
+
if (claudeDesktopReady) {
|
|
129
|
+
console.log(`\n${bold('Done.')} Restart Claude Desktop, then ask: "What's on my plate today?"\n`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.log(`\n${bold('Key saved.')} Connect an app below, then ask: "What's on my plate today?"\n`);
|
|
133
|
+
}
|
|
128
134
|
printOtherAppsHelp();
|
|
129
135
|
console.log();
|
|
130
136
|
});
|
|
@@ -160,7 +166,6 @@ program
|
|
|
160
166
|
migrateLegacyConfig();
|
|
161
167
|
const issues = [];
|
|
162
168
|
const configPath = getClaudeConfigPath();
|
|
163
|
-
const recommended = getServerEntry();
|
|
164
169
|
console.log('🩺 Exponential MCP Doctor\n');
|
|
165
170
|
if (!configStore.isAuthenticated()) {
|
|
166
171
|
issues.push('No API key found. Run "exponential-mcp init" first.');
|
|
@@ -182,19 +187,7 @@ program
|
|
|
182
187
|
issues.push('No "exponential" entry found in Claude Desktop config.');
|
|
183
188
|
}
|
|
184
189
|
else {
|
|
185
|
-
|
|
186
|
-
issues.push('MCP config is missing "command" for Exponential.');
|
|
187
|
-
}
|
|
188
|
-
else if (!existsSync(serverConfig.command)) {
|
|
189
|
-
issues.push(`MCP command not found: ${serverConfig.command}`);
|
|
190
|
-
}
|
|
191
|
-
const serverArg = Array.isArray(serverConfig.args) ? serverConfig.args[0] : null;
|
|
192
|
-
if (!serverArg) {
|
|
193
|
-
issues.push('MCP config args missing server entry point.');
|
|
194
|
-
}
|
|
195
|
-
else if (!existsSync(serverArg)) {
|
|
196
|
-
issues.push(`MCP server entry not found: ${serverArg}`);
|
|
197
|
-
}
|
|
190
|
+
issues.push(...diagnoseServerEntry(serverConfig, existsSync));
|
|
198
191
|
}
|
|
199
192
|
if (issues.length === 0) {
|
|
200
193
|
console.log('✅ No issues found. Claude Desktop should load the Exponential MCP server.');
|
|
@@ -206,31 +199,36 @@ program
|
|
|
206
199
|
}
|
|
207
200
|
}
|
|
208
201
|
console.log('\nRecommended MCP config:\n');
|
|
209
|
-
|
|
210
|
-
mcpServers: {
|
|
211
|
-
exponential: recommended,
|
|
212
|
-
},
|
|
213
|
-
}, null, 2));
|
|
202
|
+
printServerEntry();
|
|
214
203
|
});
|
|
215
|
-
|
|
204
|
+
/** Adds the server to Claude Desktop's config. False when nothing was written. */
|
|
205
|
+
function updateClaudeConfig() {
|
|
216
206
|
const configPath = getClaudeConfigPath();
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
207
|
+
if (!isClaudeDesktopInstalled(HOST, configPath)) {
|
|
208
|
+
console.log(`${dim('-')} Claude Desktop ${dim(`not found at ${dirname(configPath)}, skipped`)}`);
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
let claudeConfig = {};
|
|
220
212
|
if (existsSync(configPath)) {
|
|
221
213
|
try {
|
|
222
214
|
claudeConfig = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
223
|
-
if (!claudeConfig.mcpServers) {
|
|
224
|
-
claudeConfig.mcpServers = {};
|
|
225
|
-
}
|
|
226
215
|
}
|
|
227
|
-
catch
|
|
228
|
-
|
|
216
|
+
catch {
|
|
217
|
+
// The file holds the user's other servers. Overwriting it would lose them.
|
|
218
|
+
console.log(`! Claude Desktop ${dim(configPath)}`);
|
|
219
|
+
console.log(' That file is not valid JSON, so it was left unchanged. Fix it and run init');
|
|
220
|
+
console.log(' again, or add this entry to it by hand:\n');
|
|
221
|
+
printServerEntry();
|
|
222
|
+
return false;
|
|
229
223
|
}
|
|
230
224
|
}
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
if (typeof claudeConfig !== 'object' || claudeConfig === null || Array.isArray(claudeConfig)) {
|
|
226
|
+
claudeConfig = {};
|
|
227
|
+
}
|
|
228
|
+
claudeConfig.mcpServers = { ...claudeConfig.mcpServers, exponential: getServerEntry() };
|
|
229
|
+
ensureParentDir(configPath);
|
|
233
230
|
writeFileSync(configPath, JSON.stringify(claudeConfig, null, 2));
|
|
234
231
|
console.log(`${green('✓')} Claude Desktop ${dim(configPath)}`);
|
|
232
|
+
return true;
|
|
235
233
|
}
|
|
236
234
|
program.parse();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Claude Desktop keeps its config, and what `init` writes there.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions: the caller passes the platform, paths and an `exists` probe,
|
|
5
|
+
* so every branch (including Windows, from a Mac) is testable without touching
|
|
6
|
+
* the real filesystem.
|
|
7
|
+
*/
|
|
8
|
+
export interface Host {
|
|
9
|
+
platform: NodeJS.Platform;
|
|
10
|
+
home: string;
|
|
11
|
+
env: Record<string, string | undefined>;
|
|
12
|
+
exists: (path: string) => boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ServerEntry {
|
|
15
|
+
command: string;
|
|
16
|
+
args: string[];
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The config file Claude Desktop reads on this platform.
|
|
21
|
+
*
|
|
22
|
+
* macOS keeps its old fallback to `~/.claude/` when only that file exists.
|
|
23
|
+
* Windows and Linux do not: earlier versions wrote there on those platforms
|
|
24
|
+
* and Claude Desktop never read it, so following it would repeat the bug.
|
|
25
|
+
*/
|
|
26
|
+
export declare function claudeDesktopConfigPath(host: Host): string;
|
|
27
|
+
/**
|
|
28
|
+
* Claude Desktop creates its config directory on first launch, so a missing
|
|
29
|
+
* directory means there is no Claude Desktop here to configure.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isClaudeDesktopInstalled(host: Host, configPath: string): boolean;
|
|
32
|
+
/** npx unpacks into `~/.npm/_npx/<hash>/`, which it is free to delete. */
|
|
33
|
+
export declare function isNpxCachePath(path: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The `mcpServers.exponential` entry for Claude Desktop.
|
|
36
|
+
*
|
|
37
|
+
* A global install or a clone has a stable path, so the entry runs it directly
|
|
38
|
+
* with this Node binary. Run through `npx`, this file sits in npx's cache: a
|
|
39
|
+
* path that disappears when the cache is cleared and never sees a new release.
|
|
40
|
+
* Then the entry calls `npx` instead.
|
|
41
|
+
*
|
|
42
|
+
* Claude Desktop does not start servers with the shell's PATH. Under nvm (or
|
|
43
|
+
* any Node outside the system directories) a bare `npx` is not found, and an
|
|
44
|
+
* absolute `npx` still fails with "env: node: No such file or directory",
|
|
45
|
+
* because npx and the server both start through `#!/usr/bin/env node`. So the
|
|
46
|
+
* entry names `npx` by absolute path and puts Node's directory on PATH.
|
|
47
|
+
*/
|
|
48
|
+
export declare function serverEntry(host: Pick<Host, 'platform' | 'exists'>, runtime: {
|
|
49
|
+
execPath: string;
|
|
50
|
+
serverPath: string;
|
|
51
|
+
}): ServerEntry;
|
|
52
|
+
/** What is wrong with an existing `mcpServers.exponential` entry, if anything. */
|
|
53
|
+
export declare function diagnoseServerEntry(entry: unknown, exists: (path: string) => boolean): string[];
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Claude Desktop keeps its config, and what `init` writes there.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions: the caller passes the platform, paths and an `exists` probe,
|
|
5
|
+
* so every branch (including Windows, from a Mac) is testable without touching
|
|
6
|
+
* the real filesystem.
|
|
7
|
+
*/
|
|
8
|
+
import { posix, win32 } from 'path';
|
|
9
|
+
const CONFIG_FILE = 'claude_desktop_config.json';
|
|
10
|
+
const NPX_ARGS = ['-y', 'exponential-mcp', 'serve'];
|
|
11
|
+
const POSIX_SYSTEM_PATH = ['/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'];
|
|
12
|
+
/**
|
|
13
|
+
* The config file Claude Desktop reads on this platform.
|
|
14
|
+
*
|
|
15
|
+
* macOS keeps its old fallback to `~/.claude/` when only that file exists.
|
|
16
|
+
* Windows and Linux do not: earlier versions wrote there on those platforms
|
|
17
|
+
* and Claude Desktop never read it, so following it would repeat the bug.
|
|
18
|
+
*/
|
|
19
|
+
export function claudeDesktopConfigPath(host) {
|
|
20
|
+
if (host.platform === 'win32') {
|
|
21
|
+
const appData = host.env.APPDATA ?? win32.join(host.home, 'AppData', 'Roaming');
|
|
22
|
+
return win32.join(appData, 'Claude', CONFIG_FILE);
|
|
23
|
+
}
|
|
24
|
+
if (host.platform === 'darwin') {
|
|
25
|
+
const current = posix.join(host.home, 'Library', 'Application Support', 'Claude', CONFIG_FILE);
|
|
26
|
+
const legacy = posix.join(host.home, '.claude', CONFIG_FILE);
|
|
27
|
+
return !host.exists(current) && host.exists(legacy) ? legacy : current;
|
|
28
|
+
}
|
|
29
|
+
const configHome = host.env.XDG_CONFIG_HOME ?? posix.join(host.home, '.config');
|
|
30
|
+
return posix.join(configHome, 'Claude', CONFIG_FILE);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Claude Desktop creates its config directory on first launch, so a missing
|
|
34
|
+
* directory means there is no Claude Desktop here to configure.
|
|
35
|
+
*/
|
|
36
|
+
export function isClaudeDesktopInstalled(host, configPath) {
|
|
37
|
+
const pathLib = host.platform === 'win32' ? win32 : posix;
|
|
38
|
+
return host.exists(configPath) || host.exists(pathLib.dirname(configPath));
|
|
39
|
+
}
|
|
40
|
+
/** npx unpacks into `~/.npm/_npx/<hash>/`, which it is free to delete. */
|
|
41
|
+
export function isNpxCachePath(path) {
|
|
42
|
+
return /[\\/]_npx[\\/]/.test(path);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The `mcpServers.exponential` entry for Claude Desktop.
|
|
46
|
+
*
|
|
47
|
+
* A global install or a clone has a stable path, so the entry runs it directly
|
|
48
|
+
* with this Node binary. Run through `npx`, this file sits in npx's cache: a
|
|
49
|
+
* path that disappears when the cache is cleared and never sees a new release.
|
|
50
|
+
* Then the entry calls `npx` instead.
|
|
51
|
+
*
|
|
52
|
+
* Claude Desktop does not start servers with the shell's PATH. Under nvm (or
|
|
53
|
+
* any Node outside the system directories) a bare `npx` is not found, and an
|
|
54
|
+
* absolute `npx` still fails with "env: node: No such file or directory",
|
|
55
|
+
* because npx and the server both start through `#!/usr/bin/env node`. So the
|
|
56
|
+
* entry names `npx` by absolute path and puts Node's directory on PATH.
|
|
57
|
+
*/
|
|
58
|
+
export function serverEntry(host, runtime) {
|
|
59
|
+
if (!isNpxCachePath(runtime.serverPath)) {
|
|
60
|
+
return { command: runtime.execPath, args: [runtime.serverPath] };
|
|
61
|
+
}
|
|
62
|
+
// The Node installer for Windows puts npx on the system PATH.
|
|
63
|
+
if (host.platform === 'win32') {
|
|
64
|
+
return { command: 'npx', args: [...NPX_ARGS] };
|
|
65
|
+
}
|
|
66
|
+
const nodeDir = posix.dirname(runtime.execPath);
|
|
67
|
+
const npx = posix.join(nodeDir, 'npx');
|
|
68
|
+
if (!host.exists(npx)) {
|
|
69
|
+
return { command: 'npx', args: [...NPX_ARGS] };
|
|
70
|
+
}
|
|
71
|
+
const path = [nodeDir, ...POSIX_SYSTEM_PATH.filter((dir) => dir !== nodeDir)].join(':');
|
|
72
|
+
return { command: npx, args: [...NPX_ARGS], env: { PATH: path } };
|
|
73
|
+
}
|
|
74
|
+
function isAbsolutePath(path) {
|
|
75
|
+
return posix.isAbsolute(path) || win32.isAbsolute(path);
|
|
76
|
+
}
|
|
77
|
+
/** What is wrong with an existing `mcpServers.exponential` entry, if anything. */
|
|
78
|
+
export function diagnoseServerEntry(entry, exists) {
|
|
79
|
+
const issues = [];
|
|
80
|
+
const { command, args } = (entry ?? {});
|
|
81
|
+
if (typeof command !== 'string' || command === '') {
|
|
82
|
+
issues.push('MCP config is missing "command" for Exponential.');
|
|
83
|
+
}
|
|
84
|
+
else if (isAbsolutePath(command) && !exists(command)) {
|
|
85
|
+
issues.push(`MCP command not found: ${command}`);
|
|
86
|
+
}
|
|
87
|
+
const argList = Array.isArray(args) ? args.filter((arg) => typeof arg === 'string') : [];
|
|
88
|
+
const runsThroughNpx = argList.some((arg) => arg === 'exponential-mcp' || arg.startsWith('exponential-mcp@'));
|
|
89
|
+
if (runsThroughNpx) {
|
|
90
|
+
return issues;
|
|
91
|
+
}
|
|
92
|
+
const serverPath = argList[0];
|
|
93
|
+
if (!serverPath) {
|
|
94
|
+
issues.push('MCP config args missing server entry point.');
|
|
95
|
+
}
|
|
96
|
+
else if (!exists(serverPath)) {
|
|
97
|
+
issues.push(`MCP server entry not found: ${serverPath}`);
|
|
98
|
+
}
|
|
99
|
+
else if (isNpxCachePath(serverPath)) {
|
|
100
|
+
issues.push(`MCP server entry is inside npx's cache, which npx may delete and which never updates: ${serverPath}`);
|
|
101
|
+
}
|
|
102
|
+
return issues;
|
|
103
|
+
}
|