test(mcp): keep the OAuth world and manager profile in the MCP packages' tests

Remove the dsh-mcp-testkit package. The OAuth world returns to
mcp-client's tests and the manager profile to mcp-manager's tests, where
mcp-manager's OAuth spec imports the OAuth world by relative path as it
did before. The manager profile now also composes the `host: true`
mcp-client entry the manager injects. The package's registrations,
paths, and catalog rows go with it.
This commit is contained in:
gengruilin committed 2026-11-06 12:53:03 +08:00
1 parent 1ae3e12fd9
commit 14719bb5bf
31 files changed
+51 -522

No files matched your search

-1
View File
@@ -5209,7 +5209,6 @@ Imported as libraries by other packages; a `cordis.yml` cannot load them.
| `@deepseek-ai/dsh-llm-deepseek` | — | [`packages/llm/llm-deepseek/src/index.ts`](../packages/llm/llm-deepseek/src/index.ts) |
| `@deepseek-ai/dsh-llm-mock-server` | — | [`packages/test-support/llm-mock-server/src/index.ts`](../packages/test-support/llm-mock-server/src/index.ts) |
| `@deepseek-ai/dsh-loader-smoke` | — | [`packages/test-support/loader-smoke/src/index.ts`](../packages/test-support/loader-smoke/src/index.ts) |
| `@deepseek-ai/dsh-mcp-testkit` | — | [`packages/test-support/mcp-testkit/src/index.ts`](../packages/test-support/mcp-testkit/src/index.ts) |
| `@deepseek-ai/dsh-native-command` | — | [`packages/util/native-command/src/index.ts`](../packages/util/native-command/src/index.ts) |
| `@deepseek-ai/dsh-official-bundles` | — | [`packages/util/official-bundles/src/index.ts`](../packages/util/official-bundles/src/index.ts) |
| `@deepseek-ai/dsh-output-retention` | — | [`packages/util/output-retention/src/index.ts`](../packages/util/output-retention/src/index.ts) |
-1
View File
@@ -5211,7 +5211,6 @@ export interface Config {
| `@deepseek-ai/dsh-llm-deepseek` | — | [`packages/llm/llm-deepseek/src/index.ts`](../packages/llm/llm-deepseek/src/index.ts) |
| `@deepseek-ai/dsh-llm-mock-server` | — | [`packages/test-support/llm-mock-server/src/index.ts`](../packages/test-support/llm-mock-server/src/index.ts) |
| `@deepseek-ai/dsh-loader-smoke` | — | [`packages/test-support/loader-smoke/src/index.ts`](../packages/test-support/loader-smoke/src/index.ts) |
| `@deepseek-ai/dsh-mcp-testkit` | — | [`packages/test-support/mcp-testkit/src/index.ts`](../packages/test-support/mcp-testkit/src/index.ts) |
| `@deepseek-ai/dsh-native-command` | — | [`packages/util/native-command/src/index.ts`](../packages/util/native-command/src/index.ts) |
| `@deepseek-ai/dsh-official-bundles` | — | [`packages/util/official-bundles/src/index.ts`](../packages/util/official-bundles/src/index.ts) |
| `@deepseek-ai/dsh-output-retention` | — | [`packages/util/output-retention/src/index.ts`](../packages/util/output-retention/src/index.ts) |
-2
View File
@@ -468,7 +468,6 @@ flowchart TD
pkg_llm_mock_server["llm-mock-server"]
pkg_llm_replay["llm-replay"]
pkg_loader_smoke["loader-smoke"]
pkg_mcp_testkit["mcp-testkit"]
pkg_remote_mock["remote-mock"]
pkg_session_snapshot["session-snapshot"]
pkg_tool_testkit["tool-testkit"]
@@ -1687,7 +1686,6 @@ flowchart TD
| [`storage`](../packages/storage/storage) | `storage` | — |
| [`win32-process`](../packages/subprocess/win32-process) | `subprocess` | — |
| [`llm-mock-server`](../packages/test-support/llm-mock-server) | `test-support` | — |
| [`mcp-testkit`](../packages/test-support/mcp-testkit) | `test-support` | — |
| [`typert-generator`](../packages/typert/generator) | `typert` | — |
| [`typert-protocol`](../packages/typert/protocol) | `typert` | — |
| [`typert-registry`](../packages/typert/registry) | `typert` | — |
-2
View File
@@ -470,7 +470,6 @@ flowchart TD
pkg_llm_mock_server["llm-mock-server"]
pkg_llm_replay["llm-replay"]
pkg_loader_smoke["loader-smoke"]
pkg_mcp_testkit["mcp-testkit"]
pkg_remote_mock["remote-mock"]
pkg_session_snapshot["session-snapshot"]
pkg_tool_testkit["tool-testkit"]
@@ -1689,7 +1688,6 @@ flowchart TD
| [`storage`](../packages/storage/storage) | `storage` | — |
| [`win32-process`](../packages/subprocess/win32-process) | `subprocess` | — |
| [`llm-mock-server`](../packages/test-support/llm-mock-server) | `test-support` | — |
| [`mcp-testkit`](../packages/test-support/mcp-testkit) | `test-support` | — |
| [`typert-generator`](../packages/typert/generator) | `typert` | — |
| [`typert-protocol`](../packages/typert/protocol) | `typert` | — |
| [`typert-registry`](../packages/typert/registry) | `typert` | — |
+1 -1
View File
@@ -79,7 +79,7 @@
"@deepseek-ai/dsh-credentials": "workspace:*",
"@deepseek-ai/dsh-authorization": "workspace:*",
"@deepseek-ai/dsh-host-webserver": "workspace:*",
"@deepseek-ai/dsh-mcp-testkit": "workspace:*"
"@deepseek-ai/dsh-credentials-local": "workspace:*"
},
"peerDependenciesMeta": {
"@deepseek-ai/dsh-mcp-resources": {
+1 -1
View File
@@ -6,7 +6,7 @@ import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import Tools from '@deepseek-ai/dsh-tools'
import * as McpClient from '@deepseek-ai/dsh-mcp-client'
import { Config, type ServerConfigInput } from '@deepseek-ai/dsh-mcp-client'
import { authorize, oauthWorld } from '@deepseek-ai/dsh-mcp-testkit'
import { authorize, oauthWorld } from './oauth-fixture.ts'
import { startHttpMcpFixture } from './http-fixture.ts'
async function hosted() {
@@ -2,7 +2,7 @@
import { expect, it, onTestFinished, vi } from 'vitest'
import type { auth } from '@modelcontextprotocol/client'
import { McpOAuthAuthorization } from '../src/oauth.ts'
import { callback, captureLogs, oauthWorld, phase } from '@deepseek-ai/dsh-mcp-testkit'
import { callback, captureLogs, oauthWorld, phase } from './oauth-fixture.ts'
const { sdkAuth } = vi.hoisted(() => ({ sdkAuth: vi.fn<typeof auth>() }))
vi.mock('@modelcontextprotocol/client', async importOriginal => ({
@@ -5,7 +5,7 @@ import { credentialRef, parseCredentialKey, type CredentialRecord } from '@deeps
import { expect, it, onTestFinished, vi } from 'vitest'
import { McpOAuthCredentials, oauthFetch, oauthRecord } from '../src/oauth-credentials.ts'
import { probeServer } from '../src/probe.ts'
import { authorize, oauthWorld, phase } from '@deepseek-ai/dsh-mcp-testkit'
import { authorize, oauthWorld, phase } from './oauth-fixture.ts'
async function credentials() {
const world = await oauthWorld()
@@ -1,8 +1,4 @@
/**
* A loopback OAuth authorization server and MCP endpoint with real credential, authorization, and callback services.
*
* @module
*/
/** Loopback OAuth/MCP server and real credential, authorization, and callback services. */
import { createServer, type IncomingMessage, type ServerResponse } from 'node:http'
import { once } from 'node:events'
import { mkdtemp, rm } from 'node:fs/promises'
@@ -19,9 +15,9 @@ import Tools from '@deepseek-ai/dsh-tools'
import { createMcpHandler, McpServer } from '@modelcontextprotocol/server'
import { toNodeHandler, type NodeIncomingMessageLike } from '@modelcontextprotocol/node'
import { z } from 'zod'
import { Config, type McpOAuthConfig, type StreamableHttpConfig } from '@deepseek-ai/dsh-mcp-client'
import { McpOAuthAuthorization } from '@deepseek-ai/dsh-mcp-client/src/oauth.ts'
import type { McpOAuthAttemptView } from '@deepseek-ai/dsh-mcp-client/types'
import { Config, type StreamableHttpConfig } from '../src/index.ts'
import { McpOAuthAuthorization } from '../src/oauth.ts'
import type { McpOAuthAttemptView } from '../src/types.ts'
/** Recorded external request; token endpoints can be held by an explicit barrier. */
export interface OAuthRequest {
@@ -31,50 +27,8 @@ export interface OAuthRequest {
response: ServerResponse
}
/** The protocol server's answers that a test may change. */
export interface OAuthBehavior {
/** Answers token requests instead of issuing sequential tokens. */
token?: (request: OAuthRequest) => Promise<void>
/** Answers authenticated MCP requests with this status and optional challenge. */
rejection?: { status: number; challenge?: string }
/** `false` answers metadata discovery with 404 and challenges without a metadata URL. */
metadata?: false
/** Authorization endpoint the authorization-server metadata advertises. */
authorizationEndpoint?: string
/** Resource the protected-resource metadata advertises. */
resource?: string
}
/** A loopback OAuth world and the services mounted for it, torn down with the calling test. */
export interface OAuthWorld {
/** Context carrying the credential, authorization, Web server, and tool services. */
ctx: Context
/** Streamable HTTP configuration of the world's MCP endpoint with OAuth. */
config: StreamableHttpConfig & { oauth: McpOAuthConfig }
/** Create an authorization owner; teardown expects each owner to close cleanly. */
owner: (options?: StreamableHttpConfig & { oauth: McpOAuthConfig }) => McpOAuthAuthorization
/** Switches that change the protocol server's answers. */
behavior: OAuthBehavior
/** Every request the protocol server received. */
requests: OAuthRequest[]
/** The protocol server's origin. */
origin: string
/** Create a gate that teardown releases. */
barrier: () => PromiseWithResolvers<void>
/** Dynamic client registrations so far. */
registrations: () => number
/** Token requests so far. */
tokens: () => number
}
/**
* Mount isolated credential, authorization, Web server, and tool services and a protocol server, with all teardown
* owned by the calling test.
* @param interactive - mount the authorization and Web server services that explicit authorization requires.
* @param webHost - host the Web server binds.
* @returns the world, whose teardown is registered with the calling test.
*/
export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Promise<OAuthWorld> {
/** Mount isolated services and a protocol server, with all teardown owned by this test. */
export async function oauthWorld(interactive = true, webHost = '127.0.0.1') {
const ctx = new Context()
const releases: Array<() => void> = []
const owners: McpOAuthAuthorization[] = []
@@ -82,18 +36,23 @@ export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Pro
let registrationCount = 0
let tokenCount = 0
let origin = ''
const behavior: OAuthBehavior = {}
const behavior: {
token?: (request: OAuthRequest) => Promise<void>
rejection?: { status: number; challenge?: string }
metadata?: false
authorizationEndpoint?: string
resource?: string
} = {}
const mcp = createMcpHandler(({ requestInfo }) => {
const server = new McpServer({ name: 'oauth-fixture', version: '1.0.0' }, { capabilities: { tools: {} } })
server.registerTool('ping', { description: 'Replies pong.', inputSchema: z.object({}) }, () => ({ content: [{ type: 'text', text: 'pong' }] }))
server.registerTool('reject', { description: 'Echoes the request authorization in an error.', inputSchema: z.object({}) }, () => ({
server.registerTool('ping', { description: 'Replies pong.', inputSchema: z.object({}) }, async () => ({ content: [{ type: 'text', text: 'pong' }] }))
server.registerTool('reject', { description: 'Echoes the request authorization in an error.', inputSchema: z.object({}) }, async () => ({
isError: true, content: [{ type: 'text', text: `rejected ${String(requestInfo?.headers.get('authorization'))}` }],
}))
return server
})
const handleMcp = toNodeHandler(mcp)
const server = createServer((request, response) => {
// A failing handler answers 500, so a fixture defect fails the request instead of leaving it open.
void handle(request, response).catch(() => { response.writeHead(500).end() })
})
const dir = await mkdtemp(join(tmpdir(), 'dsh-mcp-oauth-'))
@@ -105,7 +64,6 @@ export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Pro
} finally {
await mcp.close()
await new Promise<void>((resolve, reject) => {
/* v8 ignore next -- a close failure fails the test's teardown */
server.close((error) => { if (error === undefined) resolve(); else reject(error) })
server.closeAllConnections()
})
@@ -113,11 +71,9 @@ export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Pro
}
})
async function handle(request: IncomingMessage, response: ServerResponse): Promise<void> {
/* v8 ignore next -- a request a server receives always carries its URL */
const path = new URL(request.url ?? '/', origin).pathname
const path = new URL(request.url!, origin).pathname
const body: Buffer[] = []
if (path !== '/mcp') for await (const chunk of request) {
/* v8 ignore next -- Node yields Buffer chunks for a request without an encoding */
if (!(chunk instanceof Uint8Array)) throw new Error('Expected request bytes')
body.push(Buffer.from(chunk))
}
@@ -152,7 +108,6 @@ export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Pro
server.listen(0, '127.0.0.1')
await once(server, 'listening')
const address = server.address()
/* v8 ignore next -- a listening TCP server reports an address object */
if (address === null || typeof address === 'string') throw new Error('OAuth fixture did not bind TCP')
origin = `http://127.0.0.1:${String(address.port)}`
await ctx.plugin(LocalCredentialProvider, { path: join(dir, 'credentials.yaml'), watch: false })
@@ -165,15 +120,14 @@ export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Pro
await ctx.plugin(NativeToolExecutor)
const resolved = Config({ transport: 'streamable-http', serverName: 'oauth', url: origin + '/mcp',
headers: { 'x-resource-only': 'fixture-resource-secret' }, oauth: { credentialKey: 'mcp-client/oauth' }, reconnect: { enabled: false } })
/* v8 ignore next -- the literal above resolves to a Streamable HTTP OAuth configuration */
if (resolved.transport !== 'streamable-http' || resolved.oauth === undefined) throw new Error('Missing HTTP OAuth configuration')
const config: StreamableHttpConfig & { oauth: McpOAuthConfig } = { ...resolved, oauth: resolved.oauth }
const config: StreamableHttpConfig & { oauth: NonNullable<StreamableHttpConfig['oauth']> } = { ...resolved, oauth: resolved.oauth }
const owner = (options = config): McpOAuthAuthorization => {
const result = new McpOAuthAuthorization(ctx, options, () => undefined)
owners.push(result)
return result
}
const barrier = (): PromiseWithResolvers<void> => {
const barrier = () => {
const gate: PromiseWithResolvers<void> = Promise.withResolvers()
releases.push(gate.resolve)
return gate
@@ -182,17 +136,10 @@ export async function oauthWorld(interactive = true, webHost = '127.0.0.1'): Pro
registrations: () => registrationCount, tokens: () => tokenCount }
}
/**
* Wait for an observed authorization phase.
* @param read - reads the current attempt view.
* @param expected - phase to wait for.
* @returns the view in that phase.
*/
export async function phase(read: () => McpOAuthAttemptView | undefined, expected: McpOAuthAttemptView['phase']): Promise<McpOAuthAttemptView> {
await vi.waitFor(() => { expectPhase(read(), expected) }, { timeout: 5000 })
const view = read()
expectPhase(view, expected)
return view
/** Wait for an observed authorization phase, failing promptly on a rejected flow. */
export async function phase(read: () => McpOAuthAttemptView | undefined, expected: McpOAuthAttemptView['phase']) {
await vi.waitFor(() => { const view = read(); expectPhase(view, expected) }, { timeout: 5000 })
return read()!
}
/**
@@ -210,26 +157,15 @@ export function captureLogs(ctx: Context): string[] {
return lines
}
function expectPhase(view: McpOAuthAttemptView | undefined, expected: McpOAuthAttemptView['phase']): asserts view is McpOAuthAttemptView {
function expectPhase(view: McpOAuthAttemptView | undefined, expected: McpOAuthAttemptView['phase']): void {
if (view?.phase !== expected) throw new Error(`Expected ${expected}, received ${JSON.stringify(view)}`)
}
function present<T>(value: T | null | undefined, what: string): T {
/* v8 ignore next -- an attempt waiting for the browser carries its authorization URL, redirect URI, and state */
if (value === null || value === undefined) throw new Error(`OAuth attempt has no ${what}`)
return value
}
/**
* Deliver a browser callback with the state and issuer advertised by this attempt.
* @param view - attempt view carrying the authorization URL.
* @param result - the authorization code or error the browser returns.
* @returns the callback's HTTP status.
*/
export async function callback(view: McpOAuthAttemptView, result: { code: string } | { error: string } = { code: 'fixture-code' }): Promise<number> {
const authorization = new URL(present(view.authorizationUrl, 'authorization URL'))
const url = new URL(present(authorization.searchParams.get('redirect_uri'), 'redirect URI'))
url.searchParams.set('state', present(authorization.searchParams.get('state'), 'state'))
/** Deliver a browser callback with the state and issuer advertised by this attempt. */
export async function callback(view: McpOAuthAttemptView, result: { code: string } | { error: string } = { code: 'fixture-code' }) {
const authorization = new URL(view.authorizationUrl!)
const url = new URL(authorization.searchParams.get('redirect_uri')!)
url.searchParams.set('state', authorization.searchParams.get('state')!)
url.searchParams.set('iss', authorization.origin)
for (const [key, value] of Object.entries(result)) url.searchParams.set(key, value)
const response = await fetch(url)
@@ -237,14 +173,10 @@ export async function callback(view: McpOAuthAttemptView, result: { code: string
return response.status
}
/**
* Finish one real discovery, registration, PKCE exchange, and durable grant commit.
* @param owner - authorization owner from the world.
*/
export async function authorize(owner: McpOAuthAuthorization): Promise<void> {
/** Finish one real discovery, registration, PKCE exchange, and durable grant commit. */
export async function authorize(owner: McpOAuthAuthorization) {
await owner.start()
const waiting = await phase(() => owner.current(), 'waiting-browser')
/* v8 ignore next -- a refused callback fails the helper instead of waiting for the attempt to time out */
if (await callback(waiting) !== 200) throw new Error('OAuth callback was rejected')
await phase(() => owner.current(), 'authorized')
}
+1 -1
View File
@@ -9,7 +9,7 @@ import { probeServer } from '../src/probe.ts'
import { connectionStatusIn as connectionStatusOf } from '../src/status.ts'
import { McpTemplateBinding } from '../src/credentials.ts'
import { McpOAuthCredentials, oauthRecord } from '../src/oauth-credentials.ts'
import { authorize, callback, captureLogs, oauthWorld, phase } from '@deepseek-ai/dsh-mcp-testkit'
import { authorize, callback, captureLogs, oauthWorld, phase } from './oauth-fixture.ts'
// The HTTP request deadline is 10 s; no test relies on waiting for that deadline.
describe('MCP OAuth', () => {
+1 -2
View File
@@ -78,7 +78,6 @@
"@deepseek-ai/dsh-hmr": "workspace:*",
"@deepseek-ai/cordis-plugin-loader": "workspace:~",
"@deepseek-ai/cordis-plugin-timer": "workspace:~",
"@deepseek-ai/dsh-typert-protocol": "workspace:*",
"@deepseek-ai/dsh-mcp-testkit": "workspace:*"
"@deepseek-ai/dsh-typert-protocol": "workspace:*"
}
}
@@ -7,7 +7,7 @@ import Timer from '@deepseek-ai/cordis-plugin-timer'
import Hmr from '@deepseek-ai/dsh-hmr'
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import ToolRuntime from '@deepseek-ai/dsh-tools'
import { managerProfile } from '@deepseek-ai/dsh-mcp-testkit'
import { managerProfile } from './profile-fixture.ts'
const { MockClient, MockTransport } = vi.hoisted(() => {
class MockTransport {
@@ -80,7 +80,7 @@ import { apply as applyMcpClient, Config as ClientConfig } from '@deepseek-ai/ds
import { connectionStatusIn as connectionStatusOf } from '@deepseek-ai/dsh-mcp-client/src/status.ts'
import McpServerManager from '@deepseek-ai/dsh-mcp-manager/src/index.ts'
import type { Config, McpManagedServerStatus } from '@deepseek-ai/dsh-mcp-manager/src/index.ts'
import { managerProfile } from '@deepseek-ai/dsh-mcp-testkit'
import { managerProfile } from './profile-fixture.ts'
/** Minimal real credential provider: reference half backed by a map. */
class MemoryCredentials extends CredentialProvider {
+2 -1
View File
@@ -4,7 +4,8 @@ import { ToolCallId } from '@deepseek-ai/dsh-llm'
import { executeToolFixture } from '@deepseek-ai/dsh-tool-testkit'
import { Client, UnauthorizedError } from '@modelcontextprotocol/client'
import { McpOAuthCredentials } from '@deepseek-ai/dsh-mcp-client/src/oauth-credentials.ts'
import { callback, managerProfile, oauthWorld, phase } from '@deepseek-ai/dsh-mcp-testkit'
import { callback, oauthWorld, phase } from '../../mcp-client/tests/oauth-fixture.ts'
import { managerProfile } from './profile-fixture.ts'
import type { McpManagedServerView } from '../src/types.ts'
async function managed(layer: 'base' | 'user' = 'base') {
@@ -1,8 +1,4 @@
/**
* The MCP manager and the MCP client host it injects, mounted through a real profile, ConfigEditor, and Loader.
*
* @module
*/
/** The MCP client host and manager configuration through a real profile, ConfigEditor, and Loader. */
import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'node:fs'
import { rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
@@ -10,31 +6,20 @@ import { join } from 'node:path'
import { pathToFileURL } from 'node:url'
import { onTestFinished } from 'vitest'
import type { Context } from '@deepseek-ai/cordis'
import Loader, { type Entry } from '@deepseek-ai/cordis-plugin-loader'
import Loader from '@deepseek-ai/cordis-plugin-loader'
import { initProfile, mountRootInclude, readProfilePatches, type ProfileContext } from '@deepseek-ai/dsh-app-boot'
import ConfigEditor from '@deepseek-ai/dsh-config-editor'
import Settings from '@deepseek-ai/dsh-settings'
import * as McpClient from '@deepseek-ai/dsh-mcp-client'
import McpServerManager from '@deepseek-ai/dsh-mcp-manager'
/** A profile that composes the MCP client host and the manager, torn down with the calling test. */
export interface ManagerProfile {
/** The launcher's profile context. */
profile: ProfileContext
/** The manager entry in the context the profile started in. */
entry: Entry
/** Start the same profile in another context and return its manager entry there. */
start: (context: Context) => Promise<Entry>
}
import McpServerManager from '../src/index.ts'
/**
* Mount the MCP client host and the manager from an inherited bundle and optional user patch.
* @param ctx - Test context carrying tools and optional credentials.
* @param options - Manager entry id, base configuration, and user overrides.
* @returns The profile, the manager entry, and a function that starts the same profile in another context, all owned
* by the test.
* @returns The profile and manager entry owned by the test.
*/
export async function managerProfile(ctx: Context, options: { id?: string; base?: unknown; user?: unknown } = {}): Promise<ManagerProfile> {
export async function managerProfile(ctx: Context, options: { id?: string; base?: unknown; user?: unknown } = {}) {
const home = realpathSync(mkdtempSync(join(tmpdir(), 'dsh-mcp-manager-')))
const contexts: Context[] = []
onTestFinished(async () => {
@@ -69,10 +54,7 @@ export async function managerProfile(ctx: Context, options: { id?: string; base?
await context.plugin(Settings)
await mountRootInclude(context, join(dir, 'cordis.yml'), readProfilePatches('test', profile))
await context.loader.await()
const entry = context.configEditor.entries().find(candidate => candidate.options.id === id)
/* v8 ignore next -- the bundle patch above inserts the manager entry with this id */
if (entry === undefined) throw new Error(`MCP manager entry "${id}" is not composed`)
return entry
return context.configEditor.entries().find(entry => entry.options.id === id)!
}
return { profile, entry: await start(ctx), start }
}
+2 -2
View File
@@ -15,8 +15,8 @@
en: 1eb35b015a6c423f
zh: a8a3dceee2c9e943
/packages-test-support/packages:
en: 0f7f6f785edef4c2
zh: bf1b9abfb18d655f
en: 15c602cea9f84f94
zh: d806d9eb4d958356
/packages-test-support/related-documentation:
en: 938bb087afd96c3e
zh: 0d51d0d7c0915602
-1
View File
@@ -27,7 +27,6 @@ The test-support group gives repository tests deterministic, keyless ways to exe
| [`session-snapshot`](session-snapshot/README.md) | Provides session-log snapshot support and protocol adapters for profile-driven tests |
| [`agent-loop-testkit`](agent-loop-testkit/README.md) | Provides the shared prerequisite services for tests that exercise the concrete AgentLoop |
| [`tool-testkit`](tool-testkit/README.md) | Defines tool fixtures and exercises invocation or executor behavior in tests |
| [`mcp-testkit`](mcp-testkit/README.md) | Serves a loopback MCP OAuth world and mounts the MCP manager through a real profile in tests |
| [`client-runtime`](client-runtime/README.md) | Provides the jsdom slot test bench for browser feature specs |
| [`remote-mock`](remote-mock/README.md) | Provides the endpoint-named Typert Remote mock and the Connection carrier face whole-client specs install |
| [`loader-smoke`](loader-smoke/README.md) | Boots Loader-composed applications and drives fixture turns for smoke tests |
-1
View File
@@ -27,7 +27,6 @@ test-support 组为仓库测试提供确定且无须密钥的真实产品测试
| [`session-snapshot`](session-snapshot/README.zh.md) | 为 profile 驱动的测试提供 session-log 快照支持与协议适配器 |
| [`agent-loop-testkit`](agent-loop-testkit/README.zh.md) | 为运行具体 AgentLoop 的测试提供共享先决服务 |
| [`tool-testkit`](tool-testkit/README.zh.md) | 定义工具 fixture,并在测试中执行工具调用或执行器行为 |
| [`mcp-testkit`](mcp-testkit/README.zh.md) | 在测试中提供回环 MCP OAuth world,并经真实 profile 挂载 MCP 管理器 |
| [`client-runtime`](client-runtime/README.zh.md) | 为浏览器功能测试提供 jsdom slot 测试台 |
| [`remote-mock`](remote-mock/README.zh.md) | 为整体客户端测试提供端点具名的 Typert Remote mock 与它们安装的 Connection 载体面 |
| [`loader-smoke`](loader-smoke/README.zh.md) | 启动由 Loader 组合的应用并驱动 fixture(测试前置数据)轮次以执行冒烟测试 |
@@ -1,37 +0,0 @@
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
# After editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write packages/test-support/mcp-testkit/README.md
/:
en: 28748b37fdf578be
zh: 97b42377cbc0fd34
/deepseek-ai-dsh-mcp-testkit:
en: f982e8ed4efbf9c2
zh: de66389510fd1437
/deepseek-ai-dsh-mcp-testkit/summary:
en: a487b6bf067549d4
zh: 8ab780b12280eff8
/deepseek-ai-dsh-mcp-testkit/table-of-contents:
en: d152484eb41ac6b4
zh: 1db86285abf6c499
/deepseek-ai-dsh-mcp-testkit/use-this-package:
en: e269c1b199064b16
zh: 5edde55bd001dca3
/deepseek-ai-dsh-mcp-testkit/understand-the-implementation:
en: 483aeab8de0204c0
zh: 662fca7cba278bf8
/deepseek-ai-dsh-mcp-testkit/further-exploration:
en: 14db1dc3f9ac693e
zh: f107f5b3429e1a88
/deepseek-ai-dsh-mcp-testkit/model-experience:
en: 6702f62ee99a7bba
zh: a1595dc587eb2d55
/deepseek-ai-dsh-mcp-testkit/model-experience/kv-cache-effect:
en: be3fa044c8f27bf0
zh: 35fdb79b58ba91f6
/deepseek-ai-dsh-mcp-testkit/known-limitations-and-deferred-work:
en: ad3e27b6e7754394
zh: 675dc85edc4ec3dd
/deepseek-ai-dsh-mcp-testkit/known-limitations-and-deferred-work/dev-note:
en: e67f633dc6fe7773
zh: e88aeb617ffb74ea
@@ -1,87 +0,0 @@
---
description: "Run MCP OAuth flows against a loopback authorization server and mount the MCP manager through a real profile in repository tests."
kind: "package-library"
---
# @deepseek-ai/dsh-mcp-testkit
English | [中文](README.zh.md)
## Summary
Use this package in tests that need a real MCP OAuth exchange or a profile-composed MCP manager. It serves a loopback OAuth authorization server and MCP endpoint, and mounts the MCP client host and the manager through a real profile, ConfigEditor, and Loader. Tests import it as a development dependency; each fixture registers its own teardown with the running test.
## Table of Contents
- [Use this package](#use-this-package)
- [Understand the implementation](#understand-the-implementation)
- [Further Exploration](#further-exploration)
- [Model Experience](#model-experience)
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
- [Dev Note](#dev-note)
-----
<a id="use-this-package"></a>
## Use this package
Add `@deepseek-ai/dsh-mcp-testkit` to the consuming package's `devDependencies`. Start an OAuth world, mount the manager on its context, and drive authorization through the manager:
```ts
import { callback, managerProfile, oauthWorld, phase } from '@deepseek-ai/dsh-mcp-testkit'
const world = await oauthWorld()
await managerProfile(world.ctx, { base: { servers: { oauth: { ...world.config, enabled: true } } } })
const attempt = await world.ctx.mcpManager.startAuthorization('oauth')
```
`oauthWorld()` returns the world's context with credential, authorization, Web server, and tool services, a Streamable HTTP configuration that uses OAuth, an authorization owner factory, and switches that change the protocol server's token, rejection, and metadata answers. `phase()` waits for an attempt phase, `callback()` delivers the browser callback, and `authorize()` completes one authorization through an owner. `managerProfile()` composes the MCP client host and the manager from an inherited bundle and an optional user patch; its context must already carry the tool services.
-----
<a id="understand-the-implementation"></a>
## Understand the implementation
<details>
<summary>Implementation internals — click to expand</summary>
[`src/oauth-world.ts`](src/oauth-world.ts) answers OAuth discovery, dynamic registration, token, and MCP requests from one loopback HTTP server and records each request. [`src/manager-profile.ts`](src/manager-profile.ts) writes a temporary profile whose bundle inserts the host and manager entries, then mounts it through the Loader. Both register teardown through `onTestFinished`, so they run only inside a test.
</details>
-----
<a id="further-exploration"></a>
## Further Exploration
- [MCP client](../../mcp/mcp-client/README.md#oauth) — OAuth connections, explicit authorization, and the MCP client host.
- [MCP manager](../../mcp/mcp-manager/README.md) — the server fleet the profile fixture mounts.
- [Test-support group map](../README.md) — sibling test utilities.
-----
<a id="model-experience"></a>
## Model Experience
None, as these fixtures serve OAuth and MCP protocol traffic without assembling or sending model requests.
#### KV Cache effect
None; the package itself sends no provider request.
## Known Limitations and Deferred Work
<a id="known-limitations-and-deferred-work"></a>
- The authorization server always grants the request: it does not render consent or check the client secret, and tests change its answers through the world's switches.
- The fixtures call `onTestFinished` and therefore run only inside a Vitest test.
<a id="dev-note"></a>
### Dev Note
<details>
<summary>Working context for maintainers — click to expand</summary>
None.
</details>
@@ -1,87 +0,0 @@
---
description: "在仓库测试中对着回环 OAuth 授权服务器运行 MCP OAuth 流程,并经真实 profile 挂载 MCP 管理器。"
kind: "package-library"
---
# @deepseek-ai/dsh-mcp-testkit
[English](README.md) | 中文
## 概述
需要真实 MCP OAuth 交换或经 profile 组合的 MCP 管理器的测试使用本包。它提供回环 OAuth 授权服务器和 MCP 端点,并经真实 profile、ConfigEditor 和 Loader 挂载 MCP 客户端宿主与管理器。测试将其作为开发依赖导入;每个 fixture 都把自己的清理注册到当前测试。
## 目录
- [使用本包](#use-this-package)
- [理解实现](#understand-the-implementation)
- [进一步探索](#further-exploration)
- [模型体验](#model-experience)
- [已知限制与后续工作](#known-limitations-and-deferred-work)
- [开发备注](#dev-note)
-----
<a id="use-this-package"></a>
## 使用本包
将 `@deepseek-ai/dsh-mcp-testkit` 加入消费包的 `devDependencies`。启动 OAuth world,在其 context 上挂载管理器,再通过管理器驱动授权:
```ts
import { callback, managerProfile, oauthWorld, phase } from '@deepseek-ai/dsh-mcp-testkit'
const world = await oauthWorld()
await managerProfile(world.ctx, { base: { servers: { oauth: { ...world.config, enabled: true } } } })
const attempt = await world.ctx.mcpManager.startAuthorization('oauth')
```
`oauthWorld()` 返回带有凭据、授权、Web 服务器和工具服务的 world context、一份使用 OAuth 的 Streamable HTTP 配置、授权所有者工厂,以及改变协议服务器 token、拒绝和元数据应答的开关。`phase()` 等待尝试进入某个阶段,`callback()` 投递浏览器回调,`authorize()` 通过一个所有者完成一次授权。`managerProfile()` 用继承的 bundle 和可选的用户 patch 组合 MCP 客户端宿主与管理器;其 context 必须已带有工具服务。
-----
<a id="understand-the-implementation"></a>
## 理解实现
<details>
<summary>实现内部细节——点击展开</summary>
[`src/oauth-world.ts`](src/oauth-world.ts) 由一台回环 HTTP 服务器应答 OAuth 发现、动态注册、token 和 MCP 请求,并记录每个请求。[`src/manager-profile.ts`](src/manager-profile.ts) 写出一个临时 profile,其 bundle 插入宿主与管理器条目,再经 Loader 挂载。两者都通过 `onTestFinished` 注册清理,因此只能在测试内运行。
</details>
-----
<a id="further-exploration"></a>
## 进一步探索
- [MCP 客户端](../../mcp/mcp-client/README.zh.md#oauth)——OAuth 连接、显式授权与 MCP 客户端宿主。
- [MCP 管理器](../../mcp/mcp-manager/README.zh.md)——profile fixture 挂载的服务器集合。
- [test-support 分组地图](../README.zh.md)——同组测试工具。
-----
<a id="model-experience"></a>
## 模型体验
无,这些 fixture 只承载 OAuth 和 MCP 协议流量,不组装或发送模型请求。
#### KV Cache 影响
无;本包自身不发送 provider 请求。
## 已知限制与后续工作
<a id="known-limitations-and-deferred-work"></a>
- 授权服务器总是批准请求:它不显示同意页、不校验客户端密钥,测试通过 world 的开关改变其应答。
- fixture 调用 `onTestFinished`,因此只能在 Vitest 测试内运行。
<a id="dev-note"></a>
### 开发备注
<details>
<summary>维护者工作上下文——点击展开</summary>
无。
</details>
@@ -1,56 +0,0 @@
{
"name": "@deepseek-ai/dsh-mcp-testkit",
"description": "MCP OAuth world and MCP manager profile fixtures for tests",
"version": "0.2.2-rc.1",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
"directory": "packages/test-support/mcp-testkit"
},
"type": "module",
"main": "lib/index.js",
"types": "lib/types/index.d.ts",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/index.js"
},
"./src/*": "./src/*",
"./package.json": "./package.json"
},
"files": [
"lib/index.js",
"lib/types/**/*.d.ts",
"lib/types/**/*.d.ts.map",
"lib/**/*.js.map",
"src"
],
"license": "MIT",
"peerDependencies": {
"@deepseek-ai/cordis": "workspace:~"
},
"dependencies": {
"@deepseek-ai/cordis-plugin-loader": "workspace:~",
"@deepseek-ai/dsh-app-boot": "workspace:*",
"@deepseek-ai/dsh-authorization": "workspace:*",
"@deepseek-ai/dsh-config-editor": "workspace:*",
"@deepseek-ai/dsh-credentials-local": "workspace:*",
"@deepseek-ai/dsh-host-webserver": "workspace:*",
"@deepseek-ai/dsh-mcp-client": "workspace:*",
"@deepseek-ai/dsh-mcp-manager": "workspace:*",
"@deepseek-ai/dsh-settings": "workspace:*",
"@deepseek-ai/dsh-system-prompt": "workspace:*",
"@deepseek-ai/dsh-tool-executor-native": "workspace:*",
"@deepseek-ai/dsh-tools": "workspace:*",
"@modelcontextprotocol/node": "2.0.0",
"@modelcontextprotocol/server": "2.2.0",
"vitest": "^4.1.11",
"zod": "4.6.6"
},
"devDependencies": {
"@deepseek-ai/cordis": "workspace:~"
}
}
@@ -1,11 +0,0 @@
/**
* MCP test fixtures shared by the MCP client, the MCP manager, and connector plugins: a loopback OAuth world and a
* real profile that mounts the MCP client host and the manager.
*
* @module @deepseek-ai/dsh-mcp-testkit
*/
export { authorize, callback, captureLogs, oauthWorld, phase } from './oauth-world.ts'
export type { OAuthBehavior, OAuthRequest, OAuthWorld } from './oauth-world.ts'
export { managerProfile } from './manager-profile.ts'
export type { ManagerProfile } from './manager-profile.ts'
@@ -1,11 +0,0 @@
/** The loopback protocol server answers unrouted paths and fixture failures instead of leaving requests open. */
import { expect, it } from 'vitest'
import { oauthWorld } from '../src/index.ts'
it('answers an unrouted path with 404 and a failing token behavior with 500', async () => {
const world = await oauthWorld(false)
expect((await fetch(world.origin + '/unrouted')).status).toBe(404)
world.behavior.token = async () => { throw new Error('fixture token failure') }
expect((await fetch(world.origin + '/token', { method: 'POST', body: 'grant_type=refresh_token' })).status).toBe(500)
})
@@ -1,25 +0,0 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib/types"
},
"include": [
"src"
],
"references": [
{ "path": "../../../vendor/cordis" },
{ "path": "../../../vendor/loader" },
{ "path": "../../boot/app-boot" },
{ "path": "../../boot/config-editor" },
{ "path": "../../core/system-prompt" },
{ "path": "../../core/tool-executor-native" },
{ "path": "../../core/tools" },
{ "path": "../../credentials/authorization" },
{ "path": "../../credentials/credentials-local" },
{ "path": "../../host/webserver" },
{ "path": "../../mcp/mcp-client" },
{ "path": "../../mcp/mcp-manager" },
{ "path": "../../settings/settings" }
]
}
+3 -61
View File
@@ -13816,6 +13816,9 @@ importers:
'@deepseek-ai/dsh-credentials':
specifier: workspace:*
version: link:../../credentials/credentials
'@deepseek-ai/dsh-credentials-local':
specifier: workspace:*
version: link:../../credentials/credentials-local
'@deepseek-ai/dsh-host-webserver':
specifier: workspace:*
version: link:../../host/webserver
@@ -13828,9 +13831,6 @@ importers:
'@deepseek-ai/dsh-mcp-resources':
specifier: workspace:*
version: link:../mcp-resources
'@deepseek-ai/dsh-mcp-testkit':
specifier: workspace:*
version: link:../../test-support/mcp-testkit
'@deepseek-ai/dsh-scope':
specifier: workspace:*
version: link:../../core/scope
@@ -13901,9 +13901,6 @@ importers:
'@deepseek-ai/dsh-mcp-client':
specifier: workspace:*
version: link:../mcp-client
'@deepseek-ai/dsh-mcp-testkit':
specifier: workspace:*
version: link:../../test-support/mcp-testkit
'@deepseek-ai/dsh-settings':
specifier: workspace:*
version: link:../../settings/settings
@@ -17554,61 +17551,6 @@ importers:
specifier: workspace:*
version: link:../../core/tools
packages/test-support/mcp-testkit:
dependencies:
'@deepseek-ai/cordis-plugin-loader':
specifier: workspace:~
version: link:../../../vendor/loader
'@deepseek-ai/dsh-app-boot':
specifier: workspace:*
version: link:../../boot/app-boot
'@deepseek-ai/dsh-authorization':
specifier: workspace:*
version: link:../../credentials/authorization
'@deepseek-ai/dsh-config-editor':
specifier: workspace:*
version: link:../../boot/config-editor
'@deepseek-ai/dsh-credentials-local':
specifier: workspace:*
version: link:../../credentials/credentials-local
'@deepseek-ai/dsh-host-webserver':
specifier: workspace:*
version: link:../../host/webserver
'@deepseek-ai/dsh-mcp-client':
specifier: workspace:*
version: link:../../mcp/mcp-client
'@deepseek-ai/dsh-mcp-manager':
specifier: workspace:*
version: link:../../mcp/mcp-manager
'@deepseek-ai/dsh-settings':
specifier: workspace:*
version: link:../../settings/settings
'@deepseek-ai/dsh-system-prompt':
specifier: workspace:*
version: link:../../core/system-prompt
'@deepseek-ai/dsh-tool-executor-native':
specifier: workspace:*
version: link:../../core/tool-executor-native
'@deepseek-ai/dsh-tools':
specifier: workspace:*
version: link:../../core/tools
'@modelcontextprotocol/node':
specifier: 2.0.0
version: 2.0.0(@modelcontextprotocol/[email protected])([email protected])
'@modelcontextprotocol/server':
specifier: 2.2.0
version: 2.2.0
vitest:
specifier: ^4.1.11
version: 4.1.11(@opentelemetry/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))
zod:
specifier: 4.6.6
version: 4.6.6
devDependencies:
'@deepseek-ai/cordis':
specifier: workspace:~
version: link:../../../vendor/cordis
packages/test-support/remote-mock:
dependencies:
'@vitest/spy':
-1
View File
@@ -85,7 +85,6 @@ const PACKAGE_LIBRARIES: Readonly<Record<string, string>> = {
'packages/test-support/session-snapshot': 'Test infrastructure; mounts nothing into a product composition.',
'packages/test-support/agent-loop-testkit': 'Test helper library; mounts nothing into a product composition.',
'packages/test-support/tool-testkit': 'Tool fixture library; exports helpers without a plugin entry.',
'packages/test-support/mcp-testkit': 'MCP OAuth and manager profile fixture library; exports helpers without a plugin entry.',
'packages/test-support/client-runtime': 'Browser-side test infrastructure.',
'packages/test-support/llm-mock-server': 'Test server library; substitutes provider wire behavior.',
'packages/test-support/loader-smoke': 'Test harness library; mounts nothing into a product composition.',
-1
View File
@@ -39,7 +39,6 @@ export const PRODUCT_PACKAGE_POLICY: Readonly<Record<string, ProductPackagePolic
'packages/typert/generator': { category: 'build', reason: 'Build-time generation of type metadata.' },
'packages/test-support/agent-loop-testkit': { category: 'test', reason: 'Published agent-loop test harness.' },
'packages/test-support/tool-testkit': { category: 'test', reason: 'Shared tool definition and execution fixtures for tests and benchmarks.' },
'packages/test-support/mcp-testkit': { category: 'test', reason: 'Shared MCP OAuth world and MCP manager profile fixtures for tests.' },
'packages/test-support/client-runtime': { category: 'test', reason: 'Published browser plugin test harness.' },
'packages/test-support/llm-mock-server': { category: 'test', reason: 'Published model-provider test server.' },
'packages/test-support/llm-replay': { category: 'test', reason: 'Published recorded-model replay harness.' },
@@ -243,7 +243,6 @@ const SENTENCE_MODEL_EXPERIENCE: Readonly<Record<string, SentenceContract>> = {
'packages/test-support/session-snapshot': { kind: 'none', reason: 'The test harness observes and normalizes transcripts without changing live requests.' },
'packages/test-support/agent-loop-testkit': { kind: 'none', reason: 'The test helper mounts services but neither drives nor modifies model requests.' },
'packages/test-support/tool-testkit': { kind: 'none', reason: 'Fixture helpers define and execute test tools without making model requests.' },
'packages/test-support/mcp-testkit': { kind: 'none', reason: 'OAuth and MCP protocol fixtures serve test traffic without making model requests.' },
'packages/test-support/loader-smoke': { kind: 'none', reason: 'The test harness submits an ordinary user task but delegates prompt and tool composition to the loaded tree.' },
'packages/test-support/llm-mock-server': { kind: 'none', reason: 'The test server substitutes provider wire behavior without invoking a real model.' },
'packages/test-support/llm-replay': { kind: 'none', reason: 'The keyless adapter invokes no provider model.' },
-1
View File
@@ -489,7 +489,6 @@
"@deepseek-ai/dsh-mcp-client": ["./packages/mcp/mcp-client/src"],
"@deepseek-ai/dsh-mcp-manager": ["./packages/mcp/mcp-manager/src"],
"@deepseek-ai/dsh-mcp-resources": ["./packages/mcp/mcp-resources/src"],
"@deepseek-ai/dsh-mcp-testkit": ["./packages/test-support/mcp-testkit/src"],
"@deepseek-ai/dsh-message-feedback": ["./packages/feedback/message-feedback/src"],
"@deepseek-ai/dsh-message-quotes": ["./packages/session/message-quotes/src"],
"@deepseek-ai/dsh-native-command": ["./packages/util/native-command/src"],
-1
View File
@@ -523,7 +523,6 @@
{ "path": "./packages/guard/timeout-policy" },
{ "path": "./packages/test-support/agent-loop-testkit" },
{ "path": "./packages/test-support/tool-testkit" },
{ "path": "./packages/test-support/mcp-testkit" },
{ "path": "./packages/acp/acp" },
{ "path": "./packages/bundle/acp-app" },
{ "path": "./packages/bundle/base" },