dsh-plugin-mcp-toggles 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +62 -46
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,55 +1,41 @@
1
1
  # dsh-plugin-mcp-toggles
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/dsh-plugin-mcp-toggles.svg)](https://www.npmjs.com/package/dsh-plugin-mcp-toggles)
4
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-plugin-mcp-toggles.svg)](https://www.npmjs.com/package/dsh-plugin-mcp-toggles)
4
5
  [![license](https://img.shields.io/npm/l/dsh-plugin-mcp-toggles.svg)](LICENSE)
5
6
  [![node](https://img.shields.io/node/v/dsh-plugin-mcp-toggles.svg)](package.json)
6
7
 
7
8
  为**每个会话**单独开关已安装的 MCP 服务器。
8
9
 
9
- ## 它解决什么
10
-
11
- MCP 服务器在 DSH profile 里是进程级的:`@deepseek-ai/dsh-mcp-client` 每行连一个
12
- 服务器,把 `mcp__<serverName>__<tool>` 注册进**全局**工具层。于是每个会话都看到
13
- 同一批 MCP 工具 —— 想让 A 会话只用 REA、B 会话只用别的服务器,原生做不到。
14
-
15
- 装上本插件后:会话标题栏右侧出现一个 **MCP** 按钮,点开列出已安装的 MCP 服务器,
16
- 每行一个开关,**只影响当前会话**。新会话默认全部开启(装上插件不会悄悄改变任何
17
- 人现有的能力)。
10
+ 装好之后,会话标题栏右侧(新会话页则是输入卡片上方那一行)会出现一个 **MCP**
11
+ 按钮,点开列出已安装的 MCP 服务器,每行一个开关,**只影响当前会话**。
18
12
 
19
13
  ## 安装
20
14
 
21
- 这是一个标准的 DSH bundle 包:`package.json` 里用 `dsh.bundle.patch` 声明要插入的
22
- 插件行,用 `dsh.client` 声明 Web 端入口,没有依赖、没有构建步骤,装上即可用。
15
+ 用 DSH 自带的插件命令,装进你要用的 profile:
23
16
 
24
- 从 npm 装进当前 profile:
25
-
26
- ```
27
- plugin_manager action=install_bundle target=dsh-plugin-mcp-toggles
17
+ ```bash
18
+ dsh plugin --profile web add dsh-plugin-mcp-toggles
28
19
  ```
29
20
 
30
- `target` 接受任意安装 spec:
21
+ 把 `web` 换成你的 profile 名(`desktop`、`tui`、`headless` 等)。这条命令会
22
+ 把它加入该 profile 的依赖与 bundle 列表,然后重启 DSH 即可。
31
23
 
32
- ```
33
- plugin_manager action=install_bundle target=dsh-plugin-mcp-toggles@0.1.0
34
- plugin_manager action=install_bundle target=github:ZhaoHanshao/dsh-plugin-mcp-toggles
35
- ```
24
+ 指定版本或改用 GitHub 源:
36
25
 
37
- 装好后重启 DSH,打开任意会话即可看到按钮。
26
+ ```bash
27
+ dsh plugin --profile web add dsh-plugin-mcp-toggles@0.1.0
28
+ dsh plugin --profile web add github:ZhaoHanshao/dsh-plugin-mcp-toggles
29
+ ```
38
30
 
39
- 想先读代码或自己打包检查文件清单:
31
+ 卸载:
40
32
 
41
33
  ```bash
42
- npm install dsh-plugin-mcp-toggles
43
- npm pack dsh-plugin-mcp-toggles --dry-run # 只打印将要发布的文件
34
+ dsh plugin --profile web remove dsh-plugin-mcp-toggles
44
35
  ```
45
36
 
46
- 它需要宿主提供 `webServer` 服务与 `conversation.session.header.utilities` /
47
- `conversation.hero.options` 两个槽位,因此要求 DSH 版本不低于它开发时的
48
- `@deepseek-ai/dsh-client-ui-conversation`(运行时 **0.2.1-rc.3**)。这条约束写进了
49
- `peerDependencies`,但标记为可选 —— DSH 把这些包内置在自己的安装目录里,普通 npm
50
- 安装不该为它再拉一份副本。
51
-
52
- Node 版本要求 `^22.19.0 || >=24.0.0`,与 DSH 官方下限一致。
37
+ > 在 DSH 会话里,也可以让 agent 用 `plugin_manager action=install_bundle
38
+ > target=dsh-plugin-mcp-toggles` 完成同样的安装。
53
39
 
54
40
  ## 用法
55
41
 
@@ -59,29 +45,39 @@ Node 版本要求 `^22.19.0 || >=24.0.0`,与 DSH 官方下限一致。
59
45
 
60
46
  按钮上的徽标显示当前状态:`全部开启`、`n/m`、`全部关闭`;部分关闭时按钮转为警示色。
61
47
 
62
- ## 两个入口,同一个开关集合
48
+ 开关立即生效,无需重启会话或重开服务器。
63
49
 
64
- | 槽位 | 出现位置 |
65
- |---|---|
66
- | `conversation.session.header.utilities` | 已有会话的标题栏右侧 |
67
- | `conversation.hero.options` | 新会话落地页,紧跟 workspace 与模式控件之后 |
50
+ ## 它解决什么
68
51
 
69
- 两处**必须都有**:新会话页的会话页头带 `hideChrome`
70
- (`blank && composerPhase === 'blank'`,见 `ConversationSession.tsx`),此时整个
71
- header 都不渲染,只挂标题栏会让按钮在新会话页上完全消失。两个槽都提供同一个
72
- `sessionId`,所以在哪一处切换都是同一个会话的开关 —— 在新会话页关掉的服务器,
73
- 进入对话后依然关着。
52
+ MCP 服务器在 DSH profile 里是进程级的:`@deepseek-ai/dsh-mcp-client` 每行连一个
53
+ 服务器,把 `mcp__<serverName>__<tool>` 注册进**全局**工具层。于是每个会话都看到
54
+ 同一批 MCP 工具 —— 想让 A 会话只用 REA、B 会话只用别的服务器,原生做不到。
55
+
56
+ 本插件把这份「全局可见」变成「按会话可见」。**新会话默认全部开启**,所以装上它
57
+ 不会悄悄改变任何人现有的能力;只有你亲手关掉的服务器才会在该会话里消失。
74
58
 
75
59
  ## 它怎么工作
76
60
 
77
- `agent.ctx.tools.restrict({ deny })` 是**作用域内**生效的全局工具掩码
78
- (`packages/core/tools/src/index.ts`)。可见性、schema 投影与派发都走同一个解析器,
79
- 因此被关掉的工具模型既看不到也调不到,其他会话不受影响。
61
+ `agent.ctx.tools.restrict({ deny })` 是**作用域内**生效的全局工具掩码。可见性、
62
+ schema 投影与派发都走同一个解析器,因此被关掉的工具模型既看不到也调不到,其他
63
+ 会话完全不受影响。
80
64
 
81
65
  - 关闭某服务器 → 把它的 `mcp__<server>__*` 工具加进该会话的 deny 集。
82
66
  - 全部服务器都关闭时,共享的 `list_mcp_resources` 等资源工具一并隐藏
83
67
  (`sharedResourceTools: false` 可关掉这个联动)。
84
- - 开关立即生效,无需重启会话或重开服务器。
68
+ - 掩码按 deny 指纹幂等:工具集变化时只重算、不重复叠加。
69
+
70
+ ## 两个入口,同一个开关集合
71
+
72
+ | 槽位 | 出现位置 |
73
+ |---|---|
74
+ | `conversation.session.header.utilities` | 已有会话的标题栏右侧 |
75
+ | `conversation.hero.options` | 新会话落地页,紧跟 workspace 与模式控件之后 |
76
+
77
+ 两处**必须都有**:新会话页的会话页头带 `hideChrome`
78
+ (`blank && composerPhase === 'blank'`),此时整个 header 都不渲染,只挂标题栏会让
79
+ 按钮在新会话页上完全消失。两个槽都提供同一个 `sessionId`,所以在哪一处切换都是
80
+ 同一个会话的开关 —— 在新会话页关掉的服务器,进入对话后依然关着。
85
81
 
86
82
  ## 开关存在哪
87
83
 
@@ -96,16 +92,36 @@ header 都不渲染,只挂标题栏会让按钮在新会话页上完全消失
96
92
 
97
93
  ## 配置
98
94
 
99
- `cordis.patch.yml` 的行配置:
95
+ 在 profile 的 `cordis.patch.yml` 里覆盖 `mcp-toggles` 这一行的 `config`:
100
96
 
101
97
  | 字段 | 默认 | 含义 |
102
98
  |---|---|---|
103
99
  | `sharedResourceTools` | `true` | 关闭全部 MCP 时是否连共享资源工具一起隐藏。 |
104
100
  | `extraServers` | `[]` | 额外要认作 MCP 服务器的名字;用于服务器暂时没有注册任何工具时也能列出来。 |
105
101
 
102
+ ## 兼容性
103
+
104
+ - **DSH**:需要 `@deepseek-ai/dsh-client-ui-conversation` ≥ `0.2.1-rc.3`
105
+ (提供上述两个槽位与 `webServer` 服务)。这条写进了 `peerDependencies` 并标记为
106
+ 可选 —— DSH 把这些包内置在安装目录里,普通 npm 安装不该再拉一份副本。
107
+ - **Node**:`^22.19.0 || >=24.0.0`,与 DSH 官方下限一致。
108
+
106
109
  ## 已知限制
107
110
 
108
111
  - 只管理 **MCP** 工具(`mcp__*` 前缀与共享资源工具),不动其他工具。
109
112
  - 服务器列表来自 `configEditor.entries()` 里的 `@deepseek-ai/dsh-mcp-client` 行;
110
113
  `configEditor` 不可用时退回当前工具名前缀,此时**没有工具**的服务器不会出现在列表里。
111
114
  - 开关按会话 id 保存;会话被删除后对应记录会保留(无害,不会影响其他会话)。
115
+
116
+ ## 开发
117
+
118
+ 没有依赖、没有构建步骤,`lib/` 就是发布内容。改完直接检查:
119
+
120
+ ```bash
121
+ npm run prepublishOnly # node --check 两个入口
122
+ npm pack --dry-run # 查看将要发布的文件
123
+ ```
124
+
125
+ ## License
126
+
127
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-mcp-toggles",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "Turn installed MCP servers on or off per conversation, from a picker in the session header.",
6
6
  "keywords": [