1
>
/*---------------------------------------------------------------------------------------------
codexMcpServers.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { McpServerType, type IMcpServerConfiguration } from '../../../mcp/common/mcpPlatformTypes.js';
7
>
import { McpServerStatus, type McpServerState } from '../../common/state/protocol/channels-session/state.js';
8
>
import type { ISdkMcpServer } from '../shared/mcpCustomizationController.js';
9
>
import type { McpServerStartupState } from './protocol/generated/v2/McpServerStartupState.js';
10
>
import type { McpServerStatus as CodexMcpServerStatus } from './protocol/generated/v2/McpServerStatus.js';
11
>
import type { Resource } from './protocol/generated/Resource.js';
12
>
import type { ResourceTemplate } from './protocol/generated/ResourceTemplate.js';
13
>
import type { Tool } from './protocol/generated/Tool.js';
14
>
15
>
/**
16
>
* Cached inventory entry for a single MCP server reported by the codex
17
>
* app-server. {@link state} drives the AHP customization surface while
18
>
* {@link tools} / {@link resources} / {@link resourceTemplates} back the
19
>
* read-only `tools/list`, `resources/list` and `resources/templates/list`
20
>
* MCP methods so the host can answer them from cache without
21
>
* round-tripping to codex.
22
>
*/
23
>
export interface ICodexMcpServerEntry {
24
>
readonly state: McpServerState;
25
>
readonly tools: readonly Tool[];
26
>
readonly resources: readonly Resource[];
27
>
readonly resourceTemplates: readonly ResourceTemplate[];
28
>
}
29
>
30
>
/**
31
>
* Translates a codex `mcpServer/startupStatus/updated` lifecycle state
32
>
* into the AHP {@link McpServerState} union.
33
>
*
34
>
* V1 scope: codex's auth states are not surfaced as
35
>
* {@link McpServerStatus.AuthRequired}; a connected server is reported as
36
>
* {@link McpServerStatus.Ready} regardless of `authStatus`.
37
>
*/
38
>
export function translateCodexMcpStartupState(status: McpServerStartupState, error: string | null | undefined): McpServerState {
39
switch (status) {
40
case 'ready':