@bevel-software/platform-core-frontend 0.12.1 → 0.13.1
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/package.json +2 -2
- package/src/modules/library/__tests__/McpServerSection.test.tsx +95 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +31 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +18 -0
- package/src/modules/library/components/tool-page/McpServerSection.tsx +338 -65
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +25 -9
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +8 -0
- package/src/modules/library/services/tools.api.ts +23 -1
- package/src/modules/secrets-vault/components/SecretsPage.tsx +321 -313
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +20 -11
- package/src/modules/secrets-vault/services/secrets.api.ts +2 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevel-software/platform-core-frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"tailwind-merge": "^3.5.0",
|
|
46
46
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
47
47
|
"yaml": "^2.9.0",
|
|
48
|
-
"@bevel-software/platform-shared": "0.
|
|
48
|
+
"@bevel-software/platform-shared": "0.13.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -135,4 +135,99 @@ describe('McpServerSection', () => {
|
|
|
135
135
|
await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
|
|
136
136
|
expect(apiMock.putMcpServer.mock.calls[0]![1]).toMatchObject({ newName: 'vendor_eu' });
|
|
137
137
|
});
|
|
138
|
+
|
|
139
|
+
it('shows everything the two files store: headers, variables, and a declared sign-in', async () => {
|
|
140
|
+
// What mcp.json + plugin.json say is what the reader sees — no opening
|
|
141
|
+
// either file to learn what is configured.
|
|
142
|
+
apiMock.getMcpServer.mockResolvedValue({
|
|
143
|
+
...VIEW,
|
|
144
|
+
canWrite: false,
|
|
145
|
+
description: 'Vendor CRM',
|
|
146
|
+
variables: [
|
|
147
|
+
{ name: 'VENDOR_KEY', scope: 'user' },
|
|
148
|
+
{
|
|
149
|
+
name: 'SIGNIN',
|
|
150
|
+
scope: 'user',
|
|
151
|
+
label: 'Vendor sign-in',
|
|
152
|
+
oauth: { clientId: 'app-1', scopes: ['crm.read'], pkce: false },
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
});
|
|
156
|
+
renderSection();
|
|
157
|
+
expect(await screen.findByText('X-V: 2')).toBeInTheDocument();
|
|
158
|
+
expect(screen.getByText('Authorization: Bearer ${VENDOR_KEY}')).toBeInTheDocument();
|
|
159
|
+
expect(screen.getByText('Vendor CRM')).toBeInTheDocument();
|
|
160
|
+
expect(screen.getByText('${SIGNIN}')).toBeInTheDocument();
|
|
161
|
+
expect(screen.getByText('app-1')).toBeInTheDocument();
|
|
162
|
+
expect(screen.getByText('Endpoints: discovered from the server')).toBeInTheDocument();
|
|
163
|
+
expect(screen.getByText('Scopes: crm.read')).toBeInTheDocument();
|
|
164
|
+
expect(screen.getByText('PKCE: off')).toBeInTheDocument();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('declares a sign-in on a user variable: client id only, endpoints discovered, header pre-filled', async () => {
|
|
168
|
+
apiMock.getMcpServer.mockResolvedValue({
|
|
169
|
+
...VIEW,
|
|
170
|
+
authHeaders: {},
|
|
171
|
+
variables: [{ name: 'HUBSPOT_TOKEN', scope: 'user' }],
|
|
172
|
+
});
|
|
173
|
+
renderSection();
|
|
174
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
|
|
175
|
+
fireEvent.click(screen.getByRole('checkbox', { name: 'Variable 1 OAuth sign-in' }));
|
|
176
|
+
// The header the token needs appears where the writer can see and change it.
|
|
177
|
+
expect(screen.getByRole('textbox', { name: /Auth headers/ })).toHaveValue(
|
|
178
|
+
'Authorization: Bearer ${HUBSPOT_TOKEN}',
|
|
179
|
+
);
|
|
180
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Variable 1 client id' }), {
|
|
181
|
+
target: { value: ' app-1 ' },
|
|
182
|
+
});
|
|
183
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Variable 1 scopes' }), {
|
|
184
|
+
target: { value: 'crm.read crm.write' },
|
|
185
|
+
});
|
|
186
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
187
|
+
await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
|
|
188
|
+
const write = apiMock.putMcpServer.mock.calls[0]![1];
|
|
189
|
+
expect(write).toMatchObject({
|
|
190
|
+
authHeaders: { Authorization: 'Bearer ${HUBSPOT_TOKEN}' },
|
|
191
|
+
variables: [
|
|
192
|
+
{ name: 'HUBSPOT_TOKEN', scope: 'user', oauth: { clientId: 'app-1', scopes: ['crm.read', 'crm.write'] } },
|
|
193
|
+
],
|
|
194
|
+
});
|
|
195
|
+
// Exactly what the file will store: no endpoints (discovered), no
|
|
196
|
+
// `pkce` (on is the default — only an opt-out is written).
|
|
197
|
+
expect(write.variables[0].oauth).not.toHaveProperty('authorizationUrl');
|
|
198
|
+
expect(write.variables[0].oauth).not.toHaveProperty('pkce');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('sends hand-entered endpoints and the PKCE opt-out exactly as the file will store them', async () => {
|
|
202
|
+
apiMock.getMcpServer.mockResolvedValue({
|
|
203
|
+
...VIEW,
|
|
204
|
+
variables: [{ name: 'SIGNIN', scope: 'user', oauth: { clientId: 'app-1' } }],
|
|
205
|
+
});
|
|
206
|
+
renderSection();
|
|
207
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
|
|
208
|
+
// An Authorization header already exists — nothing is pre-filled over it.
|
|
209
|
+
expect(screen.getByRole('textbox', { name: /Auth headers/ })).toHaveValue('Authorization: Bearer ${VENDOR_KEY}');
|
|
210
|
+
fireEvent.click(screen.getByRole('radio', { name: 'Variable 1 endpoints by hand' }));
|
|
211
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Variable 1 authorization URL' }), {
|
|
212
|
+
target: { value: 'https://p.example/auth' },
|
|
213
|
+
});
|
|
214
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Variable 1 token URL' }), {
|
|
215
|
+
target: { value: 'https://p.example/token' },
|
|
216
|
+
});
|
|
217
|
+
fireEvent.click(screen.getByRole('checkbox', { name: 'Variable 1 PKCE' }));
|
|
218
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
219
|
+
await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
|
|
220
|
+
expect(apiMock.putMcpServer.mock.calls[0]![1].variables).toEqual([
|
|
221
|
+
{
|
|
222
|
+
name: 'SIGNIN',
|
|
223
|
+
scope: 'user',
|
|
224
|
+
oauth: {
|
|
225
|
+
authorizationUrl: 'https://p.example/auth',
|
|
226
|
+
tokenUrl: 'https://p.example/token',
|
|
227
|
+
clientId: 'app-1',
|
|
228
|
+
pkce: false,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
]);
|
|
232
|
+
});
|
|
138
233
|
});
|
|
@@ -122,6 +122,37 @@ describe('ToolConnectionSection', () => {
|
|
|
122
122
|
expect(screen.queryByRole('button', { name: 'Edit the tool file' })).toBeNull();
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
+
it('sends the owner of an mcp.json server to "Edit server" on this page, not to a file', () => {
|
|
126
|
+
renderSection(tool({ path: 'Plugins/GTM/mcp.json', setup: OAUTH_MANUAL, canWrite: true }));
|
|
127
|
+
expect(screen.getByRole('status')).toHaveTextContent(/under "Edit server" below/);
|
|
128
|
+
expect(screen.queryByRole('button', { name: 'Edit the tool file' })).toBeNull();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('once the sign-in is declared, asks the owner only for the client secret', () => {
|
|
132
|
+
renderSection(
|
|
133
|
+
tool({
|
|
134
|
+
setup: { kind: 'oauth-manual' },
|
|
135
|
+
canWrite: true,
|
|
136
|
+
variables: [
|
|
137
|
+
{
|
|
138
|
+
name: 'SIGNIN',
|
|
139
|
+
scope: 'user',
|
|
140
|
+
label: null,
|
|
141
|
+
key: 'github_SIGNIN',
|
|
142
|
+
adminConfigured: false,
|
|
143
|
+
userConfigured: false,
|
|
144
|
+
oauth: true,
|
|
145
|
+
authorized: false,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
expect(screen.getByRole('status')).toHaveTextContent(
|
|
151
|
+
'the sign-in is declared — set its client secret below to finish',
|
|
152
|
+
);
|
|
153
|
+
expect(screen.queryByRole('button', { name: 'Edit the tool file' })).toBeNull();
|
|
154
|
+
});
|
|
155
|
+
|
|
125
156
|
it('omits the edit link while the workspace has no kb directory yet', () => {
|
|
126
157
|
renderSection(tool({ setup: OAUTH_MANUAL, canWrite: true }), null);
|
|
127
158
|
expect(screen.getByRole('status')).toBeInTheDocument();
|
|
@@ -166,6 +166,24 @@ describe('ToolVarRow: oauth', () => {
|
|
|
166
166
|
expect(screen.getByText('Connected')).toBeInTheDocument();
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
+
it('offers Reconnect beside Connected, for everyone, and it re-enters the same sign-in flow', async () => {
|
|
170
|
+
// A provider can widen what it grants after the fact (HubSpot answers
|
|
171
|
+
// REQUIRES_REAUTHORIZATION until the user consents again) or revoke a
|
|
172
|
+
// grant — the caller needs a way back into consent that doesn't wait for
|
|
173
|
+
// the scope check to notice. Left of the chip, so the chip stays the
|
|
174
|
+
// row's terminal state at a glance.
|
|
175
|
+
renderRow(signin({ authorized: true }));
|
|
176
|
+
const reconnect = screen.getByRole('button', { name: 'Reconnect' });
|
|
177
|
+
expect(reconnect.compareDocumentPosition(screen.getByText('Connected')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
178
|
+
fireEvent.click(reconnect);
|
|
179
|
+
await waitFor(() =>
|
|
180
|
+
expect(connectMock.startToolOAuth).toHaveBeenCalledWith('github', 'SIGNIN', { returnTo: RETURN_TO }),
|
|
181
|
+
);
|
|
182
|
+
await waitFor(() =>
|
|
183
|
+
expect(navMock.navigateExternal).toHaveBeenCalledWith('https://provider.example/authorize'),
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
169
187
|
it('asks for a fresh sign-in when the token is under-scoped', () => {
|
|
170
188
|
renderRow(signin({ authorized: true, needsReauth: true }));
|
|
171
189
|
expect(screen.getByRole('button', { name: 'Sign in again' })).toBeInTheDocument();
|
|
@@ -4,6 +4,7 @@ import { Badge, Banner, Button, Dialog } from '../../../../shared/components';
|
|
|
4
4
|
import {
|
|
5
5
|
getMcpServer,
|
|
6
6
|
putMcpServer,
|
|
7
|
+
type McpServerVariable,
|
|
7
8
|
type McpServerView,
|
|
8
9
|
type McpTransport,
|
|
9
10
|
} from '../../services/tools.api';
|
|
@@ -15,6 +16,13 @@ import { pathForTool } from '../../routes/library-paths';
|
|
|
15
16
|
* manuals (the GET 404s: those edit as files) and renders read-only facts for
|
|
16
17
|
* non-writers, whose editing surface this page has never been.
|
|
17
18
|
*
|
|
19
|
+
* WHAT THE FILES SAY IS WHAT THE PAGE SHOWS. One server's truth spans two
|
|
20
|
+
* files (mcp.json for the portable half, plugin.json's extensions block for
|
|
21
|
+
* ours), and the reader should not have to open either to know what is
|
|
22
|
+
* configured: the read-only view lists every stored fact — headers, declared
|
|
23
|
+
* variables, a sign-in's client id and endpoints — and the editor edits
|
|
24
|
+
* exactly those, so a save changes nothing the view didn't show.
|
|
25
|
+
*
|
|
18
26
|
* RENAME CONFIRMS, WITH THE COST NAMED. The server's name is the namespace
|
|
19
27
|
* its vault secrets bind to (`<name>_<VAR>`), so renaming disconnects every
|
|
20
28
|
* configured value and completed sign-in under the old name. The page already
|
|
@@ -49,7 +57,7 @@ export function McpServerSection({
|
|
|
49
57
|
const [literalHeaders, setLiteralHeaders] = useState('');
|
|
50
58
|
const [authHeaders, setAuthHeaders] = useState('');
|
|
51
59
|
const [local, setLocal] = useState(false);
|
|
52
|
-
const [variables, setVariables] = useState<
|
|
60
|
+
const [variables, setVariables] = useState<McpServerVariable[]>([]);
|
|
53
61
|
|
|
54
62
|
useEffect(() => {
|
|
55
63
|
let live = true;
|
|
@@ -83,6 +91,20 @@ export function McpServerSection({
|
|
|
83
91
|
setEditing(true);
|
|
84
92
|
};
|
|
85
93
|
|
|
94
|
+
/**
|
|
95
|
+
* A sign-in's token has to reach the server somehow — turning one on
|
|
96
|
+
* pre-fills the `Authorization` header the variable loader will fill,
|
|
97
|
+
* VISIBLY, in the auth-headers field the writer is already looking at.
|
|
98
|
+
* Never over an Authorization header that's already there.
|
|
99
|
+
*/
|
|
100
|
+
const suggestAuthHeader = (varName: string) => {
|
|
101
|
+
if (!varName) return;
|
|
102
|
+
const has = Object.keys(linesToHeaders(authHeaders)).some((h) => h.toLowerCase() === 'authorization');
|
|
103
|
+
if (has) return;
|
|
104
|
+
const line = `Authorization: Bearer \${${varName}}`;
|
|
105
|
+
setAuthHeaders((prev) => (prev.trim() ? `${prev.replace(/\n+$/, '')}\n${line}` : line));
|
|
106
|
+
};
|
|
107
|
+
|
|
86
108
|
const save = async () => {
|
|
87
109
|
const renaming = name.trim() !== server.name;
|
|
88
110
|
// EVERY rename confirms: this caller's page only knows their own and the
|
|
@@ -111,9 +133,7 @@ export function McpServerSection({
|
|
|
111
133
|
: { url: url.trim() }),
|
|
112
134
|
literalHeaders: linesToHeaders(literalHeaders),
|
|
113
135
|
authHeaders: linesToHeaders(authHeaders),
|
|
114
|
-
variables: variables
|
|
115
|
-
.map((v) => ({ ...v, name: v.name.trim(), label: v.label?.trim() || undefined }))
|
|
116
|
-
.filter((v) => v.name.length > 0),
|
|
136
|
+
variables: variables.map(normalizeVariable).filter((v) => v.name.length > 0),
|
|
117
137
|
...(server.description ? { description: server.description } : {}),
|
|
118
138
|
local,
|
|
119
139
|
});
|
|
@@ -144,31 +164,7 @@ export function McpServerSection({
|
|
|
144
164
|
|
|
145
165
|
{!editing && (
|
|
146
166
|
<div className="flex items-start justify-between gap-4 rounded-md border border-line px-3.5 py-2.5">
|
|
147
|
-
<
|
|
148
|
-
<div className="flex gap-2">
|
|
149
|
-
<dt className="shrink-0 font-semibold">Transport</dt>
|
|
150
|
-
<dd>{server.transport}</dd>
|
|
151
|
-
</div>
|
|
152
|
-
{server.url && (
|
|
153
|
-
<div className="flex gap-2">
|
|
154
|
-
<dt className="shrink-0 font-semibold">URL</dt>
|
|
155
|
-
<dd className="truncate">{server.url}</dd>
|
|
156
|
-
</div>
|
|
157
|
-
)}
|
|
158
|
-
{server.command && (
|
|
159
|
-
<div className="flex gap-2">
|
|
160
|
-
<dt className="shrink-0 font-semibold">Command</dt>
|
|
161
|
-
<dd className="truncate">
|
|
162
|
-
{server.command} {(server.args ?? []).join(' ')}
|
|
163
|
-
</dd>
|
|
164
|
-
</div>
|
|
165
|
-
)}
|
|
166
|
-
{server.local && (
|
|
167
|
-
<div className="mt-1 text-ink-faint">
|
|
168
|
-
Runs locally — served by the local knowledge server on each member's machine, never by the workspace.
|
|
169
|
-
</div>
|
|
170
|
-
)}
|
|
171
|
-
</dl>
|
|
167
|
+
<ServerFacts server={server} />
|
|
172
168
|
{server.canWrite && (
|
|
173
169
|
<Button variant="outline" size="sm" onClick={openEditor}>
|
|
174
170
|
Edit server
|
|
@@ -207,7 +203,7 @@ export function McpServerSection({
|
|
|
207
203
|
hint="One `Header: value` per line. Visible package data — no secrets here." />
|
|
208
204
|
<LabeledTextarea label="Auth headers" value={authHeaders} onChange={setAuthHeaders}
|
|
209
205
|
hint="One per line; values may use ${VAR} vault references, e.g. `Authorization: Bearer ${API_KEY}`." />
|
|
210
|
-
<VariablesEditor variables={variables} onChange={setVariables} />
|
|
206
|
+
<VariablesEditor variables={variables} onChange={setVariables} onSignInEnabled={suggestAuthHeader} />
|
|
211
207
|
{transport !== 'stdio' && (
|
|
212
208
|
<label className="flex items-center gap-2 text-detail text-ink-muted">
|
|
213
209
|
<input type="checkbox" checked={local} onChange={(e) => setLocal(e.target.checked)} />
|
|
@@ -248,6 +244,109 @@ export function McpServerSection({
|
|
|
248
244
|
);
|
|
249
245
|
}
|
|
250
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Everything the two files store about this server, read-only. Facts are
|
|
249
|
+
* grouped the way the files split them — portable (mcp.json) first, then
|
|
250
|
+
* ours (plugin.json) — so a reader can tell where an edit by hand would land.
|
|
251
|
+
* Nothing is elided: a header, a declared variable, a sign-in's endpoints all
|
|
252
|
+
* appear here exactly as saved, or the editor would be changing invisible state.
|
|
253
|
+
*/
|
|
254
|
+
function ServerFacts({ server }: { server: McpServerView }) {
|
|
255
|
+
const literal = Object.entries(server.literalHeaders);
|
|
256
|
+
const auth = Object.entries(server.authHeaders);
|
|
257
|
+
return (
|
|
258
|
+
<dl className="min-w-0 flex-1 text-detail text-ink-muted" aria-label="Server configuration">
|
|
259
|
+
<Fact label="Transport">{server.transport}</Fact>
|
|
260
|
+
{server.url && <Fact label="URL" mono>{server.url}</Fact>}
|
|
261
|
+
{server.command && (
|
|
262
|
+
<Fact label="Command" mono>
|
|
263
|
+
{server.command} {(server.args ?? []).join(' ')}
|
|
264
|
+
</Fact>
|
|
265
|
+
)}
|
|
266
|
+
{server.description && <Fact label="Description">{server.description}</Fact>}
|
|
267
|
+
{literal.length > 0 && (
|
|
268
|
+
<Fact label="Headers">
|
|
269
|
+
<HeaderList entries={literal} />
|
|
270
|
+
</Fact>
|
|
271
|
+
)}
|
|
272
|
+
{auth.length > 0 && (
|
|
273
|
+
<Fact label="Auth headers">
|
|
274
|
+
<HeaderList entries={auth} />
|
|
275
|
+
</Fact>
|
|
276
|
+
)}
|
|
277
|
+
{server.variables.length > 0 && (
|
|
278
|
+
<Fact label="Variables">
|
|
279
|
+
<ul className="flex flex-col gap-1">
|
|
280
|
+
{server.variables.map((v) => (
|
|
281
|
+
<li key={v.name}>
|
|
282
|
+
<code className="rounded-sm bg-sunken px-1 py-0.5 font-mono text-meta text-ink">{`\${${v.name}}`}</code>{' '}
|
|
283
|
+
<span>{v.scope === 'user' ? 'each member their own' : 'one shared value'}</span>
|
|
284
|
+
{v.label && <span className="text-ink-faint"> — {v.label}</span>}
|
|
285
|
+
{v.oauth && <SignInFacts oauth={v.oauth} />}
|
|
286
|
+
</li>
|
|
287
|
+
))}
|
|
288
|
+
</ul>
|
|
289
|
+
</Fact>
|
|
290
|
+
)}
|
|
291
|
+
{server.local && (
|
|
292
|
+
<div className="mt-1 text-ink-faint">
|
|
293
|
+
Runs locally — served by the local knowledge server on each member's machine, never by the workspace.
|
|
294
|
+
</div>
|
|
295
|
+
)}
|
|
296
|
+
</dl>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** A declared sign-in, as stored: client id, where the endpoints come from, scopes, PKCE. */
|
|
301
|
+
function SignInFacts({ oauth }: { oauth: NonNullable<McpServerVariable['oauth']> }) {
|
|
302
|
+
const discovered = !oauth.authorizationUrl || !oauth.tokenUrl;
|
|
303
|
+
return (
|
|
304
|
+
<ul className="ml-4 mt-0.5 flex list-disc flex-col gap-0.5 text-ink-faint">
|
|
305
|
+
<li>
|
|
306
|
+
OAuth sign-in · client id <code className="font-mono text-ink-muted">{oauth.clientId}</code>
|
|
307
|
+
</li>
|
|
308
|
+
<li>
|
|
309
|
+
{discovered ? (
|
|
310
|
+
<>Endpoints: discovered from the server</>
|
|
311
|
+
) : (
|
|
312
|
+
<>
|
|
313
|
+
Authorize <code className="font-mono">{oauth.authorizationUrl}</code> · Token{' '}
|
|
314
|
+
<code className="font-mono">{oauth.tokenUrl}</code>
|
|
315
|
+
</>
|
|
316
|
+
)}
|
|
317
|
+
</li>
|
|
318
|
+
{oauth.scopes && oauth.scopes.length > 0 && <li>Scopes: {oauth.scopes.join(' ')}</li>}
|
|
319
|
+
<li>PKCE: {oauth.pkce === false ? 'off' : 'on'}</li>
|
|
320
|
+
{oauth.resource && (
|
|
321
|
+
<li>
|
|
322
|
+
Resource <code className="font-mono">{oauth.resource}</code>
|
|
323
|
+
</li>
|
|
324
|
+
)}
|
|
325
|
+
</ul>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function Fact({ label, mono, children }: { label: string; mono?: boolean; children: React.ReactNode }) {
|
|
330
|
+
return (
|
|
331
|
+
<div className="flex gap-2">
|
|
332
|
+
<dt className="shrink-0 font-semibold">{label}</dt>
|
|
333
|
+
<dd className={`min-w-0 ${mono ? 'truncate font-mono' : ''}`}>{children}</dd>
|
|
334
|
+
</div>
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function HeaderList({ entries }: { entries: [string, string][] }) {
|
|
339
|
+
return (
|
|
340
|
+
<ul className="flex flex-col">
|
|
341
|
+
{entries.map(([k, v]) => (
|
|
342
|
+
<li key={k} className="truncate font-mono">
|
|
343
|
+
{k}: {v}
|
|
344
|
+
</li>
|
|
345
|
+
))}
|
|
346
|
+
</ul>
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
251
350
|
function LabeledInput({
|
|
252
351
|
label,
|
|
253
352
|
value,
|
|
@@ -303,51 +402,198 @@ function LabeledTextarea({
|
|
|
303
402
|
* by a tool writer) or `user` (each member their own, on the Connect page).
|
|
304
403
|
* The names must match the `${VAR}` references in the auth headers — the vault
|
|
305
404
|
* key is `<server>_<VAR>`, derived from exactly these names.
|
|
405
|
+
*
|
|
406
|
+
* A user-scoped variable can be an OAuth SIGN-IN instead of a typed value:
|
|
407
|
+
* the owner's OAuth app's client id, endpoints discovered from the server
|
|
408
|
+
* (or entered by hand for a provider that publishes none), scopes, PKCE. The
|
|
409
|
+
* fields mirror the `oauth` block plugin.json stores, one to one — what an
|
|
410
|
+
* agent would write into the file is what this form writes.
|
|
306
411
|
*/
|
|
307
412
|
function VariablesEditor({
|
|
308
413
|
variables,
|
|
309
414
|
onChange,
|
|
415
|
+
onSignInEnabled,
|
|
310
416
|
}: {
|
|
311
|
-
variables:
|
|
312
|
-
onChange(next:
|
|
417
|
+
variables: McpServerVariable[];
|
|
418
|
+
onChange(next: McpServerVariable[]): void;
|
|
419
|
+
/** A sign-in was just switched on for this variable name — the parent may wire its header. */
|
|
420
|
+
onSignInEnabled(varName: string): void;
|
|
313
421
|
}) {
|
|
314
|
-
const update = (i: number, patch: Partial<
|
|
422
|
+
const update = (i: number, patch: Partial<McpServerVariable>) =>
|
|
315
423
|
onChange(variables.map((v, j) => (j === i ? { ...v, ...patch } : v)));
|
|
424
|
+
const updateOAuth = (i: number, patch: Partial<NonNullable<McpServerVariable['oauth']>>) =>
|
|
425
|
+
onChange(
|
|
426
|
+
variables.map((v, j) =>
|
|
427
|
+
j === i && v.oauth ? { ...v, oauth: { ...v.oauth, ...patch } } : v,
|
|
428
|
+
),
|
|
429
|
+
);
|
|
316
430
|
return (
|
|
317
431
|
<div className="flex flex-col gap-1 text-detail">
|
|
318
432
|
<span className="font-semibold text-ink">Variables</span>
|
|
319
|
-
{variables.map((v, i) =>
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
433
|
+
{variables.map((v, i) => {
|
|
434
|
+
const n = i + 1;
|
|
435
|
+
const oauth = v.oauth;
|
|
436
|
+
const manualEndpoints = oauth !== undefined && oauth.authorizationUrl !== undefined;
|
|
437
|
+
return (
|
|
438
|
+
// Index keys are correct here: rows are edited in place and have no
|
|
439
|
+
// identity beyond their position until saved.
|
|
440
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
441
|
+
<div key={i} className="flex flex-col gap-1.5 rounded-md border border-line px-2.5 py-2">
|
|
442
|
+
<div className="flex items-center gap-2">
|
|
443
|
+
<input
|
|
444
|
+
aria-label={`Variable ${n} name`}
|
|
445
|
+
className="w-40 rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
446
|
+
value={v.name}
|
|
447
|
+
onChange={(e) => update(i, { name: e.target.value })}
|
|
448
|
+
/>
|
|
449
|
+
<select
|
|
450
|
+
aria-label={`Variable ${n} scope`}
|
|
451
|
+
className="rounded-md border border-line bg-white px-2 py-1 text-ui"
|
|
452
|
+
value={v.scope}
|
|
453
|
+
onChange={(e) => {
|
|
454
|
+
const scope = e.target.value as 'admin' | 'user';
|
|
455
|
+
// A sign-in is per-caller by nature; a shared token would
|
|
456
|
+
// hand one member's grant to everyone. Dropping it here is
|
|
457
|
+
// the same rule the save enforces, made visible early.
|
|
458
|
+
const next: McpServerVariable = { ...v, scope };
|
|
459
|
+
if (scope !== 'user') delete next.oauth;
|
|
460
|
+
onChange(variables.map((x, j) => (j === i ? next : x)));
|
|
461
|
+
}}
|
|
462
|
+
>
|
|
463
|
+
<option value="admin">admin — one shared value</option>
|
|
464
|
+
<option value="user">user — each member their own</option>
|
|
465
|
+
</select>
|
|
466
|
+
<input
|
|
467
|
+
aria-label={`Variable ${n} label`}
|
|
468
|
+
className="min-w-0 flex-1 rounded-md border border-line bg-white px-2 py-1 text-ui"
|
|
469
|
+
placeholder="Label shown in the secrets UI"
|
|
470
|
+
value={v.label ?? ''}
|
|
471
|
+
onChange={(e) => update(i, { label: e.target.value || undefined })}
|
|
472
|
+
/>
|
|
473
|
+
<Button variant="quiet" size="sm" onClick={() => onChange(variables.filter((_, j) => j !== i))}>
|
|
474
|
+
Remove
|
|
475
|
+
</Button>
|
|
476
|
+
</div>
|
|
477
|
+
{v.scope === 'user' && (
|
|
478
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
479
|
+
<input
|
|
480
|
+
type="checkbox"
|
|
481
|
+
aria-label={`Variable ${n} OAuth sign-in`}
|
|
482
|
+
checked={oauth !== undefined}
|
|
483
|
+
onChange={(e) => {
|
|
484
|
+
if (e.target.checked) {
|
|
485
|
+
update(i, { oauth: { clientId: '' } });
|
|
486
|
+
onSignInEnabled(v.name.trim());
|
|
487
|
+
} else {
|
|
488
|
+
const next = { ...v };
|
|
489
|
+
delete next.oauth;
|
|
490
|
+
onChange(variables.map((x, j) => (j === i ? next : x)));
|
|
491
|
+
}
|
|
492
|
+
}}
|
|
493
|
+
/>
|
|
494
|
+
OAuth sign-in — members sign in with the provider instead of pasting a value
|
|
495
|
+
</label>
|
|
496
|
+
)}
|
|
497
|
+
{oauth && (
|
|
498
|
+
<div className="ml-5 flex flex-col gap-1.5 border-l-2 border-line pl-3">
|
|
499
|
+
<label className="flex flex-col gap-1">
|
|
500
|
+
<span className="font-semibold text-ink">Client ID</span>
|
|
501
|
+
<input
|
|
502
|
+
aria-label={`Variable ${n} client id`}
|
|
503
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
504
|
+
value={oauth.clientId}
|
|
505
|
+
onChange={(e) => updateOAuth(i, { clientId: e.target.value })}
|
|
506
|
+
/>
|
|
507
|
+
<span className="text-ink-faint">
|
|
508
|
+
From the OAuth app you registered with the provider. Its client secret is
|
|
509
|
+
pasted on this page after saving — never in a file.
|
|
510
|
+
</span>
|
|
511
|
+
</label>
|
|
512
|
+
<div className="flex flex-col gap-1">
|
|
513
|
+
<span className="font-semibold text-ink">Endpoints</span>
|
|
514
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
515
|
+
<input
|
|
516
|
+
type="radio"
|
|
517
|
+
name={`variable-${n}-endpoints`}
|
|
518
|
+
aria-label={`Variable ${n} endpoints discovered`}
|
|
519
|
+
checked={!manualEndpoints}
|
|
520
|
+
onChange={() => {
|
|
521
|
+
const next = { ...oauth };
|
|
522
|
+
delete next.authorizationUrl;
|
|
523
|
+
delete next.tokenUrl;
|
|
524
|
+
update(i, { oauth: next });
|
|
525
|
+
}}
|
|
526
|
+
/>
|
|
527
|
+
Discover from the server (MCP servers publish them)
|
|
528
|
+
</label>
|
|
529
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
530
|
+
<input
|
|
531
|
+
type="radio"
|
|
532
|
+
name={`variable-${n}-endpoints`}
|
|
533
|
+
aria-label={`Variable ${n} endpoints by hand`}
|
|
534
|
+
checked={manualEndpoints}
|
|
535
|
+
onChange={() =>
|
|
536
|
+
updateOAuth(i, {
|
|
537
|
+
authorizationUrl: oauth.authorizationUrl ?? '',
|
|
538
|
+
tokenUrl: oauth.tokenUrl ?? '',
|
|
539
|
+
})
|
|
540
|
+
}
|
|
541
|
+
/>
|
|
542
|
+
Enter by hand (the provider publishes no OAuth metadata)
|
|
543
|
+
</label>
|
|
544
|
+
{manualEndpoints && (
|
|
545
|
+
<div className="ml-5 flex flex-col gap-1.5">
|
|
546
|
+
<input
|
|
547
|
+
aria-label={`Variable ${n} authorization URL`}
|
|
548
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
549
|
+
placeholder="https://provider.example/oauth/authorize"
|
|
550
|
+
value={oauth.authorizationUrl ?? ''}
|
|
551
|
+
onChange={(e) => updateOAuth(i, { authorizationUrl: e.target.value })}
|
|
552
|
+
/>
|
|
553
|
+
<input
|
|
554
|
+
aria-label={`Variable ${n} token URL`}
|
|
555
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
556
|
+
placeholder="https://provider.example/oauth/token"
|
|
557
|
+
value={oauth.tokenUrl ?? ''}
|
|
558
|
+
onChange={(e) => updateOAuth(i, { tokenUrl: e.target.value })}
|
|
559
|
+
/>
|
|
560
|
+
</div>
|
|
561
|
+
)}
|
|
562
|
+
</div>
|
|
563
|
+
<label className="flex flex-col gap-1">
|
|
564
|
+
<span className="font-semibold text-ink">Scopes</span>
|
|
565
|
+
<input
|
|
566
|
+
aria-label={`Variable ${n} scopes`}
|
|
567
|
+
className="rounded-md border border-line bg-white px-2 py-1 font-mono text-ui"
|
|
568
|
+
placeholder="space-separated, e.g. crm.objects.contacts.read"
|
|
569
|
+
value={(oauth.scopes ?? []).join(' ')}
|
|
570
|
+
onChange={(e) => {
|
|
571
|
+
// Split on save-shaped boundaries but keep the field
|
|
572
|
+
// typeable: a trailing space is a scope being started.
|
|
573
|
+
const scopes = e.target.value.split(/[\s,]+/);
|
|
574
|
+
updateOAuth(i, { scopes: scopes.length === 1 && scopes[0] === '' ? undefined : scopes });
|
|
575
|
+
}}
|
|
576
|
+
/>
|
|
577
|
+
</label>
|
|
578
|
+
<label className="flex items-center gap-2 text-ink-muted">
|
|
579
|
+
<input
|
|
580
|
+
type="checkbox"
|
|
581
|
+
aria-label={`Variable ${n} PKCE`}
|
|
582
|
+
checked={oauth.pkce !== false}
|
|
583
|
+
onChange={(e) => {
|
|
584
|
+
const next = { ...oauth };
|
|
585
|
+
if (e.target.checked) delete next.pkce;
|
|
586
|
+
else next.pkce = false;
|
|
587
|
+
update(i, { oauth: next });
|
|
588
|
+
}}
|
|
589
|
+
/>
|
|
590
|
+
PKCE (S256) — required by MCP servers; harmless for providers that ignore it
|
|
591
|
+
</label>
|
|
592
|
+
</div>
|
|
593
|
+
)}
|
|
594
|
+
</div>
|
|
595
|
+
);
|
|
596
|
+
})}
|
|
351
597
|
<div>
|
|
352
598
|
<Button variant="outline" size="sm" onClick={() => onChange([...variables, { name: '', scope: 'admin' }])}>
|
|
353
599
|
Add variable
|
|
@@ -361,6 +607,33 @@ function VariablesEditor({
|
|
|
361
607
|
);
|
|
362
608
|
}
|
|
363
609
|
|
|
610
|
+
/**
|
|
611
|
+
* The stored shape of one row: trimmed, empties dropped, the sign-in's
|
|
612
|
+
* endpoints sent as typed (a half pair is the backend's 422 to give, not
|
|
613
|
+
* something to silently complete or discard here).
|
|
614
|
+
*/
|
|
615
|
+
function normalizeVariable(v: McpServerVariable): McpServerVariable {
|
|
616
|
+
const label = v.label?.trim();
|
|
617
|
+
const base: McpServerVariable = { name: v.name.trim(), scope: v.scope, ...(label ? { label } : {}) };
|
|
618
|
+
if (!v.oauth || v.scope !== 'user') return base;
|
|
619
|
+
const o = v.oauth;
|
|
620
|
+
const authorizationUrl = o.authorizationUrl?.trim();
|
|
621
|
+
const tokenUrl = o.tokenUrl?.trim();
|
|
622
|
+
const scopes = (o.scopes ?? []).map((s) => s.trim()).filter(Boolean);
|
|
623
|
+
return {
|
|
624
|
+
...base,
|
|
625
|
+
oauth: {
|
|
626
|
+
...(authorizationUrl ? { authorizationUrl } : {}),
|
|
627
|
+
...(tokenUrl ? { tokenUrl } : {}),
|
|
628
|
+
clientId: o.clientId.trim(),
|
|
629
|
+
...(scopes.length > 0 ? { scopes } : {}),
|
|
630
|
+
...(o.authParams ? { authParams: o.authParams } : {}),
|
|
631
|
+
...(o.pkce === false ? { pkce: false } : {}),
|
|
632
|
+
...(o.resource ? { resource: o.resource } : {}),
|
|
633
|
+
},
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
|
|
364
637
|
function headersToLines(headers: Record<string, string>): string {
|
|
365
638
|
return Object.entries(headers)
|
|
366
639
|
.map(([k, v]) => `${k}: ${v}`)
|