refactor(mcp): follow the ctx.mcpManager rename

The base publishes the MCP manager as `ctx.mcpManager`. Inject and call
it under that key in the account UI, list its authorization endpoints
as `mcpManager/*` in the LiveShare viewer table, and update the OAuth
and composition tests and the generated configuration catalog.
This commit is contained in:
gengruilin committed 2026-11-03 13:07:09 +08:00
1 parent ef059a2e3a
commit 07ef37ba82
10 files changed
+20 -20

No files matched your search

+1 -1
View File
@@ -4968,7 +4968,7 @@ These load from a `cordis.yml` entry with no `config:` block; they declare no co
| `@deepseek-ai/dsh-client-ui-input-trigger` | — | [`packages/client/ui-input-trigger/src/index.ts`](../packages/client/ui-input-trigger/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-jobs` | — | [`packages/client/ui-jobs/src/index.ts`](../packages/client/ui-jobs/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-layout` | — | [`packages/client/ui-layout/src/index.ts`](../packages/client/ui-layout/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-mcp-account` | `mcpServers` | [`packages/client/ui-mcp-account/src/index.ts`](../packages/client/ui-mcp-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-mcp-account` | `mcpManager` | [`packages/client/ui-mcp-account/src/index.ts`](../packages/client/ui-mcp-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-message-feedback` | — | [`packages/client/ui-message-feedback/src/index.ts`](../packages/client/ui-message-feedback/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-model-selection` | — | [`packages/client/ui-model-selection/src/index.ts`](../packages/client/ui-model-selection/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-open-in-app` | — | [`packages/client/ui-open-in-app/src/index.ts`](../packages/client/ui-open-in-app/src/index.ts) |
+1 -1
View File
@@ -4970,7 +4970,7 @@ export interface Config {
| `@deepseek-ai/dsh-client-ui-input-trigger` | — | [`packages/client/ui-input-trigger/src/index.ts`](../packages/client/ui-input-trigger/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-jobs` | — | [`packages/client/ui-jobs/src/index.ts`](../packages/client/ui-jobs/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-layout` | — | [`packages/client/ui-layout/src/index.ts`](../packages/client/ui-layout/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-mcp-account` | `mcpServers` | [`packages/client/ui-mcp-account/src/index.ts`](../packages/client/ui-mcp-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-mcp-account` | `mcpManager` | [`packages/client/ui-mcp-account/src/index.ts`](../packages/client/ui-mcp-account/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-message-feedback` | — | [`packages/client/ui-message-feedback/src/index.ts`](../packages/client/ui-message-feedback/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-model-selection` | — | [`packages/client/ui-model-selection/src/index.ts`](../packages/client/ui-model-selection/src/index.ts) |
| `@deepseek-ai/dsh-client-ui-open-in-app` | — | [`packages/client/ui-open-in-app/src/index.ts`](../packages/client/ui-open-in-app/src/index.ts) |
@@ -109,7 +109,7 @@ export class McpAccountsConnection {
/**
* @param ctx - the browser context carrying the Remote client.
* @param registry - the `mcpAccounts` Remote.
* @param servers - the manager's `mcpServers` Remote.
* @param servers - the manager's `mcpManager` Remote.
*/
constructor(ctx: Context, registry: McpAccountsRemote, private readonly servers: McpServersRemote) {
this.stream = ctx.remote.$stream<McpAccountsView>({
@@ -42,7 +42,7 @@ function registerAccount(
function showAccounts(ctx: Context): void {
ctx.effect(() => ctx.locale.register(NS, { zh, en, ja, es, fr, de, ru, pt }), 'mcp-account: dictionaries')
const connection = new McpAccountsConnection(ctx, ctx.remote.mcpAccounts, ctx.remote.mcpServers)
const connection = new McpAccountsConnection(ctx, ctx.remote.mcpAccounts, ctx.remote.mcpManager)
ctx.effect(() => async () => { await connection.dispose() }, 'mcp-account: connection')
ctx.effect(() => {
const shown = new Map<string, () => void>()
@@ -72,7 +72,7 @@ function showAccounts(ctx: Context): void {
*/
export async function mountMcpAccounts(ctx: Context, contribution: TypertRemoteContribution): Promise<() => Promise<void>> {
const unmount = await ctx.remote.$mount(contribution)
const ui = ctx.inject(['remote.mcpAccounts', 'remote.mcpServers', 'slots', 'locale'], showAccounts)
const ui = ctx.inject(['remote.mcpAccounts', 'remote.mcpManager', 'slots', 'locale'], showAccounts)
try { await ui } catch (error) { await ui.dispose(); await unmount(); throw error }
return async () => { await ui.dispose(); await unmount() }
}
+2 -2
View File
@@ -22,7 +22,7 @@ declare module '@deepseek-ai/cordis' {
/** Holds the registered accounts and serves them, with their servers' manager views, to the Plugins page. */
export default class McpAccounts extends TypertRemoteService {
static inject = ['mcpServers']
static inject = ['mcpManager']
private readonly accounts = new Map<string, McpAccountRegistration>()
private readonly listeners = new Set<() => void>()
@@ -77,7 +77,7 @@ export default class McpAccounts extends TypertRemoteService {
ended.addEventListener('abort', notify, { once: true })
const following = (async () => {
try {
for await (const next of this.ctx.mcpServers.watch(ended)) {
for await (const next of this.ctx.mcpManager.watch(ended)) {
servers = next
notify()
}
@@ -80,7 +80,7 @@ async function bench() {
}
new Remote()
ctx.provide('remote.mcpAccounts', { watch: vi.fn() })
ctx.provide('remote.mcpServers', { startAuthorization, cancelAuthorization: vi.fn(), signOut: vi.fn(), restart: vi.fn() })
ctx.provide('remote.mcpManager', { startAuthorization, cancelAuthorization: vi.fn(), signOut: vi.fn(), restart: vi.fn() })
const locale = new LocaleRuntime(ctx)
ctx.provide('locale', locale)
await ctx.plugin(SlotRegistry)
@@ -56,7 +56,7 @@ function manager() {
async function registry(servers = manager()) {
const ctx = new Context()
onTestFinished(async () => { await ctx.fiber.dispose() })
ctx.provide('mcpServers', servers.service)
ctx.provide('mcpManager', servers.service)
const fiber = ctx.plugin(McpAccounts)
await fiber
return { ctx, fiber, servers }
@@ -210,9 +210,9 @@ export const VIEWER_ENDPOINT_CLASSES = {
'mcpManager/probe': 'owner-only', // owner MCP server management
'mcpManager/restart': 'owner-only', // owner MCP server management
'mcpManager/watch': 'owner-only', // owner MCP server management
'mcpServers/startAuthorization': 'owner-only', // owner MCP server management
'mcpServers/cancelAuthorization': 'owner-only', // owner MCP server management
'mcpServers/signOut': 'owner-only', // owner MCP server management
'mcpManager/startAuthorization': 'owner-only', // owner MCP server management
'mcpManager/cancelAuthorization': 'owner-only', // owner MCP server management
'mcpManager/signOut': 'owner-only', // owner MCP server management
'commands/execute': 'owner-only', // owner executes a slash command
'permissionPresets/catalog': 'owner-only', // owner permission presets
'userQuestions/answer': 'owner-only', // owner answers a pending question
@@ -124,7 +124,7 @@ describe('mcp-manager real composition', () => {
]) {
await expect(ctx.settings.update('mcp', { servers })).rejects.toThrow()
expect(await readFile(profile.patchPath, 'utf8')).toBe(saved)
expect(ctx.mcpServers.list()).toEqual([])
expect(ctx.mcpManager.list()).toEqual([])
}
})
@@ -136,6 +136,6 @@ describe('mcp-manager real composition', () => {
transport: 'streamable-http', url: 'https://example.invalid/mcp', oauth: { credentialKey: 'mcp-client/Foo' }, enabled: false,
} } })).rejects.toThrow('servers.one.oauth.credentialKey: credential key segment "Foo" must match')
expect(await readFile(profile.patchPath, 'utf8')).toBe(saved)
expect(ctx.mcpServers.list()).toEqual([])
expect(ctx.mcpManager.list()).toEqual([])
})
})
+6 -6
View File
@@ -12,7 +12,7 @@ async function managed(layer: 'base' | 'user' = 'base') {
const world = await oauthWorld()
const servers = { oauth: { ...world.config, enabled: true } }
await managerProfile(world.ctx, layer === 'base' ? { base: { servers } } : { base: { servers: {} }, user: { servers } })
const manager = world.ctx.mcpServers
const manager = world.ctx.mcpManager
const view = () => manager.list().find(entry => entry.name === 'oauth')!
const state = async (expected: string) => {
await vi.waitFor(() => { expect(view().status.state).toBe(expected) }, { timeout: 5000 })
@@ -31,7 +31,7 @@ async function managed(layer: 'base' | 'user' = 'base') {
it.each(['signOut', 'restart'] as const)('notifies authorization removal from a disabled entry after %s', async (operation) => {
const world = await oauthWorld()
await managerProfile(world.ctx, { base: { servers: { oauth: { ...world.config, enabled: false } } } })
const manager = world.ctx.mcpServers
const manager = world.ctx.mcpManager
const view = () => manager.list()[0]!
await manager.startAuthorization('oauth')
expect(await callback(await phase(() => view().authorization, 'waiting-browser'))).toBe(200)
@@ -50,7 +50,7 @@ it.each(['signOut', 'restart'] as const)('notifies authorization removal from a
it('cancels only the selected attempt and retires authorization when a disabled entry changes', async () => {
const world = await oauthWorld()
await managerProfile(world.ctx, { base: { servers: { oauth: { ...world.config, enabled: false } } } })
const manager = world.ctx.mcpServers
const manager = world.ctx.mcpManager
const view = () => manager.list()[0]!.authorization
const first = await manager.startAuthorization('oauth')
await manager.cancelAuthorization('missing', first.id)
@@ -334,7 +334,7 @@ it.each(['unauthorized', 'invalid-grant', 'scope', 'forbidden'] as const)('handl
it('registers an OAuth server, streams its authorization, and redacts its access token from tool errors', async () => {
const world = await oauthWorld()
await managerProfile(world.ctx, { base: { servers: {} } })
const manager = world.ctx.mcpServers
const manager = world.ctx.mcpManager
manager.register('oauth', {
transport: 'streamable-http', url: world.origin + '/mcp', oauth: { credentialKey: 'mcp-client/oauth' }, reconnect: { enabled: false },
})
@@ -363,8 +363,8 @@ it('registers an OAuth server, streams its authorization, and redacts its access
it('refuses a registration whose OAuth credential key a configured entry already owns', async () => {
const world = await oauthWorld()
await managerProfile(world.ctx, { base: { servers: { configured: { ...world.config, enabled: false } } } })
expect(() => world.ctx.mcpServers.register('registered', {
expect(() => world.ctx.mcpManager.register('registered', {
transport: 'streamable-http', url: world.origin + '/mcp', oauth: { credentialKey: 'mcp-client/oauth' },
})).toThrow('OAuth credentialKey is already assigned to another server')
expect(world.ctx.mcpServers.list().map(view => view.name)).toEqual(['configured'])
expect(world.ctx.mcpManager.list().map(view => view.name)).toEqual(['configured'])
})