fix(gateway): 卸载拒绝话术按接入路径分流(.env 接入的 server 不再指向 MCP 页)
复审 M30-p2-1(r1):`plugin_uninstall_scope` 的 400 一律让主人「去『MCP 服务器』页
卸载」,但 `.env` 的 MCP_SERVERS_JSON 启动期接入的 server **不经**插件管理器、
不在 plugins.json 里,MCP 页(= Manager.Statuses()/List())根本看不到它 ⇒ 那条指引
对该路径是假指引。
- 新增 `plugin.(Manager) MCPServerName`:`mcp:<server>` 注册键 → server 名的**唯一**
解析口(前缀只在 manager.go 出现一次),网关不再自己拼前缀。
- `serverScopedUninstall` 改为 `*Server` 方法,文案经 `uninstallPointer` 分流:
· 管理器托管(落在 plugins.json,判据 `Manager.List()`)⇒ 保留「请在『MCP 服务器』
页启停或卸载该 server」;
· 否则 ⇒ 明说该 server 由 .env 的 MCP_SERVERS_JSON 在启动时接入、面板不管理它,
并给出可操作步骤(改 .env 里那一项:删掉或设 enabled=false,改完需重启生效)。
接入路径判据来自**管理器持久清单**,不是名字前缀/transport 推断。
- `mcp:<server>` 登记条目同样分流(此前也一律指向 MCP 页)。
测试(gateway):plugins.json 路径断言含「MCP 服务器」页字样且不提 MCP_SERVERS_JSON;
.env 路径(工具与登记条目各一条)断言含 MCP_SERVERS_JSON 且**不含**「MCP 服务器」
字样;三条均断言 400 + `plugin_uninstall_scope` 不变、被拒后条目仍在。
修前红:两条 .env 用例(见回报);修后绿。回归 go build/vet/test 全绿。
This commit is contained in:
1 parent
86aef7b454
commit
c608dd4afb
3 files changed
+157
-10
No files matched your search
@@ -33,6 +33,19 @@ const (
|
||||
mcpCapabilityPrefix = "mcp:"
|
||||
)
|
||||
|
||||
// MCPServerName 从 `mcp:<server>` 登记条目的注册键里取出 server 名。
|
||||
// 第二个返回值为 false 表示这不是一条 KindMCP 登记条目的键(或者 server 名为空)。
|
||||
//
|
||||
// 它是**注册键格式**的唯一真相(`mcpCapabilityPrefix` 只在这里出现),因此网关在需要
|
||||
// 「这条登记条目是哪台 server」时应当调它,而不是自己在别处再拼一遍前缀。
|
||||
func MCPServerName(capName string) (string, bool) {
|
||||
server, ok := strings.CutPrefix(capName, mcpCapabilityPrefix)
|
||||
if !ok || server == "" {
|
||||
return "", false
|
||||
}
|
||||
return server, true
|
||||
}
|
||||
|
||||
// Installed is one plugin as reported to the admin API: its persisted config,
|
||||
// whether a live server currently backs it, and how many tools it registered.
|
||||
type Installed struct {
|
||||
|
||||
Reference in new issue
Block a user