refactor(mcp): extract the MCP bundle boundary (host seam + client banner)
This commit is contained in:
parent
8e5145349d
commit
0412095635
|
|
@ -33,8 +33,12 @@ window.__ModuleLoader__.load({
|
|||
migrate: '/dsh-brain/migrate',
|
||||
}
|
||||
|
||||
// ---- MCP bundle (browser bridge) ---------------------------------------
|
||||
// The MCP bridge is another plugin's public surface, not ours: it is probed
|
||||
// at runtime and the tab reports a capability gap when it is missing.
|
||||
// This bundle owns the tab, the request envelope, the probe timeout and
|
||||
// the host-unavailable state; connections, credentials, tool management
|
||||
// and any cloud-side sync belong to the host dsh-mcp-connector plugin.
|
||||
var MCP_BRIDGE = '/mcp-connector/api'
|
||||
var MCP_PANEL = '/mcp-connector/ui'
|
||||
var POLL_MS = 10000
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* MCP bundle — the host half of the MCP management tab.
|
||||
*
|
||||
* In this package the MCP feature is a browser bridge, nothing more: the
|
||||
* client tab talks to the host `dsh-mcp-connector` plugin over
|
||||
* `/mcp-connector/api`, wrapping one JSON envelope per call, a fixed probe
|
||||
* timeout and an explicit host-unavailable state. Connections, credentials
|
||||
* and tool management belong to the host plugin; this bundle never stores
|
||||
* them and never syncs MCP configuration to the cloud.
|
||||
*/
|
||||
/**
|
||||
* The MCP bridge capability fragment owned by this bundle. `capabilities()`
|
||||
* in routes.ts aggregates it with the rest of the build's report; the MCP
|
||||
* text lives here so the bundle keeps its own surface in one place.
|
||||
*/
|
||||
export function mcpCapability() {
|
||||
return {
|
||||
bridge: 'host-plugin',
|
||||
notes: [
|
||||
'MCP 管理由宿主 dsh-mcp-connector 插件提供,本卡通过其公开接口读写,不另建凭据库。',
|
||||
'MCP 工具可见性与会话级激活分属两层:本卡展示连接与工具缓存,会话级“选择精确工具后激活”由宿主 session-tools 负责,本卡不伪造激活。',
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import { brainStatus, migrateLegacyFiles } from "./brain-migration.js";
|
|||
import { SkillGroupError } from "./skill-groups.js";
|
||||
import { renderSkillsPage } from "./skill-page.js";
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { mcpCapability } from "./mcp.js";
|
||||
/** Route constants — kept in one place so the client half can reuse them. */
|
||||
export const ROUTES = {
|
||||
page: '/dsh-brain',
|
||||
|
|
@ -26,6 +27,7 @@ const MAX_BODY_BYTES = 64 * 1024;
|
|||
/** What this build actually implements, stated per feature. */
|
||||
function capabilities(deps) {
|
||||
const marketProviders = deps.market?.list().length ?? 0;
|
||||
const mcp = mcpCapability();
|
||||
return {
|
||||
version: deps.version,
|
||||
features: {
|
||||
|
|
@ -41,9 +43,7 @@ function capabilities(deps) {
|
|||
syncResolve: deps.sync !== undefined,
|
||||
multiClient: deps.clients !== undefined,
|
||||
brainMigration: 'ready',
|
||||
// The MCP bridge is provided by the host `dsh-mcp-connector` plugin over
|
||||
// the same origin; the browser half probes it at runtime.
|
||||
mcpBridge: 'host-plugin',
|
||||
mcpBridge: mcp.bridge,
|
||||
},
|
||||
notes: [
|
||||
...(deps.market === undefined
|
||||
|
|
@ -54,8 +54,7 @@ function capabilities(deps) {
|
|||
: ['更新/回退仅对带来源记录(.skill-source.json)的技能生效,更新前自动备份。']),
|
||||
...(deps.sync === undefined ? [] : ['同步冲突可在技能页签逐项“保留本地 / 采用云端 / 手动合并”。']),
|
||||
...(deps.clients === undefined ? [] : ['跨软件与工作区技能清单为只读(DSH 之外不写目录);dsh-brain 数据迁移已就绪,实际改名需部署重启。']),
|
||||
'MCP 管理由宿主 dsh-mcp-connector 插件提供,本卡通过其公开接口读写,不另建凭据库。',
|
||||
'MCP 工具可见性与会话级激活分属两层:本卡展示连接与工具缓存,会话级“选择精确工具后激活”由宿主 session-tools 负责,本卡不伪造激活。',
|
||||
...mcp.notes,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* MCP bundle — the host half of the MCP management tab.
|
||||
*
|
||||
* In this package the MCP feature is a browser bridge, nothing more: the
|
||||
* client tab talks to the host `dsh-mcp-connector` plugin over
|
||||
* `/mcp-connector/api`, wrapping one JSON envelope per call, a fixed probe
|
||||
* timeout and an explicit host-unavailable state. Connections, credentials
|
||||
* and tool management belong to the host plugin; this bundle never stores
|
||||
* them and never syncs MCP configuration to the cloud.
|
||||
*/
|
||||
|
||||
/** What the capabilities card reports about the MCP bridge. */
|
||||
export interface McpCapability {
|
||||
/** `host-plugin` when the tab is served against the host bridge. */
|
||||
bridge: 'host-plugin' | 'unavailable'
|
||||
/** Card-level notes shown under the capability list. */
|
||||
notes: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* The MCP bridge capability fragment owned by this bundle. `capabilities()`
|
||||
* in routes.ts aggregates it with the rest of the build's report; the MCP
|
||||
* text lives here so the bundle keeps its own surface in one place.
|
||||
*/
|
||||
export function mcpCapability(): McpCapability {
|
||||
return {
|
||||
bridge: 'host-plugin',
|
||||
notes: [
|
||||
'MCP 管理由宿主 dsh-mcp-connector 插件提供,本卡通过其公开接口读写,不另建凭据库。',
|
||||
'MCP 工具可见性与会话级激活分属两层:本卡展示连接与工具缓存,会话级“选择精确工具后激活”由宿主 session-tools 负责,本卡不伪造激活。',
|
||||
],
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,7 @@ import { SkillGroupError } from './skill-groups.ts'
|
|||
import type { SkillGroupManager } from './skill-groups.ts'
|
||||
import { renderSkillsPage } from './skill-page.ts'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { mcpCapability } from './mcp.ts'
|
||||
|
||||
/** Route constants — kept in one place so the client half can reuse them. */
|
||||
export const ROUTES = {
|
||||
|
|
@ -109,6 +110,7 @@ export interface CapabilityReport {
|
|||
/** What this build actually implements, stated per feature. */
|
||||
function capabilities(deps: RouteDeps): CapabilityReport {
|
||||
const marketProviders = deps.market?.list().length ?? 0
|
||||
const mcp = mcpCapability()
|
||||
return {
|
||||
version: deps.version,
|
||||
features: {
|
||||
|
|
@ -124,9 +126,7 @@ function capabilities(deps: RouteDeps): CapabilityReport {
|
|||
syncResolve: deps.sync !== undefined,
|
||||
multiClient: deps.clients !== undefined,
|
||||
brainMigration: 'ready',
|
||||
// The MCP bridge is provided by the host `dsh-mcp-connector` plugin over
|
||||
// the same origin; the browser half probes it at runtime.
|
||||
mcpBridge: 'host-plugin',
|
||||
mcpBridge: mcp.bridge,
|
||||
},
|
||||
notes: [
|
||||
...(deps.market === undefined
|
||||
|
|
@ -137,8 +137,7 @@ function capabilities(deps: RouteDeps): CapabilityReport {
|
|||
: ['更新/回退仅对带来源记录(.skill-source.json)的技能生效,更新前自动备份。']),
|
||||
...(deps.sync === undefined ? [] : ['同步冲突可在技能页签逐项“保留本地 / 采用云端 / 手动合并”。']),
|
||||
...(deps.clients === undefined ? [] : ['跨软件与工作区技能清单为只读(DSH 之外不写目录);dsh-brain 数据迁移已就绪,实际改名需部署重启。']),
|
||||
'MCP 管理由宿主 dsh-mcp-connector 插件提供,本卡通过其公开接口读写,不另建凭据库。',
|
||||
'MCP 工具可见性与会话级激活分属两层:本卡展示连接与工具缓存,会话级“选择精确工具后激活”由宿主 session-tools 负责,本卡不伪造激活。',
|
||||
...mcp.notes,
|
||||
],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue