@kabmo-labs/kabmo 0.30.0 → 0.31.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 +79 -21
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +481 -462
- package/dist/client/static/js/{index-5vjbp04s.js → index-r3bhgvkt.js} +882 -883
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/format.test.ts +7 -1
- package/package.json +2 -2
- package/src/client/components/common/context-usage-button/McpSection.tsx +133 -0
- package/src/client/components/common/context-usage-button/Ring.tsx +12 -6
- package/src/client/components/common/context-usage-button/index.test.tsx +24 -13
- package/src/client/components/common/context-usage-button/index.tsx +32 -34
- package/src/client/components/common/session-row/TrailingSlot.tsx +6 -2
- package/src/client/components/common/session-row/session-row.test.tsx +13 -0
- package/src/client/components/layout/desktop-layout/index.tsx +5 -1
- package/src/client/components/mobile/RightSidebar.tsx +2 -1
- package/src/client/components/settings/categories/McpSettings.tsx +10 -3
- package/src/client/components/settings/categories/mcp-settings/AdvancedSection.tsx +244 -0
- package/src/client/components/settings/categories/mcp-settings/ConnectionTest.tsx +3 -3
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +55 -97
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +12 -64
- package/src/client/components/settings/categories/mcp-settings/{EnvVarsSection.tsx → KeyValueSection.tsx} +42 -24
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +1 -1
- package/src/client/components/settings/categories/mcp-settings/TransportSection.tsx +101 -0
- package/src/client/components/workspace/browser-panel/EngineNotice.test.tsx +109 -0
- package/src/client/components/workspace/browser-panel/EngineNotice.tsx +112 -0
- package/src/client/components/workspace/browser-panel/index.tsx +45 -12
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +63 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +18 -6
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/chat-input/access-levels.ts +39 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.test.tsx +13 -7
- package/src/client/components/workspace/editor/plugin-rail.test.tsx +6 -1
- package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +20 -5
- package/src/client/data/settings/mcp.ts +4 -2
- package/src/client/data/settings/omp-schema.json +22 -2
- package/src/client/hooks/browser/use-browser-engine.ts +99 -0
- package/src/client/hooks/chat/context/mcp.ts +159 -0
- package/src/client/hooks/chat/timeline/access-mode.ts +45 -15
- package/src/client/hooks/chat/timeline/index.ts +7 -3
- package/src/client/hooks/chat/timeline/timeline-mode-state.test.ts +33 -4
- package/src/client/hooks/ui/ui-listeners.test.ts +13 -18
- package/src/server/lib/browser/engine.test.ts +118 -0
- package/src/server/lib/browser/engine.ts +102 -0
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/fs/toolchain-path.test.ts +87 -0
- package/src/server/lib/fs/toolchain-path.ts +49 -0
- package/src/server/lib/harness/acp/protocol.ts +9 -1
- package/src/server/lib/harness/auto-probe.server.ts +3 -2
- package/src/server/lib/harness/launch-table.ts +3 -2
- package/src/server/lib/harness/spawn.server.ts +5 -1
- package/src/server/lib/harness/update-queue.server.ts +2 -1
- package/src/server/lib/harness/update-state.server.ts +6 -2
- package/src/server/lib/mcp/probe.server.ts +71 -0
- package/src/server/lib/mcp/registry.server.ts +195 -46
- package/src/server/lib/mcp/registry.test.ts +76 -4
- package/src/server/lib/mcp/schema.server.ts +35 -0
- package/src/server/lib/mcp/session-mcp.test.ts +164 -0
- package/src/server/lib/mcp/session-overlay.server.ts +152 -0
- package/src/server/lib/mcp/session-state.server.ts +75 -0
- package/src/server/lib/mcp/store.server.ts +6 -1
- package/src/server/lib/omp/config/config-cli.ts +4 -0
- package/src/server/lib/omp/config/mcp-and-cli.test.ts +12 -183
- package/src/server/lib/omp/config/mcp-config.test.ts +277 -0
- package/src/server/lib/omp/config/mcp-shared.ts +36 -0
- package/src/server/lib/omp/config/mcp-test-protocol.ts +89 -0
- package/src/server/lib/omp/config/mcp-test-remote.ts +167 -0
- package/src/server/lib/omp/config/mcp-test.ts +21 -123
- package/src/server/lib/omp/config/mcp-write.ts +179 -0
- package/src/server/lib/omp/config/mcp.ts +138 -118
- package/src/server/lib/omp/core/cli.ts +4 -14
- package/src/server/lib/omp/rpc/manager.ts +12 -17
- package/src/server/lib/omp/rpc/reload-mcp.ts +39 -0
- package/src/server/lib/omp/rpc/session-registry.ts +6 -2
- package/src/server/lib/omp/rpc/spawn-mcp.ts +43 -0
- package/src/server/lib/omp/session/delete.server.ts +7 -0
- package/src/server/lib/plugins/mcp.server.ts +2 -2
- package/src/server/lib/realtime/topics/workspace.server.test.ts +44 -0
- package/src/server/lib/realtime/topics/workspace.server.ts +3 -2
- package/src/server/routes/browser/engine.test.ts +70 -0
- package/src/server/routes/browser/engine.ts +51 -0
- package/src/server/routes/browser/index.ts +5 -0
- package/src/server/routes/fs/git.ts +4 -3
- package/src/server/routes/harness/versions.test.ts +5 -0
- package/src/server/routes/sessions/index.ts +7 -0
- package/src/server/routes/sessions/mcp.test.ts +154 -0
- package/src/server/routes/sessions/mcp.ts +202 -0
- package/src/server/routes/settings/mcp-test.ts +5 -4
- package/src/server/routes/settings/mcp.test.ts +42 -1
- package/src/server/routes/settings/mcp.ts +80 -24
- package/src/shared/lib/code/highlight-memo.test.ts +18 -0
- package/src/shared/lib/code/highlight-memo.ts +46 -17
- package/src/shared/lib/fonts/nerd-symbols.css +14 -0
- package/src/shared/lib/fonts/nerd-symbols.test.ts +86 -0
- package/src/shared/lib/fonts/symbols-nerd-font-mono.woff2 +0 -0
- package/src/shared/lib/mcp/import.ts +112 -0
- package/src/shared/lib/mcp/item.ts +61 -0
- package/src/shared/lib/mcp/key-value.ts +37 -0
- package/src/shared/lib/mcp/mcp-lib.test.ts +119 -0
- package/src/shared/lib/mcp/status.test.ts +36 -0
- package/src/shared/lib/mcp/status.ts +38 -0
- package/src/shared/lib/models/client.ts +27 -6
- package/src/shared/lib/models/provider/models.test.ts +31 -0
- package/src/shared/lib/omp/config/access-mode.test.ts +73 -0
- package/src/shared/lib/omp/config/access-mode.ts +49 -0
- package/src/shared/lib/workspace/right-panels.ts +13 -0
- package/src/shared/lib/workspace/workspace-modules.test.ts +3 -1
- package/src/shared/types/browser.ts +21 -0
- package/src/shared/types/settings/mcp.ts +73 -4
- package/src/test-support/pristine-globals.test.ts +53 -0
- package/src/test-support/pristine-globals.ts +6 -1
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The rest of omp's per-server schema: timeout, working directory, request-id
|
|
8
|
+
* encoding, instruction inclusion, and the two credential blocks.
|
|
9
|
+
*
|
|
10
|
+
* These are collapsed because most servers need none of them, but they are
|
|
11
|
+
* editable rather than hidden: a server that needs `cwd`, a string request id,
|
|
12
|
+
* or an OAuth client is otherwise impossible to configure from Kabmo, and the
|
|
13
|
+
* file would have to be hand-edited.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { ComponentChildren } from 'preact';
|
|
17
|
+
import { CHECKBOX_CLASS } from '@/client/components/common/checkbox/style';
|
|
18
|
+
import type { McpAuthConfig, McpOAuthConfig, McpServerItem } from '@/shared/types';
|
|
19
|
+
|
|
20
|
+
const INPUT_CLASS =
|
|
21
|
+
'w-full text-xs font-mono px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors';
|
|
22
|
+
|
|
23
|
+
function Field({ label, children }: { label: string; children: ComponentChildren }) {
|
|
24
|
+
return (
|
|
25
|
+
<label className="block space-y-1">
|
|
26
|
+
<span className="block text-[11px] font-medium text-ink/70">{label}</span>
|
|
27
|
+
{children}
|
|
28
|
+
</label>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface McpAdvancedSectionProps {
|
|
33
|
+
server: McpServerItem;
|
|
34
|
+
onChange: (patch: Partial<McpServerItem>) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function McpAdvancedSection({ server, onChange }: McpAdvancedSectionProps) {
|
|
38
|
+
const auth = server.auth;
|
|
39
|
+
const oauth = server.oauth;
|
|
40
|
+
const setAuth = (patch: Partial<McpAuthConfig>) => {
|
|
41
|
+
onChange({ auth: { ...(auth ?? { type: 'oauth' }), ...patch } });
|
|
42
|
+
};
|
|
43
|
+
const setOAuth = (patch: Partial<McpOAuthConfig>) => {
|
|
44
|
+
onChange({ oauth: { ...(oauth ?? {}), ...patch } });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<details className="rounded-lg border border-ink/15 bg-ink/[0.02]">
|
|
49
|
+
<summary className="cursor-pointer select-none px-3 py-2 text-xs font-semibold text-ink">
|
|
50
|
+
Advanced
|
|
51
|
+
<span className="ml-2 font-normal text-ink/50">timeout, working directory, credentials</span>
|
|
52
|
+
</summary>
|
|
53
|
+
|
|
54
|
+
<div className="px-3 pb-3 space-y-3">
|
|
55
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
|
56
|
+
<Field label="Timeout (ms)">
|
|
57
|
+
<input
|
|
58
|
+
type="number"
|
|
59
|
+
min={0}
|
|
60
|
+
value={server.timeout ?? ''}
|
|
61
|
+
onChange={(e) => {
|
|
62
|
+
const raw = e.currentTarget.value;
|
|
63
|
+
onChange({ timeout: raw === '' ? undefined : Number(raw) });
|
|
64
|
+
}}
|
|
65
|
+
placeholder="30000"
|
|
66
|
+
className={INPUT_CLASS}
|
|
67
|
+
/>
|
|
68
|
+
</Field>
|
|
69
|
+
|
|
70
|
+
<Field label="Request id format">
|
|
71
|
+
<select
|
|
72
|
+
value={server.requestIdFormat ?? ''}
|
|
73
|
+
onChange={(e) => {
|
|
74
|
+
const raw = e.currentTarget.value;
|
|
75
|
+
onChange({ requestIdFormat: raw === 'string' || raw === 'number' ? raw : undefined });
|
|
76
|
+
}}
|
|
77
|
+
className={`${INPUT_CLASS} cursor-pointer`}
|
|
78
|
+
>
|
|
79
|
+
<option value="">Default (number)</option>
|
|
80
|
+
<option value="number">number</option>
|
|
81
|
+
<option value="string">string</option>
|
|
82
|
+
</select>
|
|
83
|
+
</Field>
|
|
84
|
+
|
|
85
|
+
{server.transport === 'stdio' && (
|
|
86
|
+
<Field label="Working directory">
|
|
87
|
+
<input
|
|
88
|
+
type="text"
|
|
89
|
+
value={server.cwd ?? ''}
|
|
90
|
+
onChange={(e) => onChange({ cwd: e.currentTarget.value || undefined })}
|
|
91
|
+
placeholder="/path/to/project"
|
|
92
|
+
className={INPUT_CLASS}
|
|
93
|
+
/>
|
|
94
|
+
</Field>
|
|
95
|
+
)}
|
|
96
|
+
|
|
97
|
+
<label className="flex items-center gap-2 pt-5 text-xs text-ink cursor-pointer select-none">
|
|
98
|
+
<input
|
|
99
|
+
type="checkbox"
|
|
100
|
+
checked={server.instructions !== false}
|
|
101
|
+
onChange={(e) => onChange({ instructions: e.currentTarget.checked })}
|
|
102
|
+
className={`${CHECKBOX_CLASS} w-4 h-4 cursor-pointer`}
|
|
103
|
+
/>
|
|
104
|
+
Include the server’s instructions in the prompt
|
|
105
|
+
</label>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<div className="border-t border-ink/10 pt-3 space-y-3">
|
|
109
|
+
<Field label="Auth strategy">
|
|
110
|
+
<select
|
|
111
|
+
value={auth?.type ?? ''}
|
|
112
|
+
onChange={(e) => {
|
|
113
|
+
const raw = e.currentTarget.value;
|
|
114
|
+
if (raw !== 'oauth' && raw !== 'apikey') {
|
|
115
|
+
onChange({ auth: undefined });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
setAuth({ type: raw });
|
|
119
|
+
}}
|
|
120
|
+
className={`${INPUT_CLASS} cursor-pointer`}
|
|
121
|
+
>
|
|
122
|
+
<option value="">None</option>
|
|
123
|
+
<option value="oauth">OAuth</option>
|
|
124
|
+
<option value="apikey">API key</option>
|
|
125
|
+
</select>
|
|
126
|
+
</Field>
|
|
127
|
+
|
|
128
|
+
{auth && (
|
|
129
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
|
130
|
+
<Field label="Credential id">
|
|
131
|
+
<input
|
|
132
|
+
type="text"
|
|
133
|
+
value={auth.credentialId ?? ''}
|
|
134
|
+
onChange={(e) => setAuth({ credentialId: e.currentTarget.value })}
|
|
135
|
+
className={INPUT_CLASS}
|
|
136
|
+
/>
|
|
137
|
+
</Field>
|
|
138
|
+
<Field label="Token URL">
|
|
139
|
+
<input
|
|
140
|
+
type="text"
|
|
141
|
+
value={auth.tokenUrl ?? ''}
|
|
142
|
+
onChange={(e) => setAuth({ tokenUrl: e.currentTarget.value })}
|
|
143
|
+
className={INPUT_CLASS}
|
|
144
|
+
/>
|
|
145
|
+
</Field>
|
|
146
|
+
<Field label="Client id">
|
|
147
|
+
<input
|
|
148
|
+
type="text"
|
|
149
|
+
value={auth.clientId ?? ''}
|
|
150
|
+
onChange={(e) => setAuth({ clientId: e.currentTarget.value })}
|
|
151
|
+
className={INPUT_CLASS}
|
|
152
|
+
/>
|
|
153
|
+
</Field>
|
|
154
|
+
<Field label="Client secret">
|
|
155
|
+
<input
|
|
156
|
+
type="password"
|
|
157
|
+
value={auth.clientSecret ?? ''}
|
|
158
|
+
onChange={(e) => setAuth({ clientSecret: e.currentTarget.value })}
|
|
159
|
+
className={INPUT_CLASS}
|
|
160
|
+
/>
|
|
161
|
+
</Field>
|
|
162
|
+
<Field label="Resource">
|
|
163
|
+
<input
|
|
164
|
+
type="text"
|
|
165
|
+
value={auth.resource ?? ''}
|
|
166
|
+
onChange={(e) => setAuth({ resource: e.currentTarget.value })}
|
|
167
|
+
className={INPUT_CLASS}
|
|
168
|
+
/>
|
|
169
|
+
</Field>
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div className="border-t border-ink/10 pt-3 space-y-3">
|
|
175
|
+
<p className="text-[11px] font-medium text-ink/70">OAuth client (used by reauth)</p>
|
|
176
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-3">
|
|
177
|
+
<Field label="Client id">
|
|
178
|
+
<input
|
|
179
|
+
type="text"
|
|
180
|
+
value={oauth?.clientId ?? ''}
|
|
181
|
+
onChange={(e) => setOAuth({ clientId: e.currentTarget.value })}
|
|
182
|
+
className={INPUT_CLASS}
|
|
183
|
+
/>
|
|
184
|
+
</Field>
|
|
185
|
+
<Field label="Client secret">
|
|
186
|
+
<input
|
|
187
|
+
type="password"
|
|
188
|
+
value={oauth?.clientSecret ?? ''}
|
|
189
|
+
onChange={(e) => setOAuth({ clientSecret: e.currentTarget.value })}
|
|
190
|
+
className={INPUT_CLASS}
|
|
191
|
+
/>
|
|
192
|
+
</Field>
|
|
193
|
+
<Field label="Scope">
|
|
194
|
+
<input
|
|
195
|
+
type="text"
|
|
196
|
+
value={oauth?.scope ?? ''}
|
|
197
|
+
onChange={(e) => setOAuth({ scope: e.currentTarget.value })}
|
|
198
|
+
className={INPUT_CLASS}
|
|
199
|
+
/>
|
|
200
|
+
</Field>
|
|
201
|
+
<Field label="Redirect URI">
|
|
202
|
+
<input
|
|
203
|
+
type="text"
|
|
204
|
+
value={oauth?.redirectUri ?? ''}
|
|
205
|
+
onChange={(e) => setOAuth({ redirectUri: e.currentTarget.value })}
|
|
206
|
+
className={INPUT_CLASS}
|
|
207
|
+
/>
|
|
208
|
+
</Field>
|
|
209
|
+
<Field label="Callback port">
|
|
210
|
+
<input
|
|
211
|
+
type="number"
|
|
212
|
+
min={1}
|
|
213
|
+
max={65535}
|
|
214
|
+
value={oauth?.callbackPort ?? ''}
|
|
215
|
+
onChange={(e) => {
|
|
216
|
+
const raw = e.currentTarget.value;
|
|
217
|
+
setOAuth({ callbackPort: raw === '' ? undefined : Number(raw) });
|
|
218
|
+
}}
|
|
219
|
+
className={INPUT_CLASS}
|
|
220
|
+
/>
|
|
221
|
+
</Field>
|
|
222
|
+
<Field label="Callback path">
|
|
223
|
+
<input
|
|
224
|
+
type="text"
|
|
225
|
+
value={oauth?.callbackPath ?? ''}
|
|
226
|
+
onChange={(e) => setOAuth({ callbackPath: e.currentTarget.value })}
|
|
227
|
+
className={INPUT_CLASS}
|
|
228
|
+
/>
|
|
229
|
+
</Field>
|
|
230
|
+
<Field label="Prompt">
|
|
231
|
+
<input
|
|
232
|
+
type="text"
|
|
233
|
+
value={oauth?.prompt ?? ''}
|
|
234
|
+
onChange={(e) => setOAuth({ prompt: e.currentTarget.value })}
|
|
235
|
+
placeholder="consent"
|
|
236
|
+
className={INPUT_CLASS}
|
|
237
|
+
/>
|
|
238
|
+
</Field>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
</details>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useState } from 'preact/hooks';
|
|
2
2
|
import { Activity, AlertCircle, Check } from 'lucide-preact';
|
|
3
|
-
import type { McpServerItem } from '@/shared/types';
|
|
3
|
+
import type { McpServerItem, McpTransport } from '@/shared/types';
|
|
4
4
|
|
|
5
5
|
/** Shape of the response returned by POST /api/settings/mcp-test. */
|
|
6
6
|
interface McpTestResult {
|
|
7
7
|
ok: boolean;
|
|
8
|
-
transport:
|
|
8
|
+
transport: McpTransport;
|
|
9
9
|
protocolVersion?: string;
|
|
10
10
|
serverInfo?: { name?: string; version?: string };
|
|
11
11
|
toolCount?: number;
|
|
@@ -37,7 +37,7 @@ export function ConnectionTest({ server }: ConnectionTestProps) {
|
|
|
37
37
|
} catch (error) {
|
|
38
38
|
setResult({
|
|
39
39
|
ok: false,
|
|
40
|
-
transport: server.
|
|
40
|
+
transport: server.transport,
|
|
41
41
|
durationMs: 0,
|
|
42
42
|
error: error instanceof Error ? error.message : 'Request failed',
|
|
43
43
|
});
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { CHECKBOX_CLASS } from '@/client/components/common/checkbox/style';
|
|
2
2
|
import { useEffect, useState } from 'preact/hooks';
|
|
3
3
|
import type { FormEvent, FunctionComponent } from 'preact/compat';
|
|
4
|
-
import { AlertCircle, Check, Code,
|
|
5
|
-
import type {
|
|
4
|
+
import { AlertCircle, Check, Code, Loader2, Save, Trash2 } from 'lucide-preact';
|
|
5
|
+
import type { McpKeyValue, McpScope, McpServerItem, WriteOutcome } from '@/shared/types';
|
|
6
6
|
import { ConnectionTest } from '@/client/components/settings/categories/mcp-settings/ConnectionTest';
|
|
7
|
-
import {
|
|
7
|
+
import { McpKeyValueSection } from '@/client/components/settings/categories/mcp-settings/KeyValueSection';
|
|
8
|
+
import { McpTransportSection } from '@/client/components/settings/categories/mcp-settings/TransportSection';
|
|
9
|
+
import { McpAdvancedSection } from '@/client/components/settings/categories/mcp-settings/AdvancedSection';
|
|
8
10
|
import { useWriteFeedback } from '@/client/hooks/settings/write-feedback';
|
|
9
11
|
|
|
10
12
|
function parseCommandArgs(text: string): string[] {
|
|
11
13
|
return text.split('\n').map((s) => s.trim()).filter(Boolean);
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** Append a blank row; the id only has to be unique within this form. */
|
|
17
|
+
function withRow(rows: McpKeyValue[], prefix: string): McpKeyValue[] {
|
|
18
|
+
return [...rows, { id: `${prefix}-${Date.now()}-${rows.length}`, key: '', value: '' }];
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
interface McpDetailPaneProps {
|
|
15
22
|
server: McpServerItem;
|
|
16
23
|
isNew?: boolean;
|
|
@@ -44,10 +51,10 @@ export const McpDetailPane: FunctionComponent<McpDetailPaneProps> = ({
|
|
|
44
51
|
*/
|
|
45
52
|
const validationError = (() => {
|
|
46
53
|
if (!formData.name.trim()) return 'A server needs a name — omp keys its config by it.';
|
|
47
|
-
if (formData.
|
|
54
|
+
if (formData.transport === 'stdio' && parseCommandArgs(commandText).length === 0) {
|
|
48
55
|
return 'Paste the command that starts the server, one argument per line.';
|
|
49
56
|
}
|
|
50
|
-
if (formData.
|
|
57
|
+
if (formData.transport !== 'stdio' && !(formData.linkUrl ?? '').trim()) {
|
|
51
58
|
return 'Paste the server’s MCP endpoint URL.';
|
|
52
59
|
}
|
|
53
60
|
return null;
|
|
@@ -73,30 +80,15 @@ export const McpDetailPane: FunctionComponent<McpDetailPaneProps> = ({
|
|
|
73
80
|
});
|
|
74
81
|
};
|
|
75
82
|
|
|
76
|
-
const
|
|
77
|
-
const newEnv: McpEnvVar = {
|
|
78
|
-
id: `env-${Date.now()}`,
|
|
79
|
-
key: '',
|
|
80
|
-
value: '',
|
|
81
|
-
};
|
|
83
|
+
const updateRow = (field: 'envVars' | 'headers', id: string, key: string, value: string) => {
|
|
82
84
|
setFormData((prev) => ({
|
|
83
85
|
...prev,
|
|
84
|
-
|
|
86
|
+
[field]: prev[field].map((row) => (row.id === id ? { ...row, key, value } : row)),
|
|
85
87
|
}));
|
|
86
88
|
};
|
|
87
89
|
|
|
88
|
-
const
|
|
89
|
-
setFormData((prev) => ({
|
|
90
|
-
...prev,
|
|
91
|
-
envVars: prev.envVars.map((ev) => (ev.id === id ? { ...ev, key, value } : ev)),
|
|
92
|
-
}));
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const handleRemoveEnvVar = (id: string) => {
|
|
96
|
-
setFormData((prev) => ({
|
|
97
|
-
...prev,
|
|
98
|
-
envVars: prev.envVars.filter((ev) => ev.id !== id),
|
|
99
|
-
}));
|
|
90
|
+
const removeRow = (field: 'envVars' | 'headers', id: string) => {
|
|
91
|
+
setFormData((prev) => ({ ...prev, [field]: prev[field].filter((row) => row.id !== id) }));
|
|
100
92
|
};
|
|
101
93
|
|
|
102
94
|
const serverForTest: McpServerItem = {
|
|
@@ -173,82 +165,48 @@ export const McpDetailPane: FunctionComponent<McpDetailPaneProps> = ({
|
|
|
173
165
|
|
|
174
166
|
<div className="border-t border-ink/10" />
|
|
175
167
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
</p>
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
{/* Segmented Reach Type Buttons */}
|
|
188
|
-
<div className="inline-flex rounded-lg border border-ink/20 p-0.5 bg-ink/5">
|
|
189
|
-
<button
|
|
190
|
-
type="button"
|
|
191
|
-
onClick={() => setFormData({ ...formData, reachType: 'command' })}
|
|
192
|
-
className={`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors cursor-pointer ${
|
|
193
|
-
formData.reachType === 'command'
|
|
194
|
-
? 'bg-paper text-ink shadow-2xs font-semibold'
|
|
195
|
-
: 'text-ink/60 hover:text-ink'
|
|
196
|
-
}`}
|
|
197
|
-
>
|
|
198
|
-
<Terminal className="w-3.5 h-3.5" />
|
|
199
|
-
Command
|
|
200
|
-
</button>
|
|
201
|
-
<button
|
|
202
|
-
type="button"
|
|
203
|
-
onClick={() => setFormData({ ...formData, reachType: 'link' })}
|
|
204
|
-
className={`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors cursor-pointer ${
|
|
205
|
-
formData.reachType === 'link'
|
|
206
|
-
? 'bg-paper text-ink shadow-2xs font-semibold'
|
|
207
|
-
: 'text-ink/60 hover:text-ink'
|
|
208
|
-
}`}
|
|
209
|
-
>
|
|
210
|
-
<Globe className="w-3.5 h-3.5" />
|
|
211
|
-
Link
|
|
212
|
-
</button>
|
|
213
|
-
</div>
|
|
214
|
-
|
|
215
|
-
{formData.reachType === 'command' ? (
|
|
216
|
-
<div>
|
|
217
|
-
<textarea
|
|
218
|
-
value={commandText}
|
|
219
|
-
onChange={(e) => setCommandText(e.currentTarget.value)}
|
|
220
|
-
rows={4}
|
|
221
|
-
placeholder={`bunx\n@modelcontextprotocol/server-postgres\npostgresql://user:pass@host/db`}
|
|
222
|
-
className="w-full text-xs font-mono p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink resize-none leading-relaxed text-ink transition-colors"
|
|
223
|
-
/>
|
|
224
|
-
<p className="text-[11px] text-ink/50 mt-1">
|
|
225
|
-
Runs on this machine. Paste a whole command and it is split into one argument per line.
|
|
226
|
-
</p>
|
|
227
|
-
</div>
|
|
228
|
-
) : (
|
|
229
|
-
<div>
|
|
230
|
-
<input
|
|
231
|
-
type="url"
|
|
232
|
-
value={formData.linkUrl || ''}
|
|
233
|
-
onChange={(e) => setFormData({ ...formData, linkUrl: e.currentTarget.value })}
|
|
234
|
-
placeholder="https://needmcp.com/mcp"
|
|
235
|
-
className="w-full text-xs font-mono px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink text-ink transition-colors"
|
|
236
|
-
/>
|
|
237
|
-
<p className="text-[11px] text-ink/50 mt-1">
|
|
238
|
-
Connect to a hosted MCP SSE or HTTP endpoint.
|
|
239
|
-
</p>
|
|
240
|
-
</div>
|
|
241
|
-
)}
|
|
242
|
-
</div>
|
|
168
|
+
<McpTransportSection
|
|
169
|
+
transport={formData.transport}
|
|
170
|
+
onTransportChange={(transport) => setFormData({ ...formData, transport })}
|
|
171
|
+
commandText={commandText}
|
|
172
|
+
onCommandTextChange={setCommandText}
|
|
173
|
+
linkUrl={formData.linkUrl ?? ''}
|
|
174
|
+
onLinkUrlChange={(linkUrl) => setFormData({ ...formData, linkUrl })}
|
|
175
|
+
/>
|
|
243
176
|
|
|
244
177
|
<div className="border-t border-ink/10" />
|
|
245
178
|
|
|
246
|
-
{
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
179
|
+
{formData.transport === 'stdio' ? (
|
|
180
|
+
<McpKeyValueSection
|
|
181
|
+
title="Environment Variables"
|
|
182
|
+
description="Values the server needs, such as an API key."
|
|
183
|
+
addLabel="Add variable"
|
|
184
|
+
emptyLabel="No environment variables configured."
|
|
185
|
+
keyPlaceholder="KEY"
|
|
186
|
+
valuePlaceholder="VALUE"
|
|
187
|
+
rows={formData.envVars}
|
|
188
|
+
onAdd={() => setFormData((prev) => ({ ...prev, envVars: withRow(prev.envVars, 'env') }))}
|
|
189
|
+
onUpdate={(id, key, value) => updateRow('envVars', id, key, value)}
|
|
190
|
+
onRemove={(id) => removeRow('envVars', id)}
|
|
191
|
+
/>
|
|
192
|
+
) : (
|
|
193
|
+
<McpKeyValueSection
|
|
194
|
+
title="Request Headers"
|
|
195
|
+
description="Sent with every request — an Authorization header, for example."
|
|
196
|
+
addLabel="Add header"
|
|
197
|
+
emptyLabel="No request headers configured."
|
|
198
|
+
keyPlaceholder="Authorization"
|
|
199
|
+
valuePlaceholder="Bearer …"
|
|
200
|
+
rows={formData.headers}
|
|
201
|
+
onAdd={() => setFormData((prev) => ({ ...prev, headers: withRow(prev.headers, 'header') }))}
|
|
202
|
+
onUpdate={(id, key, value) => updateRow('headers', id, key, value)}
|
|
203
|
+
onRemove={(id) => removeRow('headers', id)}
|
|
204
|
+
/>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
<McpAdvancedSection
|
|
208
|
+
server={formData}
|
|
209
|
+
onChange={(patch) => setFormData((prev) => ({ ...prev, ...patch }))}
|
|
252
210
|
/>
|
|
253
211
|
|
|
254
212
|
{validationError && (
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useState } from 'preact/hooks';
|
|
2
2
|
import type { FunctionComponent } from 'preact/compat';
|
|
3
3
|
import { AlertCircle, Code, Loader2, X } from 'lucide-preact';
|
|
4
|
-
import type {
|
|
4
|
+
import type { McpServerItem, WriteOutcome } from '@/shared/types';
|
|
5
|
+
import { parseMcpImport } from '@/shared/lib/mcp/import';
|
|
5
6
|
|
|
6
7
|
interface McpImportModalProps {
|
|
7
8
|
isOpen: boolean;
|
|
8
9
|
onClose: () => void;
|
|
9
10
|
/** Resolves with the save's outcome; a refusal keeps this dialog open. */
|
|
10
|
-
onImport: (
|
|
11
|
+
onImport: (servers: McpServerItem[]) => Promise<WriteOutcome>;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const SAMPLE_JSON = `{
|
|
@@ -35,73 +36,19 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
35
36
|
|
|
36
37
|
const handleParseAndImport = async () => {
|
|
37
38
|
setError(null);
|
|
39
|
+
let servers: McpServerItem[];
|
|
38
40
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Handle {"mcpServers": { "name": { ... } }} format
|
|
42
|
-
if (parsed.mcpServers && typeof parsed.mcpServers === 'object') {
|
|
43
|
-
const serverKeys = Object.keys(parsed.mcpServers);
|
|
44
|
-
if (serverKeys.length === 0) {
|
|
45
|
-
throw new Error('No servers found inside "mcpServers" object.');
|
|
46
|
-
}
|
|
47
|
-
const firstKey = serverKeys[0];
|
|
48
|
-
const serverConfig = parsed.mcpServers[firstKey];
|
|
49
|
-
await importConfig(firstKey, serverConfig);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Handle direct config: { name, command, args, env } or { command, args }
|
|
54
|
-
const name = parsed.name || 'imported-mcp-server';
|
|
55
|
-
await importConfig(name, parsed);
|
|
41
|
+
servers = parseMcpImport(jsonText);
|
|
56
42
|
} catch (err: unknown) {
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
setError(err instanceof Error ? err.message : 'Invalid JSON format');
|
|
44
|
+
return;
|
|
59
45
|
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const importConfig = async (serverName: string, cfg: Record<string, unknown>) => {
|
|
63
|
-
const isUrl = typeof cfg.url === 'string' && cfg.url.length > 0;
|
|
64
|
-
const reachType = isUrl ? 'link' : 'command';
|
|
65
|
-
|
|
66
|
-
let commandArgs: string[] = [];
|
|
67
|
-
if (!isUrl) {
|
|
68
|
-
const cmd = typeof cfg.command === 'string' ? [cfg.command] : [];
|
|
69
|
-
const args = Array.isArray(cfg.args) ? cfg.args.map(String) : [];
|
|
70
|
-
commandArgs = [...cmd, ...args];
|
|
71
|
-
if (commandArgs.length === 0) {
|
|
72
|
-
commandArgs = ['bunx', '@modelcontextprotocol/server-everything'];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const envVars: McpEnvVar[] = [];
|
|
77
|
-
if (cfg.env && typeof cfg.env === 'object') {
|
|
78
|
-
Object.entries(cfg.env).forEach(([k, v], idx) => {
|
|
79
|
-
envVars.push({
|
|
80
|
-
id: `env-${Date.now()}-${idx}`,
|
|
81
|
-
key: k,
|
|
82
|
-
value: String(v),
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const resolvedUrl = typeof cfg.url === 'string' ? cfg.url : undefined;
|
|
88
|
-
const newServer: McpServerItem = {
|
|
89
|
-
id: `mcp-${Date.now()}`,
|
|
90
|
-
name: serverName,
|
|
91
|
-
scope: 'every-project',
|
|
92
|
-
enabled: true,
|
|
93
|
-
reachType,
|
|
94
|
-
commandArgs,
|
|
95
|
-
...(resolvedUrl ? { linkUrl: resolvedUrl } : {}),
|
|
96
|
-
envVars,
|
|
97
|
-
status: 'active',
|
|
98
|
-
};
|
|
99
46
|
|
|
100
47
|
// The dialog closes on the SAVE's answer, not on the click: a refused
|
|
101
48
|
// write has to be readable against the JSON that produced it.
|
|
102
49
|
setImporting(true);
|
|
103
50
|
try {
|
|
104
|
-
const outcome = await onImport(
|
|
51
|
+
const outcome = await onImport(servers);
|
|
105
52
|
if (outcome.ok) onClose();
|
|
106
53
|
else setError(outcome.error ?? 'The server refused the import.');
|
|
107
54
|
} finally {
|
|
@@ -116,7 +63,7 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
116
63
|
<div className="flex items-center gap-2">
|
|
117
64
|
<Code className="w-4 h-4 text-ink/70" />
|
|
118
65
|
<h2 className="text-xs font-bold uppercase tracking-wider text-ink">
|
|
119
|
-
Import MCP
|
|
66
|
+
Import MCP Servers from JSON
|
|
120
67
|
</h2>
|
|
121
68
|
</div>
|
|
122
69
|
<button
|
|
@@ -129,7 +76,8 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
129
76
|
</div>
|
|
130
77
|
|
|
131
78
|
<p className="text-xs text-ink/70 leading-relaxed">
|
|
132
|
-
Paste a configuration block from Claude
|
|
79
|
+
Paste a configuration block from omp, Claude, VS Code, Cursor, Gemini, or OpenCode.
|
|
80
|
+
Every server in the snippet is imported.
|
|
133
81
|
</p>
|
|
134
82
|
|
|
135
83
|
<textarea
|
|
@@ -165,7 +113,7 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
165
113
|
className="flex items-center gap-1.5 px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-50 disabled:cursor-progress"
|
|
166
114
|
>
|
|
167
115
|
{importing && <Loader2 className="w-3.5 h-3.5 animate-spin" />}
|
|
168
|
-
{importing ? 'Importing…' : 'Import
|
|
116
|
+
{importing ? 'Importing…' : 'Import Servers'}
|
|
169
117
|
</button>
|
|
170
118
|
</div>
|
|
171
119
|
</div>
|