DSH / Atlas
2026-11-04implementedfeature

Custom MCP servers in the Connectors tab

“连接器”标签中的自定义 MCP 服务器

People add MCP servers by editing the profile's composition, and the Plugins page shows none of the servers declared there. Each server is one [server row](../architecture/2026-11-24-mcp-manager-server-rows.md) of the [MCP manager](../../../../packages/mcp/mcp-manager/README.md), which resolves secrets through credential references, probes a server, and authorizes OAuth servers; what is missing is a page that adds, e

English

Problem

People add MCP servers by editing the profile's composition, and the Plugins page shows none of the servers declared there. Each server is one server row of the MCP manager, which resolves secrets through credential references, probes a server, and authorizes OAuth servers; what is missing is a page that adds, edits, switches, and removes those rows and shows an OAuth server's account. A local stdio server runs a command on the Host with the person's permissions, so letting a browser define one needs an explicit decision.

Decision

The Connectors tab lists the MCP server rows of the profile's composition and changes them through its Host service's connectors Remote. A server added in the tab is a row of the profile patch, the declaration a hand edit writes, so the tab keeps no store of its own. The service runs each save, removal, and switch as one operation that stops at the first refused step. It writes a row with the configuration editor's insert(), editRow(), and remove() and switches one with the plugin manager's setPluginEnabled, so the profile lock, the precedence of higher layers, and the reconciliation of the running composition apply unchanged.

A save of a server that is switched on must leave its row running. When the row does not start with the saved config, the editor restores the profile patch and the save reports the row's failure, so whatever the manager refuses at registration reaches the form. A server that is switched off is validated with the row plugin's Config and written without starting; what only the manager refuses shows when the server is switched on.

The list is read from the composition, because the manager's list() holds registered servers only: it omits a row that is switched off or did not start, and it includes each connector's server, which has no row. Each listed row carries whether it is off, runs, or did not start, with the reason. The Host service streams the list with a revision, a digest of the rows, at subscription and after each app-boot/config-reload, each plugin-manager/changed, and each change of its own. A change names the revision it was made on, and a stale one is refused.

Bearer tokens and secret header or environment rows go to the credentials service under MCP_<NAME>_<FIELD> references, and the row stores only the ${credential:REF} template. Removing a server removes its OAuth grant and deletes the secrets it owned, and a saved edit writes the row before storing the secrets entered in it and deletes the references the row stopped using; neither deletes a reference another row still uses, whether that row is on or off. The manager signs out a server that is on. For a server that is off or did not start, which the manager does not hold, the service deletes the record that the row's oauth.credentialKey names from credentials, unless another row names the same record or the name of a server the manager holds forms its key: a connector's server keeps its grant under mcp-client/<name>. Test connection and the account section need the manager's server, so they appear only while the server is on.

The tab offers stdio servers. Before a local command starts, a risk confirmation names the command and states that it runs on this computer with the person's permissions, outside the sandbox: when a local command is saved, unless its server is switched off, and when a local command is switched on. Custom servers are not connectors: they are rows of the profile and keep running while the Connectors bundle is off.

The Host service registers each OAuth server row that is on with dsh-mcp-account under the key mcp:<name>, without a bundle package, and with copy that names the server, so its account's display and operations come from the Host like a connector's. Its status in its list row, and its account section on its page, render through the connector.account Factory of ui-connector-account.

Alternatives considered

A store or a patch writer of the tab's own. A second store of servers needs a precedence rule against the rows of the composition. A second writer of the profile patch repeats the configuration editor's lock, its refusal of a write that a higher layer overrides, and its reconciliation of the running composition, so the row operations are the editor's.

A validation method on the manager. It would have one caller, and a row could still be refused between the validation and its registration. Writing the row, waiting for it to start, and restoring the file when it does not start reports the refusal of the registration itself.

Listing from the manager. list() would need the switched-off rows, which the manager does not hold, and a field that tells a row's server from a plugin's, both for this one caller.

Registering the accounts from the row plugin. The manager package would depend on dsh-mcp-account, which depends on the manager, and the copy that names the server belongs to Connectors.

No stdio from the browser. Local servers are a main reason to add a custom server, and Desktop runs its page on the Host computer; the confirmation names the command instead.

Writing from the browser. The browser would need the configuration editor's row operations as Remote methods and would run them in turn with the secret writes and the removal of the grant. Removing a grant is account logic, the manager offers sign-out only to Host callers, and the order and the first refusal belong in one operation.

A browser mirror of the manager's servers. Mapping each manager view to an account in the browser repeats the Host's account presentation and needs the manager's authorization methods as Remote operations; registering the accounts on the Host reuses the MCP account service and the connector account registry.

Accounts for servers without OAuth. Their rows could show the manager's connection status as an account with only Retry, but such a server has no account; its page's connection test shows whether it connects.

A separate account block in the Connectors tab. It would duplicate the attempt handling, authorization page opening, and notices of the connector accounts.

Consequences

A browser that reaches the owner-only connectors Remote can make the Host run a command; the Connectors tab is the page that offers it, and it confirms first. The list sends each row's config to the owner's browser as written, so a secret that a composition file holds as a plain value appears in the form. The Loader evaluates a !!js expression in a row's config when the row starts, so the service refuses a header or environment row named __jsExpr, the key that marks an expression, and lists a row that holds an expression as one the form cannot read.

A row that a layer other than the profile patch adds, such as a bundle, can be edited and switched off but not removed, because a patch has no item that removes another layer's row. A custom server cannot share its name with a server that a loaded connector registers: the manager refuses the second registration of a name, so a save under that name is refused, and when such a connector loads beside an existing custom server, whichever of the two registers second does not start. Both would keep their OAuth grant under mcp-client/<name>. An OAuth server whose row names no credential key gets mcp-client/<name>, so its name must fit a credential key segment: lowercase letters, digits, and -, starting with a letter. A row that names its credential key keeps it through an edit, and its name is not limited that way. Server names that differ only in case, -, or _ are refused, because they would share a credential reference, as are header or environment names of one server that map to one reference; so is a save whose own MCP_<NAME>_ references another row uses.

中文

问题

用户要添加 MCP 服务器,只能编辑 profile 的组合配置,而插件页上看不到在那里声明的任何服务器。每个服务器是一个服务器行,由 MCP 管理器管理;管理器通过凭据引用解析密钥,能探测服务器,也能为 OAuth 服务器完成授权。缺少的是一个添加、编辑、开关和删除这些行,并显示 OAuth 服务器账号的页面。本地 stdio 服务器会以用户权限在 Host 上运行命令,所以是否允许浏览器定义这类服务器,需要明确决定。

决策

“连接器”标签列出 profile 组合中的 MCP 服务器行,并通过它的 Host 服务提供的 connectors Remote 修改它们。在标签中添加的服务器是 profile 补丁中的一行,和手工编辑写出的声明相同,所以标签没有自己的存储。该服务把每次保存、删除和开关作为一次操作执行,遇到第一个被拒绝的步骤即停止。它用配置编辑器的 insert()、editRow() 和 remove() 写入行,用插件管理器的 setPluginEnabled 开关行,profile 锁、更高组合层的优先级和对运行中组合的协调因此原样生效。

保存已开启的服务器之后,它的行必须在运行。行用保存的配置无法启动时,编辑器恢复 profile 补丁,保存报告这一行的失败原因,所以管理器在注册时拒绝的内容都会反映到表单上。关闭的服务器用行插件的 Config 校验,写入但不启动;只有管理器才会拒绝的内容,要到开启服务器时才显示。

列表从组合中读取,因为管理器的 list() 只包含已注册的服务器:它不含关闭的行和未能启动的行,却包含每个连接器的服务器,而连接器的服务器没有行。列表中的每一行带有它是关闭、在运行还是未能启动,以及未能启动的原因。Host 服务以流的形式提供列表和它的 revision(各行的摘要):订阅时发送一次,此后在每次 app-boot/config-reload、每次 plugin-manager/changed 和它自己的每次修改之后再次发送。每次修改带上它所依据的 revision,过期的 revision 会被拒绝。

Bearer 令牌以及标为密钥的请求头或环境变量行保存在凭据服务中,引用名为 MCP_<名称>_<字段>,行里只保存 ${credential:REF} 模板。删除服务器会删除它的 OAuth 授权和它拥有的密钥;保存编辑时先写入行,再保存表单中输入的密钥,并删除这一行不再引用的密钥;两者都不会删除其他行仍在引用的密钥,无论那一行是开启还是关闭。已开启的服务器由管理器退出登录。关闭或未能启动的服务器不在管理器中,服务从凭据服务中删除它的 oauth.credentialKey 所指的记录,除非另一行指向同一条记录,或者管理器中某个服务器的名称构成了这条记录的键:连接器的服务器把授权保存在 mcp-client/<名称> 下。测试连接和账号区块需要管理器中的服务器,所以只在服务器开启期间出现。

标签允许添加 stdio 服务器。本地命令启动之前,会先显示风险确认:写明命令,并说明它会以用户权限在这台电脑上运行、不经过沙箱。确认出现在保存本地命令时(服务器处于关闭状态的除外),以及打开本地命令的开关时。自定义服务器不属于连接器:它们是 profile 的行,“连接器”bundle 关闭时仍会运行。

Host 服务把每个已开启的 OAuth 服务器行以键 mcp:<名称> 登记到 dsh-mcp-account,不带 bundle 包,文案中写出服务器名,因此它的账号显示和操作都像连接器一样来自 Host。它在列表行中的状态,以及它页面上的账号区块,都通过 ui-connector-account 的 connector.account 组件工厂渲染。

考虑过的替代方案

标签自己的存储或补丁写入器。 另设一处存放服务器,就要规定它和组合中的行谁优先。另写一个 profile 补丁的写入器,会重复配置编辑器的锁、它对被更高组合层覆盖的写入的拒绝,以及它对运行中组合的协调,所以行操作放在编辑器中。

给管理器增加校验方法。 它只有一个调用方,而且在校验和注册之间,行仍可能被拒绝。写入行、等它启动、未能启动时恢复文件,报告的就是注册本身的拒绝。

从管理器读取列表。 list() 需要加入管理器并不持有的关闭的行,还需要一个区分行的服务器和插件的服务器的字段,两者都只为这一个调用方。

由行插件登记账号。 管理器包会依赖 dsh-mcp-account,而后者依赖管理器;写出服务器名的文案也属于“连接器”。

不允许浏览器添加 stdio。 本地服务器是添加自定义服务器的主要原因之一,而 Desktop 的页面就运行在 Host 所在的电脑上;改为在确认中写明命令。

由浏览器写入。 浏览器需要配置编辑器的行操作作为 Remote 方法,并依次执行行操作、密钥写入和授权删除。但删除授权属于账号逻辑,管理器只向 Host 上的调用方提供退出登录,而且步骤顺序和第一个拒绝应当在同一次操作中处理。

在浏览器中镜像管理器的服务器。 在浏览器中把管理器的每个视图映射成账号,会重复 Host 上的账号展示逻辑,还需要把管理器的授权方法作为 Remote 操作提供;在 Host 上登记账号则复用 MCP 账号服务和连接器账号注册表。

为不使用 OAuth 的服务器也登记账号。 这样列表行可以把管理器的连接状态显示为只有“重试”的账号,但这类服务器并没有账号;它页面上的连接测试会显示能否连接。

在“连接器”标签里另写一个账号区块。 这会重复连接器账号的授权尝试处理、授权页打开和通知。

后果

能访问仅限所有者的 connectors Remote 的浏览器,能让 Host 运行命令;“连接器”标签是提供这一能力的页面,并会先请用户确认。列表把每一行的配置按原样发给所有者的浏览器,所以组合文件中以明文保存的密钥会出现在表单中。行启动时 Loader 会对行配置中的 !!js 表达式求值,所以服务拒绝名为 __jsExpr(标记表达式的键)的请求头或环境变量行,并把含有表达式的行列为表单无法读取的行。

由 profile 补丁之外的组合层(例如 bundle)添加的行可以编辑和关闭,但不能删除,因为补丁中没有用来移除其他层的行的条目。自定义服务器不能与已加载连接器注册的服务器同名:管理器拒绝同一个名称的第二次注册,所以以这个名称保存会被拒绝;这样的连接器与已有的自定义服务器一同加载时,两者中后注册的那个无法启动。两者的 OAuth 授权也都会保存在 mcp-client/<名称> 下。行没有写凭据键的 OAuth 服务器使用 mcp-client/<名称>,所以名称必须符合凭据键段的格式:小写字母、数字和 -,以字母开头。写了凭据键的行在编辑后保留该键,名称不受这一限制。只在大小写、- 和 _ 上不同的服务器名会被拒绝,因为它们会共用同一个凭据引用;同一个服务器中对应到同一个引用的请求头名或环境变量名同样会被拒绝;自身 MCP_<名称>_ 引用被其他行使用的保存也会被拒绝。