dsh-mcp-manager-plus 0.4.4 → 0.5.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/lib/client.js CHANGED
@@ -33,9 +33,27 @@ window.__ModuleLoader__.load({
33
33
 
34
34
  var NS = 'dsh-mcp-manager-plus';
35
35
 
36
- /** Attribute this plugin stamps on its own settings nav row (see markNavRow). */
36
+ /**
37
+ * Attribute the LEGACY nav-row fallback stamps on this plugin's row.
38
+ *
39
+ * Only shells that predate `settings.section.icon` need it: they draw a
40
+ * generic gear for any section id they do not know, and CSS can hide that
41
+ * gear only if it can find the row, so the row is tagged. On a current
42
+ * shell the icon seat owns the row and no flag is ever written (apply()
43
+ * switches the tagger off as soon as the seat is live).
44
+ */
37
45
  var NAV_ROW_FLAG = 'data-mcpmp-nav';
38
46
 
47
+ /**
48
+ * Whether the shell declared `settings.section.icon`.
49
+ *
50
+ * When it did, the registration in `apply()` puts our glyph inside the
51
+ * shell's own icon seat: the shell then owns the row and its markup, so
52
+ * the flag-and-mask fallback must keep quiet, or the row would carry two
53
+ * glyphs (the one it paints and the one we painted beside the gear).
54
+ */
55
+ var iconSlotLive = false;
56
+
39
57
  /** The dictionary, keyed for the two locales the harness ships. */
40
58
  var DICT = {
41
59
  zh: {
@@ -96,7 +114,6 @@ window.__ModuleLoader__.load({
96
114
  phaseFailed: '连接失败',
97
115
  phaseDisabled: '已停用',
98
116
  phaseUnloading: '卸载中',
99
- sourceUser: '配置文件',
100
117
  sourceBundle: '部署内置',
101
118
  sourceBuiltin: '内置能力',
102
119
  notWritable: '配置文件不可写,改动无法保存:{path}',
@@ -110,6 +127,17 @@ window.__ModuleLoader__.load({
110
127
  collapse: '收起',
111
128
  langLabel: '语言',
112
129
  langAuto: '自动',
130
+ bindTitle: '项目绑定',
131
+ bindHint:
132
+ '把该服务器锁定到指定项目目录:只有工作目录位于这些目录(含其子目录)下的会话,才能看到并调用它的工具;其它项目里这些工具会被隐藏,调用也会被拒绝。留空即解除绑定,恢复全局可用。',
133
+ bindPathsLabel: '项目目录',
134
+ bindPathsHint: '每行一个绝对路径,例如 D:\\work\\my-project',
135
+ bindScopeAll: '全局可用',
136
+ bindScopeLimited: '仅限 {n} 个项目',
137
+ bindSaved: '已更新项目绑定',
138
+ bindUnbound: '已解除项目绑定',
139
+ bindNote: '绑定对正在运行的会话立即生效,无需重启,也不影响 MCP 连接本身。',
140
+ bindLoadHint: '支持 ~ 开头的家目录路径。',
113
141
  },
114
142
  en: {
115
143
  nav: 'MCP',
@@ -169,7 +197,6 @@ window.__ModuleLoader__.load({
169
197
  phaseFailed: 'Failed',
170
198
  phaseDisabled: 'Disabled',
171
199
  phaseUnloading: 'Unloading',
172
- sourceUser: 'Config file',
173
200
  sourceBundle: 'Deployment',
174
201
  sourceBuiltin: 'Built-in',
175
202
  notWritable: 'The configuration file is not writable, so changes cannot be saved: {path}',
@@ -183,6 +210,17 @@ window.__ModuleLoader__.load({
183
210
  collapse: 'Collapse',
184
211
  langLabel: 'Language',
185
212
  langAuto: 'Auto',
213
+ bindTitle: 'Project binding',
214
+ bindHint:
215
+ 'Lock this server to specific project directories: only sessions whose working directory is one of these directories (or inside one) can see and call its tools. In any other project the tools are hidden and refused. Leave it empty to clear the binding and make the server global again.',
216
+ bindPathsLabel: 'Project directories',
217
+ bindPathsHint: 'One absolute path per line, for example D:\\work\\my-project',
218
+ bindScopeAll: 'All projects',
219
+ bindScopeLimited: 'Bound to {n} project(s)',
220
+ bindSaved: 'Project binding updated',
221
+ bindUnbound: 'Project binding cleared',
222
+ bindNote: 'Applies immediately to running sessions — no restart needed, and the MCP connection itself is untouched.',
223
+ bindLoadHint: 'A path may start with ~ for your home directory.',
186
224
  },
187
225
  };
188
226
 
@@ -198,12 +236,14 @@ window.__ModuleLoader__.load({
198
236
  };
199
237
  }
200
238
 
201
- // The settings shell picks a nav-row icon from its own hard-coded table
202
- // keyed by section id, and every id it does not know — `mcp` included —
203
- // falls through to the same generic gear `general` uses. The two chain
204
- // links below are the shell's own `IconLinkOutline16` geometry, copied
205
- // verbatim so the row matches the rest of the sidebar's visual language.
206
- // They are filled (not stroked) because that is how the shipped icon draws.
239
+ // The chain-link glyph for this plugin's settings nav row.
240
+ //
241
+ // This is the shell's own `IconLinkOutline16` geometry, copied verbatim so
242
+ // the row matches the rest of the sidebar's visual language. The shapes are
243
+ // filled (not stroked) because that is how the shipped icon draws. Two
244
+ // consumers share these paths: `NavIcon` renders them into the shell's
245
+ // `settings.section.icon` seat on a current shell, and the legacy mask in
246
+ // `CSS` paints them on shells that have no such seat.
207
247
  var NAV_ICON_PATHS = [
208
248
  'M9.94133 6.50173C11.3218 7.99603 11.3218 10.3011 9.94128 11.7954C9.88691 11.8542 9.82125 11.9196 9.72099 12.0198L7.75707 13.9838C7.65709 14.0838 7.592 14.1491 7.53334 14.2034C6.03906 15.5843 3.7327 15.5854 2.23827 14.2048C2.17933 14.1503 2.11374 14.0844 2.01315 13.9838C1.91318 13.8839 1.84922 13.8188 1.79495 13.7601C0.413857 12.2657 0.413909 9.95948 1.795 8.46503C1.84923 8.4064 1.91335 8.34115 2.01321 8.24129L3.79275 6.46313C3.71814 7.08101 3.75236 7.71445 3.90115 8.33518L3.00344 9.23151C2.89398 9.34097 2.8535 9.38307 2.82251 9.41658C1.93771 10.3744 1.93704 11.8514 2.82179 12.8092C2.85279 12.8427 2.89383 12.884 3.0034 12.9936C3.11272 13.1029 3.15429 13.1442 3.18777 13.1752C4.14561 14.0603 5.62381 14.0608 6.58178 13.1758C6.61532 13.1448 6.65722 13.1032 6.76685 12.9935L8.73077 11.0296C8.83999 10.9204 8.88142 10.8787 8.91238 10.8452C9.79744 9.88728 9.7969 8.40911 8.91173 7.45124C8.88074 7.41775 8.83944 7.3762 8.73011 7.26687C8.62082 7.15757 8.58061 7.11623 8.54712 7.08526C8.37347 6.92477 8.18243 6.79361 7.98088 6.69165L9.00289 5.66964C9.17506 5.78373 9.34035 5.91265 9.49663 6.05703C9.55538 6.11135 9.62026 6.17652 9.72036 6.27662C9.82094 6.3772 9.88686 6.4428 9.94133 6.50173Z',
209
249
  'M6.06816 9.49196C4.68626 7.99724 4.68667 5.68942 6.06885 4.19487C6.12268 4.13671 6.18789 4.07306 6.28706 3.9739L8.24541 2.01416C8.34478 1.91479 8.41018 1.85055 8.46845 1.79665C9.96301 0.414902 12.2689 0.414922 13.7635 1.79665C13.8217 1.85051 13.8866 1.91559 13.9858 2.01486C14.0849 2.11394 14.1502 2.17769 14.204 2.23583C15.5861 3.7304 15.5866 6.03823 14.2047 7.53291C14.1508 7.59125 14.0854 7.65638 13.9858 7.75595L12.1994 9.54098C12.2614 8.92982 12.2185 8.30587 12.0634 7.69657L12.9956 6.76573C13.1044 6.65692 13.1458 6.61529 13.1765 6.58205C14.0621 5.62404 14.0621 4.1454 13.1765 3.18738C13.1458 3.15419 13.104 3.1135 12.9956 3.00508C12.8877 2.89716 12.8471 2.85551 12.814 2.82485C11.8559 1.9389 10.376 1.93886 9.41794 2.82485C9.38479 2.85554 9.34381 2.89622 9.23564 3.00439L7.27728 4.96413C7.16875 5.07265 7.12708 5.11322 7.09636 5.14643C6.21074 6.10441 6.21153 7.58236 7.09705 8.5404C7.12775 8.57357 7.16826 8.61575 7.27659 8.72408C7.38456 8.83205 7.42647 8.87227 7.45958 8.90293C7.62849 9.0591 7.81309 9.1881 8.00856 9.28894L6.98795 10.3095C6.82111 10.1978 6.66052 10.0715 6.50872 9.93114C6.45057 9.87733 6.38547 9.81341 6.28637 9.71431C6.1871 9.61504 6.12202 9.55018 6.06816 9.49196Z',
@@ -229,9 +269,32 @@ window.__ModuleLoader__.load({
229
269
  '.mcpmp-btn-danger{color:var(--dsw-alias-state-error-primary)}',
230
270
  '.mcpmp-btn-sm{height:26px;padding:0 9px;font-size:12px}',
231
271
  '.mcpmp-icon{width:30px;padding:0}',
272
+ // Row actions are icon-only, so their label has to come from somewhere
273
+ // on hover. The shell may clip a panel, so the tip is positioned against
274
+ // the button and allowed to escape upward; `pointer-events:none` keeps it
275
+ // out of the hit area, or hovering the tip would hide it.
276
+ '.mcpmp-icon[data-tip]{position:relative}',
277
+ '.mcpmp-icon[data-tip]::after{content:attr(data-tip);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translateX(-50%) translateY(2px);padding:3px 7px;border-radius:6px;background:var(--dsw-alias-bg-overlay);border:1px solid var(--dsw-alias-border-l1);box-shadow:0 4px 14px rgba(0,0,0,.16);color:var(--dsw-alias-label-primary);font-size:11px;line-height:1.4;font-weight:400;white-space:nowrap;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .12s ease,transform .12s ease;z-index:5}',
278
+ '.mcpmp-icon[data-tip]:hover::after,.mcpmp-icon[data-tip]:focus-visible::after{opacity:1;visibility:visible;transform:translateX(-50%) translateY(0)}',
279
+ // The row's last action sits next to the switch; anchoring the tip to the
280
+ // right edge keeps it inside the card instead of hanging off it.
281
+ '.mcpmp-row-actions{display:flex;gap:6px;flex:0 0 auto}',
282
+ '.mcpmp-row-actions>.mcpmp-icon:last-child[data-tip]::after{left:auto;right:0;transform:translateY(2px)}',
283
+ '.mcpmp-row-actions>.mcpmp-icon:last-child[data-tip]:hover::after,.mcpmp-row-actions>.mcpmp-icon:last-child[data-tip]:focus-visible::after{transform:translateY(0)}',
232
284
  '.mcpmp-list{display:flex;flex-direction:column;gap:8px}',
233
- '.mcpmp-card{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);overflow:hidden}',
234
- '.mcpmp-row{display:flex;align-items:center;gap:10px;padding:10px 12px;min-height:52px}',
285
+ // No `overflow:hidden` here: the row's icon buttons draw their labels as
286
+ // ::after tips, and a clipping card would cut them off. The expanded body
287
+ // is the only child that paints to the edge, so it carries the bottom
288
+ // corner itself rather than being clipped by the card.
289
+ '.mcpmp-card{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
290
+ '.mcpmp-card>*:last-child{border-bottom-left-radius:9px;border-bottom-right-radius:9px}',
291
+ // The tip reaches above the row, so the card it belongs to must paint
292
+ // over the card above it while one of its buttons is hovered.
293
+ '.mcpmp-card{position:relative}',
294
+ '.mcpmp-card:hover,.mcpmp-card:focus-within{z-index:1}',
295
+ // The tip is drawn above the button and must survive the card's
296
+ // neighbours, so the row itself must not clip either.
297
+ '.mcpmp-row{display:flex;align-items:center;gap:10px;padding:10px 12px;min-height:52px;position:relative}',
235
298
  '.mcpmp-avatar{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#fff;flex:0 0 auto;text-transform:uppercase}',
236
299
  '.mcpmp-name{display:flex;align-items:center;gap:6px;font-weight:500;min-width:0}',
237
300
  '.mcpmp-name span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
@@ -254,6 +317,13 @@ window.__ModuleLoader__.load({
254
317
  '.mcpmp-tool code{font-size:12px;color:var(--dsw-alias-label-primary);word-break:break-all}',
255
318
  '.mcpmp-tool p{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
256
319
  '.mcpmp-tools-empty{padding:10px 14px;color:var(--dsw-alias-label-secondary);font-size:12px}',
320
+ '.mcpmp-tag-bound{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-state-success-primary)}',
321
+ '.mcpmp-btn-bound{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary)}',
322
+ '.mcpmp-binding{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;padding:8px 14px;border-bottom:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);font-size:11px}',
323
+ '.mcpmp-binding-label{font-weight:500;color:var(--dsw-alias-label-secondary)}',
324
+ '.mcpmp-binding-paths{display:inline-flex;flex-wrap:wrap;gap:4px}',
325
+ '.mcpmp-binding-paths code{background:var(--dsw-alias-bg-layer-2);border-radius:5px;padding:1px 6px;font-size:11px}',
326
+ '.mcpmp-binding-all{color:var(--dsw-alias-label-secondary)}',
257
327
  '.mcpmp-note{padding:9px 12px;border-radius:8px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);font-size:12px}',
258
328
  '.mcpmp-note-warn{color:var(--dsw-alias-state-warn-primary)}',
259
329
  '.mcpmp-note-error{color:var(--dsw-alias-state-error-primary)}',
@@ -296,13 +366,15 @@ window.__ModuleLoader__.load({
296
366
  '.mcpmp-textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;line-height:1.55;resize:vertical}',
297
367
  '.mcpmp-input:focus,.mcpmp-select:focus,.mcpmp-textarea:focus{outline:none;border-color:var(--dsw-alias-brand-primary)}',
298
368
  '@media (max-width:640px){.mcpmp-tool{grid-template-columns:1fr;gap:2px}}',
299
- // ── settings nav row icon ────────────────────────────────────────────
300
- // The shell draws a generic gear for any section id it does not know,
301
- // and offers no way to supply a different one. Our row is tagged with
302
- // NAV_ROW_FLAG by markNavRow; hide the shell's gear in that row and
303
- // paint the chain-link glyph instead. The glyph rides a mask so it
304
- // inherits `currentColor` exactly like every other nav icon, in both
305
- // themes, with no extra element to keep in sync.
369
+ // ── legacy settings nav row icon (shells without the icon seat) ───────
370
+ // Before `settings.section.icon` existed, the shell drew a generic gear
371
+ // for any section id it did not know and offered no way to supply a
372
+ // different one. This is that workaround, kept only for those shells: a
373
+ // row tagged with NAV_ROW_FLAG hides the gear and paints the chain-link
374
+ // glyph in its place. The glyph rides a mask so it inherits
375
+ // `currentColor` exactly like every other nav icon, in both themes.
376
+ // `apply()` stops tagging rows as soon as the icon seat is live, so on a
377
+ // current shell no row ever matches these rules.
306
378
  'button[' + NAV_ROW_FLAG + ']>svg:first-child{display:none}',
307
379
  'button[' + NAV_ROW_FLAG + ']::before{content:"";flex:none;width:16px;height:16px;background-color:currentColor;'
308
380
  + '-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;'
@@ -471,6 +543,15 @@ window.__ModuleLoader__.load({
471
543
  refresh: h('path', { d: 'M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5V5H11' }),
472
544
  chevron: h('path', { d: 'M4 6l4 4 4-4' }),
473
545
  close: h('path', { d: 'M4 4l8 8M12 4l-8 8' }),
546
+ // Row-action glyphs. Each is one <path> of plain line segments so the
547
+ // stroke width stays uniform at 14px, where a multi-shape icon turns to
548
+ // mush.
549
+ edit: h('path', { d: 'M10.6 2.9l2.5 2.5-8 8L2 14.2l.8-3.1 7.8-8.2z' }),
550
+ trash: h('path', { d: 'M2.6 4.4h10.8M6.2 4.4V2.9h3.6v1.5M4.4 4.4l.6 8.7h6l.6-8.7' }),
551
+ // Project binding: a folder (the project) with a padlock on it.
552
+ bind: h('path', {
553
+ d: 'M2.4 12.8V3.6h3.5l1.3 1.6h6.4v3M7.6 9.2h4.6v3.6H7.6zM8.4 9.2V8.4a1.5 1.5 0 0 1 3 0v.8',
554
+ }),
474
555
  // Mode-switch glyphs: a form (label rows) and code brackets. Each is a
475
556
  // single <path> with several subpaths, so no React `key` is needed —
476
557
  // `key` is not forwarded to the DOM, but avoiding it keeps the elements
@@ -479,6 +560,32 @@ window.__ModuleLoader__.load({
479
560
  code: h('path', { d: 'M6 4L2.5 8 6 12M10 4l3.5 4L10 12' }),
480
561
  };
481
562
 
563
+ /**
564
+ * The settings nav-row glyph, for the shell's `settings.section.icon` seat.
565
+ *
566
+ * The seat hands a square size (the same 16 the shell's own nav icons use)
567
+ * and expects back the same shape they are: one inline SVG painted in
568
+ * `currentColor`, so the row's own active/hover colour applies without this
569
+ * component knowing either theme. It is deliberately not tied to the page's
570
+ * own header icon set — the row is part of the shell's sidebar.
571
+ */
572
+ function NavIcon(props) {
573
+ var size = props !== null && typeof props.size === 'number' ? props.size : 16;
574
+ return h(
575
+ 'svg',
576
+ {
577
+ width: size,
578
+ height: size,
579
+ viewBox: '0 0 16 16',
580
+ fill: 'none',
581
+ 'aria-hidden': 'true',
582
+ },
583
+ NAV_ICON_PATHS.map(function (d, index) {
584
+ return h('path', { key: index, d: d, fill: 'currentColor' });
585
+ }),
586
+ );
587
+ }
588
+
482
589
  /**
483
590
  * Mark this plugin's own nav row so the stylesheet can swap its icon.
484
591
  *
@@ -490,10 +597,14 @@ window.__ModuleLoader__.load({
490
597
  * `:nth-child` guess) keeps working when another plugin inserts a section
491
598
  * at a neighbouring order, and it never touches a row that is not ours.
492
599
  *
600
+ * Only the legacy path calls this: with the icon seat live the shell draws
601
+ * our glyph itself and tagging the row would add a second one.
602
+ *
493
603
  * @param root - the mounted page element.
494
604
  * @returns a disposer that removes the marker.
495
605
  */
496
606
  function markNavRow(root) {
607
+ if (iconSlotLive) return function () {};
497
608
  if (root === null || typeof root.closest !== 'function') return function () {};
498
609
  var label = makeT(localeRef.current)('nav');
499
610
  // The page is mounted inside the settings panel, so the panel is the
@@ -527,15 +638,22 @@ window.__ModuleLoader__.load({
527
638
  * for environments without MutationObserver; here a missing flag is only
528
639
  * ever set, never removed, so mutations cannot ping-pong.
529
640
  *
641
+ * LEGACY path only: the whole tagger switches off the moment
642
+ * `settings.section.icon` is live. The shell then draws our glyph inside
643
+ * its own icon seat, so a flagged row would show that glyph plus the
644
+ * mask, i.e. a second icon — exactly the bug this guard exists to prevent.
645
+ *
530
646
  * @returns a disposer that disconnects the observer.
531
647
  */
532
648
  function watchNavRow() {
649
+ if (iconSlotLive) return function () {};
533
650
  if (typeof MutationObserver === 'undefined' || typeof document === 'undefined') {
534
651
  return function () {};
535
652
  }
536
653
  var scheduled = false;
537
654
  function scan() {
538
655
  scheduled = false;
656
+ if (iconSlotLive) return;
539
657
  var label = makeT(localeRef.current)('nav');
540
658
  var cells = document.querySelectorAll('button[class*="navCell"]');
541
659
  for (var i = 0; i < cells.length; i += 1) {
@@ -558,6 +676,20 @@ window.__ModuleLoader__.load({
558
676
  };
559
677
  }
560
678
 
679
+ /**
680
+ * Drop every legacy row flag.
681
+ *
682
+ * Called when the icon seat turns out to be live. The shell usually
683
+ * declares it before this plugin applies, but nothing guarantees that: if
684
+ * it declares the seat later, rows the fallback already tagged have to
685
+ * stop painting a glyph of their own, or the row ends up with two.
686
+ */
687
+ function clearNavRowFlags() {
688
+ if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;
689
+ var rows = document.querySelectorAll('button[' + NAV_ROW_FLAG + ']');
690
+ for (var i = 0; i < rows.length; i += 1) rows[i].removeAttribute(NAV_ROW_FLAG);
691
+ }
692
+
561
693
  /** The row switch, styled as the pill toggle the rest of the UI uses. */
562
694
  function Switch(props) {
563
695
  return h(
@@ -594,51 +726,81 @@ window.__ModuleLoader__.load({
594
726
  unloading: t('phaseUnloading'),
595
727
  }[phase] || phase;
596
728
  var tools = Array.isArray(live.tools) ? live.tools : [];
729
+ // Only non-user rows wear this tag now; a user row's origin is the
730
+ // "config file" text this row used to spend a chip on.
597
731
  var sourceLabel =
598
- server.source === 'user'
599
- ? t('sourceUser')
600
- : server.source === 'builtin'
601
- ? t('sourceBuiltin')
602
- : t('sourceBundle');
732
+ server.source === 'builtin' ? t('sourceBuiltin') : t('sourceBundle');
733
+ var boundPaths =
734
+ server.binding && Array.isArray(server.binding.paths) ? server.binding.paths : [];
735
+ var bindingLabel =
736
+ boundPaths.length === 0 ? t('bindScopeAll') : t('bindScopeLimited', { n: boundPaths.length });
737
+
738
+ /**
739
+ * One row action: an icon-only button whose label lives in `title` and
740
+ * `aria-label`, plus a CSS tooltip of its own.
741
+ *
742
+ * `title` alone would be the accessible name AND the tooltip, but the
743
+ * native tooltip waits about a second and is invisible in screenshots, so
744
+ * the stylesheet paints one from `data-tip` on hover/focus. `title` is
745
+ * kept as the fallback for touch and for anything that ignores CSS, and
746
+ * `aria-label` is the accessible name — a button holding only an <svg>
747
+ * would otherwise announce as nothing.
748
+ */
749
+ function actionButton(spec) {
750
+ var label = t(spec.labelKey);
751
+ return h(
752
+ 'button',
753
+ {
754
+ key: spec.key,
755
+ type: 'button',
756
+ className: 'mcpmp-btn mcpmp-btn-sm mcpmp-icon' +
757
+ (spec.danger === true ? ' mcpmp-btn-danger' : '') +
758
+ (spec.active === true ? ' mcpmp-btn-bound' : ''),
759
+ disabled: busy,
760
+ onClick: spec.onClick,
761
+ title: label,
762
+ 'aria-label': label,
763
+ 'data-tip': label,
764
+ },
765
+ h(Icon, { path: spec.path, size: 14 }),
766
+ );
767
+ }
603
768
 
604
769
  var actions = [];
605
770
  if (server.editable) {
606
771
  actions.push(
607
- h(
608
- 'button',
609
- { key: 'edit', type: 'button', className: 'mcpmp-btn mcpmp-btn-sm', disabled: busy, onClick: props.onEdit },
610
- t('edit'),
611
- ),
772
+ actionButton({ key: 'edit', labelKey: 'edit', path: ICON_PATH.edit, onClick: props.onEdit }),
612
773
  );
613
774
  }
614
775
  if (live.mounted) {
615
776
  actions.push(
616
- h(
617
- 'button',
618
- {
619
- key: 'restart',
620
- type: 'button',
621
- className: 'mcpmp-btn mcpmp-btn-sm',
622
- disabled: busy,
623
- onClick: props.onRestart,
624
- },
625
- t('restart'),
626
- ),
777
+ actionButton({ key: 'restart', labelKey: 'restart', path: ICON_PATH.refresh, onClick: props.onRestart }),
627
778
  );
628
779
  }
629
780
  if (server.removable) {
630
781
  actions.push(
631
- h(
632
- 'button',
633
- {
634
- key: 'remove',
635
- type: 'button',
636
- className: 'mcpmp-btn mcpmp-btn-sm mcpmp-btn-danger',
637
- disabled: busy,
638
- onClick: props.onRemove,
639
- },
640
- t('remove'),
641
- ),
782
+ actionButton({
783
+ key: 'remove',
784
+ labelKey: 'remove',
785
+ path: ICON_PATH.trash,
786
+ onClick: props.onRemove,
787
+ danger: true,
788
+ }),
789
+ );
790
+ }
791
+
792
+ // Binding is offered for every row that carries a serverName, including
793
+ // bundle-provided ones: the binding table is this plugin's own data, so it
794
+ // can scope a server the user must not edit or delete.
795
+ if (server.serverName) {
796
+ actions.push(
797
+ actionButton({
798
+ key: 'bind',
799
+ labelKey: 'bindTitle',
800
+ path: ICON_PATH.bind,
801
+ onClick: props.onBind,
802
+ active: boundPaths.length > 0,
803
+ }),
642
804
  );
643
805
  }
644
806
 
@@ -680,10 +842,25 @@ window.__ModuleLoader__.load({
680
842
  h('span', { className: 'mcpmp-dot mcpmp-dot-' + phase }),
681
843
  h('span', null, phaseLabel),
682
844
  h('span', { className: 'mcpmp-tag' }, t('toolCount', { n: tools.length })),
683
- h('span', { className: 'mcpmp-tag' }, sourceLabel),
845
+ // The binding state sits where the source tag used to be. A
846
+ // user-managed server is the overwhelmingly common row, so its
847
+ // "config file" label was noise that pushed the useful state onto
848
+ // a second line; where the row came from still matters for the
849
+ // rows that are not the user's own, so those keep their tag.
850
+ h(
851
+ 'span',
852
+ {
853
+ className: 'mcpmp-tag' + (boundPaths.length > 0 ? ' mcpmp-tag-bound' : ''),
854
+ title: boundPaths.length > 0 ? boundPaths.join('\n') : t('bindScopeAll'),
855
+ },
856
+ bindingLabel,
857
+ ),
858
+ server.source === 'user'
859
+ ? null
860
+ : h('span', { className: 'mcpmp-tag' }, sourceLabel),
684
861
  ),
685
862
  ),
686
- actions.length > 0 ? h('div', { style: { display: 'flex', gap: 6 } }, actions) : null,
863
+ actions.length > 0 ? h('div', { className: 'mcpmp-row-actions' }, actions) : null,
687
864
  h(Switch, {
688
865
  checked: server.enabled,
689
866
  disabled: busy || server.id === '',
@@ -695,6 +872,23 @@ window.__ModuleLoader__.load({
695
872
  ? h(
696
873
  'div',
697
874
  { className: 'mcpmp-tools' },
875
+ h(
876
+ 'div',
877
+ {
878
+ className:
879
+ 'mcpmp-binding' + (boundPaths.length > 0 ? ' mcpmp-binding-bound' : ''),
880
+ },
881
+ h('span', { className: 'mcpmp-binding-label' }, t('bindTitle')),
882
+ boundPaths.length > 0
883
+ ? h(
884
+ 'span',
885
+ { className: 'mcpmp-binding-paths' },
886
+ boundPaths.map(function (path) {
887
+ return h('code', { key: path, title: path }, path);
888
+ }),
889
+ )
890
+ : h('span', { className: 'mcpmp-binding-all' }, t('bindScopeAll')),
891
+ ),
698
892
  tools.length === 0
699
893
  ? h('div', { className: 'mcpmp-tools-empty' }, t('noTools'))
700
894
  : tools.map(function (tool) {
@@ -979,6 +1173,101 @@ window.__ModuleLoader__.load({
979
1173
  );
980
1174
  }
981
1175
 
1176
+ /**
1177
+ * The project-binding editor for one server.
1178
+ *
1179
+ * Paths are typed one per line rather than chosen from a directory picker:
1180
+ * a browser file picker cannot hand back an absolute path, and the directory
1181
+ * a user wants to bind is usually not one they can reach from a picker
1182
+ * anyway. The host validates every line and refuses the whole write when one
1183
+ * is relative, so a typo cannot half-apply.
1184
+ */
1185
+ function BindingDialog(props) {
1186
+ var t = props.t;
1187
+ var server = props.server;
1188
+ var existing =
1189
+ server.binding && Array.isArray(server.binding.paths) ? server.binding.paths : [];
1190
+ var [text, setText] = useState(function () {
1191
+ return existing.join('\n');
1192
+ });
1193
+ var [error, setError] = useState(null);
1194
+ var [busy, setBusy] = useState(false);
1195
+
1196
+ function submit() {
1197
+ if (busy) return;
1198
+ var paths = text
1199
+ .split('\n')
1200
+ .map(function (line) {
1201
+ return line.trim();
1202
+ })
1203
+ .filter(function (line) {
1204
+ return line !== '';
1205
+ });
1206
+ setBusy(true);
1207
+ setError(null);
1208
+ api('bind', { serverName: server.serverName, paths: paths })
1209
+ .then(function (result) {
1210
+ setBusy(false);
1211
+ props.onDone(result);
1212
+ })
1213
+ .catch(function (failure) {
1214
+ setBusy(false);
1215
+ setError(String((failure && failure.message) || failure));
1216
+ });
1217
+ }
1218
+
1219
+ return h(
1220
+ Modal,
1221
+ {
1222
+ title: t('bindTitle') + ' · ' + server.serverName,
1223
+ closeLabel: t('close'),
1224
+ onClose: props.onClose,
1225
+ footer: h(
1226
+ 'div',
1227
+ {
1228
+ style: {
1229
+ display: 'flex',
1230
+ alignItems: 'center',
1231
+ justifyContent: 'space-between',
1232
+ width: '100%',
1233
+ gap: 12,
1234
+ },
1235
+ },
1236
+ h('span', { className: 'mcpmp-note', style: { fontSize: 11, padding: '5px 8px' } }, t('bindNote')),
1237
+ h(
1238
+ 'div',
1239
+ { style: { display: 'flex', gap: 8 } },
1240
+ h('button', { type: 'button', className: 'mcpmp-btn', onClick: props.onClose }, t('cancel')),
1241
+ h(
1242
+ 'button',
1243
+ { type: 'button', className: 'mcpmp-btn mcpmp-btn-primary', disabled: busy, onClick: submit },
1244
+ busy ? t('saving') : t('confirm'),
1245
+ ),
1246
+ ),
1247
+ ),
1248
+ },
1249
+ h('p', null, t('bindHint')),
1250
+ h(
1251
+ 'div',
1252
+ { className: 'mcpmp-field' },
1253
+ h('label', { htmlFor: 'mcpmp-bind-paths' }, t('bindPathsLabel')),
1254
+ h('textarea', {
1255
+ id: 'mcpmp-bind-paths',
1256
+ className: 'mcpmp-textarea',
1257
+ rows: 6,
1258
+ spellCheck: false,
1259
+ value: text,
1260
+ placeholder: 'D:\\work\\my-project\n~/work/another-project',
1261
+ onChange: function (event) {
1262
+ setText(event.target.value);
1263
+ },
1264
+ }),
1265
+ h('small', null, t('bindPathsHint') + ' ' + t('bindLoadHint')),
1266
+ ),
1267
+ error !== null ? h('div', { className: 'mcpmp-note mcpmp-note-error' }, error) : null,
1268
+ );
1269
+ }
1270
+
982
1271
  /** The add/edit form for one server. */
983
1272
  function ServerFormDialog(props) {
984
1273
  var t = props.t;
@@ -1231,9 +1520,11 @@ window.__ModuleLoader__.load({
1231
1520
  var settleTimer = useRef(null);
1232
1521
  var pageRef = useRef(null);
1233
1522
 
1234
- // Swap this page's settings nav-row icon. watchNavRow already keeps the
1235
- // row flagged from registration time, so this is only a fallback for
1236
- // environments where the observer is unavailable.
1523
+ // Legacy paths only — with `settings.section.icon` live the glyph is
1524
+ // registered at apply() time and the row needs no tagging. watchNavRow
1525
+ // already keeps the row flagged from registration time, so this is a
1526
+ // fallback for environments where the observer is unavailable; both are
1527
+ // no-ops once the icon seat is live.
1237
1528
  useEffect(function () {
1238
1529
  return markNavRow(pageRef.current);
1239
1530
  }, []);
@@ -1380,6 +1671,9 @@ window.__ModuleLoader__.load({
1380
1671
  onEdit: function () {
1381
1672
  setDialog({ kind: 'form', server: server });
1382
1673
  },
1674
+ onBind: function () {
1675
+ setDialog({ kind: 'bind', server: server });
1676
+ },
1383
1677
  });
1384
1678
  }),
1385
1679
  );
@@ -1529,6 +1823,27 @@ window.__ModuleLoader__.load({
1529
1823
  : undefined,
1530
1824
  })
1531
1825
  : null,
1826
+
1827
+ // Binding never touches the loader tree, so the state the host returns
1828
+ // is already final — no `settle()` poll is needed here.
1829
+ dialog !== null && dialog.kind === 'bind'
1830
+ ? h(BindingDialog, {
1831
+ t: t,
1832
+ server: dialog.server,
1833
+ onClose: function () {
1834
+ setDialog(null);
1835
+ },
1836
+ onDone: function (result) {
1837
+ setDialog(null);
1838
+ if (result && result.state) setState({ status: 'ready', data: result.state, error: null });
1839
+ setNotice(
1840
+ (result && result.action === 'cleared' ? t('bindUnbound') : t('bindSaved')) +
1841
+ ':' +
1842
+ ((result && result.serverName) || ''),
1843
+ );
1844
+ },
1845
+ })
1846
+ : null,
1532
1847
  );
1533
1848
  }
1534
1849
 
@@ -1595,9 +1910,35 @@ window.__ModuleLoader__.load({
1595
1910
  });
1596
1911
  }, 'dsh-mcp-manager-plus: settings section');
1597
1912
 
1598
- // Flag the nav row from the moment the shell first renders it, so the
1599
- // link icon shows before the page is ever opened.
1600
- ctx.effect(watchNavRow, 'dsh-mcp-manager-plus: nav row icon watch');
1913
+ // Preferred path: the shell's own icon seat for a settings section.
1914
+ // `id` must equal the section id registered above — the shell draws the
1915
+ // entry whose id matches the row it is rendering and falls back to its
1916
+ // generic gear when none does. This seat only exists on shells that
1917
+ // declare it, hence the stylesheet fallback below.
1918
+ try {
1919
+ ctx.effect(function () {
1920
+ return slots.inject('settings.section.icon', function () {
1921
+ iconSlotLive = true;
1922
+ // The seat took over the row: retire anything the legacy fallback
1923
+ // already tagged before its first render.
1924
+ clearNavRowFlags();
1925
+ return slots.register({ name: 'settings.section.icon', id: 'mcp' }, NavIcon);
1926
+ });
1927
+ }, 'dsh-mcp-manager-plus: settings nav icon');
1928
+ } catch (error) {
1929
+ // A shell without the seat parks the injection; one that rejects the
1930
+ // unknown key lands here. Either way the page must still register, so
1931
+ // the failure is reported and the fallback below takes the row.
1932
+ console.warn(
1933
+ '[dsh-mcp-manager-plus] settings.section.icon is unavailable, using the stylesheet glyph:',
1934
+ error,
1935
+ );
1936
+ }
1937
+
1938
+ // Legacy path, for shells that predate the icon seat: flag the row from
1939
+ // the moment the shell first renders it, so the link glyph shows before
1940
+ // the page is ever opened. No-op once `iconSlotLive` is set.
1941
+ ctx.effect(watchNavRow, 'dsh-mcp-manager-plus: legacy nav row icon');
1601
1942
  };
1602
1943
 
1603
1944
  return module.exports;