# Class CodexMcpAdapter

Codex CLI adapter using MCP transport.

Extends BaseCliAdapter which provides:

- Retry logic with exponential backoff
- Health checks with version compatibility
- Capacity tracking
- Error creation helpers

#### Hierarchy (View Summary)

- BaseCliAdapter
  - CodexMcpAdapter

- Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:51

##### Index

### Constructors

constructor

### Properties

name
transport
logger
capacityTracker
initialized
lastHealthCheck?
cachedVersion?

### Accessors

capabilities

### Methods

getModelInfo
initialize
executeTask
dispose
initCapacityTracker
execute
healthCheck
getVersion
getCapacity
recordUsage
parseVersion
checkVersionCompatibility
getVersionMessage
createError
normalizeResponse
delay

## Constructors

### constructor

- new CodexMcpAdapter(options?: BaseAdapterOptions): CodexMcpAdapter

  #### Parameters

  - `Optional` options: BaseAdapterOptions

  #### Returns CodexMcpAdapter

  Overrides BaseCliAdapter.constructor

  - Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:60

## Properties

### `Readonly` name

name: "claude" | "gemini" | "codex" | "opencode" = 'codex'

CLI name

Overrides BaseCliAdapter.name

- Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:52

### `Readonly` transport

transport: CliTransport = 'mcp'

Transport type

Overrides BaseCliAdapter.transport

- Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:53

### `Protected` `Readonly` logger

logger: ILogger

Inherited from BaseCliAdapter.logger

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:75

### `Protected` capacityTracker

capacityTracker: CapacityTracker | null = null

Inherited from BaseCliAdapter.capacityTracker

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:76

### `Protected` initialized

initialized: boolean = false

Inherited from BaseCliAdapter.initialized

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:77

### `Protected` `Optional` lastHealthCheck

lastHealthCheck?: HealthStatus

Inherited from BaseCliAdapter.lastHealthCheck

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:78

### `Protected` `Optional` cachedVersion

cachedVersion?: string

Inherited from BaseCliAdapter.cachedVersion

- Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:79

## Accessors

### capabilities

- get capabilities(): CliCapabilityProfile

  Gets the capability profile for this CLI.

  #### Returns CliCapabilityProfile

  Inherited from BaseCliAdapter.capabilities

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:96

## Methods

### getModelInfo

- getModelInfo(): CliModelInfo

  Gets Codex model information. Resolves from canonical registry when possible, falls back to legacy lookup.

  #### Returns CliModelInfo

  Overrides BaseCliAdapter.getModelInfo

  - Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:69

### initialize

- initialize(): Promise<void>

  Initializes the MCP connection to Codex.

  #### Returns Promise<void>

  Overrides BaseCliAdapter.initialize

  - Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:87

### executeTask

- executeTask(
  _task: CliTask,
  options: Required<CliExecutionOptions>,
  ): Promise<Result<CliResponse, CliError>>

  Executes a task via MCP client. Called by BaseCliAdapter.execute() with retry handling.

  #### Parameters

  - _task: CliTask
  - options: Required<CliExecutionOptions>

  #### Returns Promise<Result<CliResponse, CliError>>

  Overrides BaseCliAdapter.executeTask

  - Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:119

### dispose

- dispose(): Promise<void>

  Disposes the adapter and closes MCP connection.

  #### Returns Promise<void>

  Overrides BaseCliAdapter.dispose

  - Defined in packages/nexus-agents/src/cli-adapters/adapters/codex-mcp-adapter.ts:216

### `Protected` initCapacityTracker

- initCapacityTracker(): void

  Initializes the capacity tracker. Called by subclasses after name is set.

  #### Returns void

  Inherited from BaseCliAdapter.initCapacityTracker

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:89

### execute

- execute(
  task: CliTask,
  options?: CliExecutionOptions,
  ): Promise<Result<CliResponse, CliError>>

  Executes a task with error handling and retries.

  Timeout priority (highest to lowest):

  1. options.timeoutMs - explicit execution option
  2. task.timeoutMs - task-level setting
  3. getTimeoutForTaskAuto() - computed from task complexity and CLI

  #### Parameters

  - task: CliTask
  - `Optional` options: CliExecutionOptions

  #### Returns Promise<Result<CliResponse, CliError>>

  Inherited from BaseCliAdapter.execute

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:135

### healthCheck

- healthCheck(): Promise<HealthStatus>

  Performs a health check.

  #### Returns Promise<HealthStatus>

  Inherited from BaseCliAdapter.healthCheck

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:200

### getVersion

- getVersion(): Promise<string>

  Gets CLI version.

  #### Returns Promise<string>

  Inherited from BaseCliAdapter.getVersion

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:230

### getCapacity

- getCapacity(): Promise<CapacityStatus>

  Gets current capacity status based on tracked usage. Uses usage-based tracking since CLI subprocess execution doesn't expose HTTP rate limit headers.

  #### Returns Promise<CapacityStatus>

  #### See

  Issue #456 - Real API rate limit tracking

  Inherited from BaseCliAdapter.getCapacity

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:256

### `Protected` recordUsage

- recordUsage(response: CliResponse): void

  Records usage from a response for capacity tracking.

  #### Parameters

  - response: CliResponse

  #### Returns void

  Inherited from BaseCliAdapter.recordUsage

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:281

### `Protected` parseVersion

- parseVersion(output: string): string

  Parses version from CLI output.

  #### Parameters

  - output: string

  #### Returns string

  Inherited from BaseCliAdapter.parseVersion

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:290

### `Protected` checkVersionCompatibility

- checkVersionCompatibility(version: string): VersionStatus

  Checks version compatibility.

  #### Parameters

  - version: string

  #### Returns VersionStatus

  Inherited from BaseCliAdapter.checkVersionCompatibility

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:302

### `Protected` getVersionMessage

- getVersionMessage(status: VersionStatus, version: string): string | undefined

  Gets version status message.

  #### Parameters

  - status: VersionStatus
  - version: string

  #### Returns string | undefined

  Inherited from BaseCliAdapter.getVersionMessage

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:331

### `Protected` createError

- createError(code: CliErrorCode, message: string, cause?: Error): CliError

  Creates a CLI error.

  #### Parameters

  - code: CliErrorCode
  - message: string
  - `Optional` cause: Error

  #### Returns CliError

  Inherited from BaseCliAdapter.createError

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:349

### `Protected` normalizeResponse

- normalizeResponse(
  text: string,
  usage?: CliTokenUsage,
  extra?: Partial<CliResponse>,
  ): CliResponse

  Normalizes CLI response to common format.

  #### Parameters

  - text: string
  - `Optional` usage: CliTokenUsage
  - `Optional` extra: Partial<CliResponse>

  #### Returns CliResponse

  Inherited from BaseCliAdapter.normalizeResponse

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:364

### `Protected` delay

- delay(ms: number): Promise<void>

  Delays for the specified milliseconds.

  #### Parameters

  - ms: number

  #### Returns Promise<void>

  Inherited from BaseCliAdapter.delay

  - Defined in packages/nexus-agents/src/cli-adapters/base-adapter.ts:379