dsh-mcp-manager-plus 0.4.5 → 0.5.2
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/CHANGELOG.md +109 -0
- package/README.en.md +148 -6
- package/README.md +114 -7
- package/lib/client.js +403 -52
- package/lib/index.js +821 -20
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -114,7 +114,15 @@ window.__ModuleLoader__.load({
|
|
|
114
114
|
phaseFailed: '连接失败',
|
|
115
115
|
phaseDisabled: '已停用',
|
|
116
116
|
phaseUnloading: '卸载中',
|
|
117
|
-
|
|
117
|
+
phaseReconnecting: '重连中',
|
|
118
|
+
phaseClosed: '已断开',
|
|
119
|
+
phaseCredentials: '缺少凭据',
|
|
120
|
+
phaseUnverified: '可能未连接',
|
|
121
|
+
reasonGaveUp: '已放弃重连',
|
|
122
|
+
reasonReconnectDisabled: '自动重连已关闭',
|
|
123
|
+
reasonUnclosed: '上一代连接未关闭',
|
|
124
|
+
reconnectDetail: '第 {attempt}/{max} 次重连',
|
|
125
|
+
noToolsConnected: '服务器已连接,但未提供任何工具。',
|
|
118
126
|
sourceBundle: '部署内置',
|
|
119
127
|
sourceBuiltin: '内置能力',
|
|
120
128
|
notWritable: '配置文件不可写,改动无法保存:{path}',
|
|
@@ -128,6 +136,17 @@ window.__ModuleLoader__.load({
|
|
|
128
136
|
collapse: '收起',
|
|
129
137
|
langLabel: '语言',
|
|
130
138
|
langAuto: '自动',
|
|
139
|
+
bindTitle: '项目绑定',
|
|
140
|
+
bindHint:
|
|
141
|
+
'把该服务器锁定到指定项目目录:只有工作目录位于这些目录(含其子目录)下的会话,才能看到并调用它的工具;其它项目里这些工具会被隐藏,调用也会被拒绝。留空即解除绑定,恢复全局可用。',
|
|
142
|
+
bindPathsLabel: '项目目录',
|
|
143
|
+
bindPathsHint: '每行一个绝对路径,例如 D:\\work\\my-project',
|
|
144
|
+
bindScopeAll: '全局可用',
|
|
145
|
+
bindScopeLimited: '仅限 {n} 个项目',
|
|
146
|
+
bindSaved: '已更新项目绑定',
|
|
147
|
+
bindUnbound: '已解除项目绑定',
|
|
148
|
+
bindNote: '绑定对正在运行的会话立即生效,无需重启,也不影响 MCP 连接本身。',
|
|
149
|
+
bindLoadHint: '支持 ~ 开头的家目录路径。',
|
|
131
150
|
},
|
|
132
151
|
en: {
|
|
133
152
|
nav: 'MCP',
|
|
@@ -187,7 +206,15 @@ window.__ModuleLoader__.load({
|
|
|
187
206
|
phaseFailed: 'Failed',
|
|
188
207
|
phaseDisabled: 'Disabled',
|
|
189
208
|
phaseUnloading: 'Unloading',
|
|
190
|
-
|
|
209
|
+
phaseReconnecting: 'Reconnecting',
|
|
210
|
+
phaseClosed: 'Disconnected',
|
|
211
|
+
phaseCredentials: 'Missing credentials',
|
|
212
|
+
phaseUnverified: 'May be disconnected',
|
|
213
|
+
reasonGaveUp: 'Gave up reconnecting',
|
|
214
|
+
reasonReconnectDisabled: 'Automatic reconnect is off',
|
|
215
|
+
reasonUnclosed: 'Previous connection was not closed',
|
|
216
|
+
reconnectDetail: 'Reconnect attempt {attempt}/{max}',
|
|
217
|
+
noToolsConnected: 'Connected, but the server exposes no tools.',
|
|
191
218
|
sourceBundle: 'Deployment',
|
|
192
219
|
sourceBuiltin: 'Built-in',
|
|
193
220
|
notWritable: 'The configuration file is not writable, so changes cannot be saved: {path}',
|
|
@@ -201,6 +228,17 @@ window.__ModuleLoader__.load({
|
|
|
201
228
|
collapse: 'Collapse',
|
|
202
229
|
langLabel: 'Language',
|
|
203
230
|
langAuto: 'Auto',
|
|
231
|
+
bindTitle: 'Project binding',
|
|
232
|
+
bindHint:
|
|
233
|
+
'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.',
|
|
234
|
+
bindPathsLabel: 'Project directories',
|
|
235
|
+
bindPathsHint: 'One absolute path per line, for example D:\\work\\my-project',
|
|
236
|
+
bindScopeAll: 'All projects',
|
|
237
|
+
bindScopeLimited: 'Bound to {n} project(s)',
|
|
238
|
+
bindSaved: 'Project binding updated',
|
|
239
|
+
bindUnbound: 'Project binding cleared',
|
|
240
|
+
bindNote: 'Applies immediately to running sessions — no restart needed, and the MCP connection itself is untouched.',
|
|
241
|
+
bindLoadHint: 'A path may start with ~ for your home directory.',
|
|
204
242
|
},
|
|
205
243
|
};
|
|
206
244
|
|
|
@@ -249,9 +287,32 @@ window.__ModuleLoader__.load({
|
|
|
249
287
|
'.mcpmp-btn-danger{color:var(--dsw-alias-state-error-primary)}',
|
|
250
288
|
'.mcpmp-btn-sm{height:26px;padding:0 9px;font-size:12px}',
|
|
251
289
|
'.mcpmp-icon{width:30px;padding:0}',
|
|
290
|
+
// Row actions are icon-only, so their label has to come from somewhere
|
|
291
|
+
// on hover. The shell may clip a panel, so the tip is positioned against
|
|
292
|
+
// the button and allowed to escape upward; `pointer-events:none` keeps it
|
|
293
|
+
// out of the hit area, or hovering the tip would hide it.
|
|
294
|
+
'.mcpmp-icon[data-tip]{position:relative}',
|
|
295
|
+
'.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}',
|
|
296
|
+
'.mcpmp-icon[data-tip]:hover::after,.mcpmp-icon[data-tip]:focus-visible::after{opacity:1;visibility:visible;transform:translateX(-50%) translateY(0)}',
|
|
297
|
+
// The row's last action sits next to the switch; anchoring the tip to the
|
|
298
|
+
// right edge keeps it inside the card instead of hanging off it.
|
|
299
|
+
'.mcpmp-row-actions{display:flex;gap:6px;flex:0 0 auto}',
|
|
300
|
+
'.mcpmp-row-actions>.mcpmp-icon:last-child[data-tip]::after{left:auto;right:0;transform:translateY(2px)}',
|
|
301
|
+
'.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)}',
|
|
252
302
|
'.mcpmp-list{display:flex;flex-direction:column;gap:8px}',
|
|
253
|
-
|
|
254
|
-
|
|
303
|
+
// No `overflow:hidden` here: the row's icon buttons draw their labels as
|
|
304
|
+
// ::after tips, and a clipping card would cut them off. The expanded body
|
|
305
|
+
// is the only child that paints to the edge, so it carries the bottom
|
|
306
|
+
// corner itself rather than being clipped by the card.
|
|
307
|
+
'.mcpmp-card{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
|
|
308
|
+
'.mcpmp-card>*:last-child{border-bottom-left-radius:9px;border-bottom-right-radius:9px}',
|
|
309
|
+
// The tip reaches above the row, so the card it belongs to must paint
|
|
310
|
+
// over the card above it while one of its buttons is hovered.
|
|
311
|
+
'.mcpmp-card{position:relative}',
|
|
312
|
+
'.mcpmp-card:hover,.mcpmp-card:focus-within{z-index:1}',
|
|
313
|
+
// The tip is drawn above the button and must survive the card's
|
|
314
|
+
// neighbours, so the row itself must not clip either.
|
|
315
|
+
'.mcpmp-row{display:flex;align-items:center;gap:10px;padding:10px 12px;min-height:52px;position:relative}',
|
|
255
316
|
'.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}',
|
|
256
317
|
'.mcpmp-name{display:flex;align-items:center;gap:6px;font-weight:500;min-width:0}',
|
|
257
318
|
'.mcpmp-name span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
@@ -274,6 +335,13 @@ window.__ModuleLoader__.load({
|
|
|
274
335
|
'.mcpmp-tool code{font-size:12px;color:var(--dsw-alias-label-primary);word-break:break-all}',
|
|
275
336
|
'.mcpmp-tool p{margin:0;color:var(--dsw-alias-label-secondary);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
|
|
276
337
|
'.mcpmp-tools-empty{padding:10px 14px;color:var(--dsw-alias-label-secondary);font-size:12px}',
|
|
338
|
+
'.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)}',
|
|
339
|
+
'.mcpmp-btn-bound{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary)}',
|
|
340
|
+
'.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}',
|
|
341
|
+
'.mcpmp-binding-label{font-weight:500;color:var(--dsw-alias-label-secondary)}',
|
|
342
|
+
'.mcpmp-binding-paths{display:inline-flex;flex-wrap:wrap;gap:4px}',
|
|
343
|
+
'.mcpmp-binding-paths code{background:var(--dsw-alias-bg-layer-2);border-radius:5px;padding:1px 6px;font-size:11px}',
|
|
344
|
+
'.mcpmp-binding-all{color:var(--dsw-alias-label-secondary)}',
|
|
277
345
|
'.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}',
|
|
278
346
|
'.mcpmp-note-warn{color:var(--dsw-alias-state-warn-primary)}',
|
|
279
347
|
'.mcpmp-note-error{color:var(--dsw-alias-state-error-primary)}',
|
|
@@ -493,6 +561,15 @@ window.__ModuleLoader__.load({
|
|
|
493
561
|
refresh: h('path', { d: 'M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5V5H11' }),
|
|
494
562
|
chevron: h('path', { d: 'M4 6l4 4 4-4' }),
|
|
495
563
|
close: h('path', { d: 'M4 4l8 8M12 4l-8 8' }),
|
|
564
|
+
// Row-action glyphs. Each is one <path> of plain line segments so the
|
|
565
|
+
// stroke width stays uniform at 14px, where a multi-shape icon turns to
|
|
566
|
+
// mush.
|
|
567
|
+
edit: h('path', { d: 'M10.6 2.9l2.5 2.5-8 8L2 14.2l.8-3.1 7.8-8.2z' }),
|
|
568
|
+
trash: h('path', { d: 'M2.6 4.4h10.8M6.2 4.4V2.9h3.6v1.5M4.4 4.4l.6 8.7h6l.6-8.7' }),
|
|
569
|
+
// Project binding: a folder (the project) with a padlock on it.
|
|
570
|
+
bind: h('path', {
|
|
571
|
+
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',
|
|
572
|
+
}),
|
|
496
573
|
// Mode-switch glyphs: a form (label rows) and code brackets. Each is a
|
|
497
574
|
// single <path> with several subpaths, so no React `key` is needed —
|
|
498
575
|
// `key` is not forwarded to the DOM, but avoiding it keeps the elements
|
|
@@ -657,61 +734,162 @@ window.__ModuleLoader__.load({
|
|
|
657
734
|
var expanded = props.expanded;
|
|
658
735
|
var live = server.live || {};
|
|
659
736
|
var phase = live.phase || 'pending';
|
|
660
|
-
var
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
737
|
+
var connection =
|
|
738
|
+
live.connection !== null && typeof live.connection === 'object' ? live.connection : null;
|
|
739
|
+
var connectionState =
|
|
740
|
+
connection !== null && typeof connection.state === 'string' ? connection.state : '';
|
|
741
|
+
// The bridge's own state is the truthful badge once it exists: the loader
|
|
742
|
+
// phase only proves the plugin mounted, and a crashed MCP handshake leaves
|
|
743
|
+
// that phase active forever. Lifecycle states still win — a disabled or
|
|
744
|
+
// failed entry has no live bridge to report.
|
|
745
|
+
var CONNECTION_LABEL = {
|
|
746
|
+
connected: 'phaseActive',
|
|
747
|
+
connecting: 'phaseLoading',
|
|
748
|
+
reconnecting: 'phaseReconnecting',
|
|
749
|
+
failed: 'phaseFailed',
|
|
750
|
+
closed: 'phaseClosed',
|
|
751
|
+
'waiting-credentials': 'phaseCredentials',
|
|
752
|
+
unknown: 'phaseUnverified',
|
|
753
|
+
};
|
|
754
|
+
var CONNECTION_DOT = {
|
|
755
|
+
connected: 'active',
|
|
756
|
+
connecting: 'loading',
|
|
757
|
+
reconnecting: 'loading',
|
|
758
|
+
failed: 'failed',
|
|
759
|
+
closed: 'failed',
|
|
760
|
+
'waiting-credentials': 'pending',
|
|
761
|
+
unknown: 'pending',
|
|
762
|
+
};
|
|
763
|
+
var REASON_LABEL = {
|
|
764
|
+
'gave-up': t('reasonGaveUp'),
|
|
765
|
+
'reconnect-disabled': t('reasonReconnectDisabled'),
|
|
766
|
+
'unclosed-generation': t('reasonUnclosed'),
|
|
767
|
+
};
|
|
768
|
+
var phaseLabel;
|
|
769
|
+
var dotPhase = phase;
|
|
770
|
+
if (phase === 'active' && connectionState !== '') {
|
|
771
|
+
phaseLabel =
|
|
772
|
+
CONNECTION_LABEL[connectionState] !== undefined
|
|
773
|
+
? t(CONNECTION_LABEL[connectionState])
|
|
774
|
+
: connectionState;
|
|
775
|
+
dotPhase = CONNECTION_DOT[connectionState] || 'pending';
|
|
776
|
+
} else {
|
|
777
|
+
phaseLabel =
|
|
778
|
+
{
|
|
779
|
+
active: t('phaseActive'),
|
|
780
|
+
loading: t('phaseLoading'),
|
|
781
|
+
pending: t('phasePending'),
|
|
782
|
+
failed: t('phaseFailed'),
|
|
783
|
+
disabled: t('phaseDisabled'),
|
|
784
|
+
unloading: t('phaseUnloading'),
|
|
785
|
+
}[phase] || phase;
|
|
786
|
+
}
|
|
787
|
+
var statusTitle = '';
|
|
788
|
+
if (connection !== null) {
|
|
789
|
+
var reason =
|
|
790
|
+
typeof connection.reason === 'string'
|
|
791
|
+
? REASON_LABEL[connection.reason] || connection.reason
|
|
792
|
+
: '';
|
|
793
|
+
statusTitle = [reason, connection.cleanupError, connection.lastError]
|
|
794
|
+
.filter(function (part) {
|
|
795
|
+
return typeof part === 'string' && part !== '';
|
|
796
|
+
})
|
|
797
|
+
.join(' · ');
|
|
798
|
+
if (
|
|
799
|
+
statusTitle === '' &&
|
|
800
|
+
connection.state === 'reconnecting' &&
|
|
801
|
+
typeof connection.attempt === 'number'
|
|
802
|
+
) {
|
|
803
|
+
statusTitle = t('reconnectDetail', {
|
|
804
|
+
attempt: connection.attempt,
|
|
805
|
+
max: typeof connection.maxAttempts === 'number' ? connection.maxAttempts : '?',
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
// A green tick next to "连接失败" is the contradiction this row used to
|
|
810
|
+
// show. Keep the enabled mark only while the connection is not known to be
|
|
811
|
+
// down; the switch itself still reports the configured on/off state.
|
|
812
|
+
var connectionDown =
|
|
813
|
+
connectionState === 'failed' ||
|
|
814
|
+
connectionState === 'closed' ||
|
|
815
|
+
connectionState === 'unknown';
|
|
816
|
+
var showEnabledTick = server.enabled && phase !== 'failed' && !connectionDown;
|
|
669
817
|
var tools = Array.isArray(live.tools) ? live.tools : [];
|
|
818
|
+
// Only non-user rows wear this tag now; a user row's origin is the
|
|
819
|
+
// "config file" text this row used to spend a chip on.
|
|
670
820
|
var sourceLabel =
|
|
671
|
-
server.source === '
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
821
|
+
server.source === 'builtin' ? t('sourceBuiltin') : t('sourceBundle');
|
|
822
|
+
var boundPaths =
|
|
823
|
+
server.binding && Array.isArray(server.binding.paths) ? server.binding.paths : [];
|
|
824
|
+
var bindingLabel =
|
|
825
|
+
boundPaths.length === 0 ? t('bindScopeAll') : t('bindScopeLimited', { n: boundPaths.length });
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* One row action: an icon-only button whose label lives in `title` and
|
|
829
|
+
* `aria-label`, plus a CSS tooltip of its own.
|
|
830
|
+
*
|
|
831
|
+
* `title` alone would be the accessible name AND the tooltip, but the
|
|
832
|
+
* native tooltip waits about a second and is invisible in screenshots, so
|
|
833
|
+
* the stylesheet paints one from `data-tip` on hover/focus. `title` is
|
|
834
|
+
* kept as the fallback for touch and for anything that ignores CSS, and
|
|
835
|
+
* `aria-label` is the accessible name — a button holding only an <svg>
|
|
836
|
+
* would otherwise announce as nothing.
|
|
837
|
+
*/
|
|
838
|
+
function actionButton(spec) {
|
|
839
|
+
var label = t(spec.labelKey);
|
|
840
|
+
return h(
|
|
841
|
+
'button',
|
|
842
|
+
{
|
|
843
|
+
key: spec.key,
|
|
844
|
+
type: 'button',
|
|
845
|
+
className: 'mcpmp-btn mcpmp-btn-sm mcpmp-icon' +
|
|
846
|
+
(spec.danger === true ? ' mcpmp-btn-danger' : '') +
|
|
847
|
+
(spec.active === true ? ' mcpmp-btn-bound' : ''),
|
|
848
|
+
disabled: busy,
|
|
849
|
+
onClick: spec.onClick,
|
|
850
|
+
title: label,
|
|
851
|
+
'aria-label': label,
|
|
852
|
+
'data-tip': label,
|
|
853
|
+
},
|
|
854
|
+
h(Icon, { path: spec.path, size: 14 }),
|
|
855
|
+
);
|
|
856
|
+
}
|
|
676
857
|
|
|
677
858
|
var actions = [];
|
|
678
859
|
if (server.editable) {
|
|
679
860
|
actions.push(
|
|
680
|
-
|
|
681
|
-
'button',
|
|
682
|
-
{ key: 'edit', type: 'button', className: 'mcpmp-btn mcpmp-btn-sm', disabled: busy, onClick: props.onEdit },
|
|
683
|
-
t('edit'),
|
|
684
|
-
),
|
|
861
|
+
actionButton({ key: 'edit', labelKey: 'edit', path: ICON_PATH.edit, onClick: props.onEdit }),
|
|
685
862
|
);
|
|
686
863
|
}
|
|
687
864
|
if (live.mounted) {
|
|
688
865
|
actions.push(
|
|
689
|
-
|
|
690
|
-
'button',
|
|
691
|
-
{
|
|
692
|
-
key: 'restart',
|
|
693
|
-
type: 'button',
|
|
694
|
-
className: 'mcpmp-btn mcpmp-btn-sm',
|
|
695
|
-
disabled: busy,
|
|
696
|
-
onClick: props.onRestart,
|
|
697
|
-
},
|
|
698
|
-
t('restart'),
|
|
699
|
-
),
|
|
866
|
+
actionButton({ key: 'restart', labelKey: 'restart', path: ICON_PATH.refresh, onClick: props.onRestart }),
|
|
700
867
|
);
|
|
701
868
|
}
|
|
702
869
|
if (server.removable) {
|
|
703
870
|
actions.push(
|
|
704
|
-
|
|
705
|
-
'
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
871
|
+
actionButton({
|
|
872
|
+
key: 'remove',
|
|
873
|
+
labelKey: 'remove',
|
|
874
|
+
path: ICON_PATH.trash,
|
|
875
|
+
onClick: props.onRemove,
|
|
876
|
+
danger: true,
|
|
877
|
+
}),
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// Binding is offered for every row that carries a serverName, including
|
|
882
|
+
// bundle-provided ones: the binding table is this plugin's own data, so it
|
|
883
|
+
// can scope a server the user must not edit or delete.
|
|
884
|
+
if (server.serverName) {
|
|
885
|
+
actions.push(
|
|
886
|
+
actionButton({
|
|
887
|
+
key: 'bind',
|
|
888
|
+
labelKey: 'bindTitle',
|
|
889
|
+
path: ICON_PATH.bind,
|
|
890
|
+
onClick: props.onBind,
|
|
891
|
+
active: boundPaths.length > 0,
|
|
892
|
+
}),
|
|
715
893
|
);
|
|
716
894
|
}
|
|
717
895
|
|
|
@@ -745,18 +923,46 @@ window.__ModuleLoader__.load({
|
|
|
745
923
|
'div',
|
|
746
924
|
{ className: 'mcpmp-name' },
|
|
747
925
|
h('span', { title: server.serverName }, server.displayName || server.serverName),
|
|
748
|
-
|
|
926
|
+
showEnabledTick ? h('span', { style: { color: 'var(--dsw-alias-state-success-primary)' } }, '✓') : null,
|
|
749
927
|
),
|
|
750
928
|
h(
|
|
751
929
|
'div',
|
|
752
930
|
{ className: 'mcpmp-meta' },
|
|
753
|
-
h('span', {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
931
|
+
h('span', {
|
|
932
|
+
className: 'mcpmp-dot mcpmp-dot-' + dotPhase,
|
|
933
|
+
title: statusTitle || undefined,
|
|
934
|
+
}),
|
|
935
|
+
h('span', { title: statusTitle || undefined }, phaseLabel),
|
|
936
|
+
h(
|
|
937
|
+
'span',
|
|
938
|
+
{
|
|
939
|
+
className: 'mcpmp-tag',
|
|
940
|
+
title:
|
|
941
|
+
connectionState === 'connected' && tools.length === 0
|
|
942
|
+
? t('noToolsConnected')
|
|
943
|
+
: undefined,
|
|
944
|
+
},
|
|
945
|
+
t('toolCount', { n: tools.length }),
|
|
946
|
+
),
|
|
947
|
+
// The binding state sits where the source tag used to be. A
|
|
948
|
+
// user-managed server is the overwhelmingly common row, so its
|
|
949
|
+
// "config file" label was noise that pushed the useful state onto
|
|
950
|
+
// a second line; where the row came from still matters for the
|
|
951
|
+
// rows that are not the user's own, so those keep their tag.
|
|
952
|
+
h(
|
|
953
|
+
'span',
|
|
954
|
+
{
|
|
955
|
+
className: 'mcpmp-tag' + (boundPaths.length > 0 ? ' mcpmp-tag-bound' : ''),
|
|
956
|
+
title: boundPaths.length > 0 ? boundPaths.join('\n') : t('bindScopeAll'),
|
|
957
|
+
},
|
|
958
|
+
bindingLabel,
|
|
959
|
+
),
|
|
960
|
+
server.source === 'user'
|
|
961
|
+
? null
|
|
962
|
+
: h('span', { className: 'mcpmp-tag' }, sourceLabel),
|
|
757
963
|
),
|
|
758
964
|
),
|
|
759
|
-
actions.length > 0 ? h('div', {
|
|
965
|
+
actions.length > 0 ? h('div', { className: 'mcpmp-row-actions' }, actions) : null,
|
|
760
966
|
h(Switch, {
|
|
761
967
|
checked: server.enabled,
|
|
762
968
|
disabled: busy || server.id === '',
|
|
@@ -768,8 +974,34 @@ window.__ModuleLoader__.load({
|
|
|
768
974
|
? h(
|
|
769
975
|
'div',
|
|
770
976
|
{ className: 'mcpmp-tools' },
|
|
977
|
+
h(
|
|
978
|
+
'div',
|
|
979
|
+
{
|
|
980
|
+
className:
|
|
981
|
+
'mcpmp-binding' + (boundPaths.length > 0 ? ' mcpmp-binding-bound' : ''),
|
|
982
|
+
},
|
|
983
|
+
h('span', { className: 'mcpmp-binding-label' }, t('bindTitle')),
|
|
984
|
+
boundPaths.length > 0
|
|
985
|
+
? h(
|
|
986
|
+
'span',
|
|
987
|
+
{ className: 'mcpmp-binding-paths' },
|
|
988
|
+
boundPaths.map(function (path) {
|
|
989
|
+
return h('code', { key: path, title: path }, path);
|
|
990
|
+
}),
|
|
991
|
+
)
|
|
992
|
+
: h('span', { className: 'mcpmp-binding-all' }, t('bindScopeAll')),
|
|
993
|
+
),
|
|
771
994
|
tools.length === 0
|
|
772
|
-
? h(
|
|
995
|
+
? h(
|
|
996
|
+
'div',
|
|
997
|
+
{ className: 'mcpmp-tools-empty' },
|
|
998
|
+
// Once the handshake is confirmed the old "may be
|
|
999
|
+
// disconnected" hint is misleading, and so is the warning
|
|
1000
|
+
// tone: say plainly that the server exposes nothing.
|
|
1001
|
+
connectionState === 'connected'
|
|
1002
|
+
? t('noToolsConnected')
|
|
1003
|
+
: t('noTools'),
|
|
1004
|
+
)
|
|
773
1005
|
: tools.map(function (tool) {
|
|
774
1006
|
return h(
|
|
775
1007
|
'div',
|
|
@@ -1052,6 +1284,101 @@ window.__ModuleLoader__.load({
|
|
|
1052
1284
|
);
|
|
1053
1285
|
}
|
|
1054
1286
|
|
|
1287
|
+
/**
|
|
1288
|
+
* The project-binding editor for one server.
|
|
1289
|
+
*
|
|
1290
|
+
* Paths are typed one per line rather than chosen from a directory picker:
|
|
1291
|
+
* a browser file picker cannot hand back an absolute path, and the directory
|
|
1292
|
+
* a user wants to bind is usually not one they can reach from a picker
|
|
1293
|
+
* anyway. The host validates every line and refuses the whole write when one
|
|
1294
|
+
* is relative, so a typo cannot half-apply.
|
|
1295
|
+
*/
|
|
1296
|
+
function BindingDialog(props) {
|
|
1297
|
+
var t = props.t;
|
|
1298
|
+
var server = props.server;
|
|
1299
|
+
var existing =
|
|
1300
|
+
server.binding && Array.isArray(server.binding.paths) ? server.binding.paths : [];
|
|
1301
|
+
var [text, setText] = useState(function () {
|
|
1302
|
+
return existing.join('\n');
|
|
1303
|
+
});
|
|
1304
|
+
var [error, setError] = useState(null);
|
|
1305
|
+
var [busy, setBusy] = useState(false);
|
|
1306
|
+
|
|
1307
|
+
function submit() {
|
|
1308
|
+
if (busy) return;
|
|
1309
|
+
var paths = text
|
|
1310
|
+
.split('\n')
|
|
1311
|
+
.map(function (line) {
|
|
1312
|
+
return line.trim();
|
|
1313
|
+
})
|
|
1314
|
+
.filter(function (line) {
|
|
1315
|
+
return line !== '';
|
|
1316
|
+
});
|
|
1317
|
+
setBusy(true);
|
|
1318
|
+
setError(null);
|
|
1319
|
+
api('bind', { serverName: server.serverName, paths: paths })
|
|
1320
|
+
.then(function (result) {
|
|
1321
|
+
setBusy(false);
|
|
1322
|
+
props.onDone(result);
|
|
1323
|
+
})
|
|
1324
|
+
.catch(function (failure) {
|
|
1325
|
+
setBusy(false);
|
|
1326
|
+
setError(String((failure && failure.message) || failure));
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
return h(
|
|
1331
|
+
Modal,
|
|
1332
|
+
{
|
|
1333
|
+
title: t('bindTitle') + ' · ' + server.serverName,
|
|
1334
|
+
closeLabel: t('close'),
|
|
1335
|
+
onClose: props.onClose,
|
|
1336
|
+
footer: h(
|
|
1337
|
+
'div',
|
|
1338
|
+
{
|
|
1339
|
+
style: {
|
|
1340
|
+
display: 'flex',
|
|
1341
|
+
alignItems: 'center',
|
|
1342
|
+
justifyContent: 'space-between',
|
|
1343
|
+
width: '100%',
|
|
1344
|
+
gap: 12,
|
|
1345
|
+
},
|
|
1346
|
+
},
|
|
1347
|
+
h('span', { className: 'mcpmp-note', style: { fontSize: 11, padding: '5px 8px' } }, t('bindNote')),
|
|
1348
|
+
h(
|
|
1349
|
+
'div',
|
|
1350
|
+
{ style: { display: 'flex', gap: 8 } },
|
|
1351
|
+
h('button', { type: 'button', className: 'mcpmp-btn', onClick: props.onClose }, t('cancel')),
|
|
1352
|
+
h(
|
|
1353
|
+
'button',
|
|
1354
|
+
{ type: 'button', className: 'mcpmp-btn mcpmp-btn-primary', disabled: busy, onClick: submit },
|
|
1355
|
+
busy ? t('saving') : t('confirm'),
|
|
1356
|
+
),
|
|
1357
|
+
),
|
|
1358
|
+
),
|
|
1359
|
+
},
|
|
1360
|
+
h('p', null, t('bindHint')),
|
|
1361
|
+
h(
|
|
1362
|
+
'div',
|
|
1363
|
+
{ className: 'mcpmp-field' },
|
|
1364
|
+
h('label', { htmlFor: 'mcpmp-bind-paths' }, t('bindPathsLabel')),
|
|
1365
|
+
h('textarea', {
|
|
1366
|
+
id: 'mcpmp-bind-paths',
|
|
1367
|
+
className: 'mcpmp-textarea',
|
|
1368
|
+
rows: 6,
|
|
1369
|
+
spellCheck: false,
|
|
1370
|
+
value: text,
|
|
1371
|
+
placeholder: 'D:\\work\\my-project\n~/work/another-project',
|
|
1372
|
+
onChange: function (event) {
|
|
1373
|
+
setText(event.target.value);
|
|
1374
|
+
},
|
|
1375
|
+
}),
|
|
1376
|
+
h('small', null, t('bindPathsHint') + ' ' + t('bindLoadHint')),
|
|
1377
|
+
),
|
|
1378
|
+
error !== null ? h('div', { className: 'mcpmp-note mcpmp-note-error' }, error) : null,
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1055
1382
|
/** The add/edit form for one server. */
|
|
1056
1383
|
function ServerFormDialog(props) {
|
|
1057
1384
|
var t = props.t;
|
|
@@ -1455,6 +1782,9 @@ window.__ModuleLoader__.load({
|
|
|
1455
1782
|
onEdit: function () {
|
|
1456
1783
|
setDialog({ kind: 'form', server: server });
|
|
1457
1784
|
},
|
|
1785
|
+
onBind: function () {
|
|
1786
|
+
setDialog({ kind: 'bind', server: server });
|
|
1787
|
+
},
|
|
1458
1788
|
});
|
|
1459
1789
|
}),
|
|
1460
1790
|
);
|
|
@@ -1604,6 +1934,27 @@ window.__ModuleLoader__.load({
|
|
|
1604
1934
|
: undefined,
|
|
1605
1935
|
})
|
|
1606
1936
|
: null,
|
|
1937
|
+
|
|
1938
|
+
// Binding never touches the loader tree, so the state the host returns
|
|
1939
|
+
// is already final — no `settle()` poll is needed here.
|
|
1940
|
+
dialog !== null && dialog.kind === 'bind'
|
|
1941
|
+
? h(BindingDialog, {
|
|
1942
|
+
t: t,
|
|
1943
|
+
server: dialog.server,
|
|
1944
|
+
onClose: function () {
|
|
1945
|
+
setDialog(null);
|
|
1946
|
+
},
|
|
1947
|
+
onDone: function (result) {
|
|
1948
|
+
setDialog(null);
|
|
1949
|
+
if (result && result.state) setState({ status: 'ready', data: result.state, error: null });
|
|
1950
|
+
setNotice(
|
|
1951
|
+
(result && result.action === 'cleared' ? t('bindUnbound') : t('bindSaved')) +
|
|
1952
|
+
':' +
|
|
1953
|
+
((result && result.serverName) || ''),
|
|
1954
|
+
);
|
|
1955
|
+
},
|
|
1956
|
+
})
|
|
1957
|
+
: null,
|
|
1607
1958
|
);
|
|
1608
1959
|
}
|
|
1609
1960
|
|