---
metadata:
  - name: generator
    content: Diplodoc Platform v5.66.0
alternate:
  - https://sourcecraft.dev/portal/docs/en/cli-ref/src-codex-serve.md
  - https://sourcecraft.dev/portal/docs/ru/cli-ref/src-codex-serve.md
  - href: https://sourcecraft.dev/portal/docs/en/cli-ref/src-codex-serve.md
    type: text/markdown
    title: Markdown version
  - href: https://sourcecraft.dev/portal/docs/en/llms.txt?revision=r21973087
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://sourcecraft.dev/portal/docs/en/llms.txt?revision=r21973087

# src codex serve

Start Codex app-server listening on ws://127.0.0.1:PORT.

This subcommand is intended for use by IDE plugins (e.g., the SourceCraft JB plugin).
It starts the Codex app-server and blocks until the server exits.

The following environment variables are used when set:
SRC_IDE_MCP_HOST   MCP server host (default: 127.0.0.1)
SRC_IDE_PORT       MCP server port
SRC_IDE_AUTH_TOKEN MCP auth token

## Usage

`src codex serve [flags]`

### Examples

`src codex serve --port 9000`

### Flags

| Flag | Description |
| --- | --- |
| `--autoinstall` | Auto-install Codex if not present |
| `--model string` | Model to use (overrides config) |
| `--port int` | Port to listen on (required) (default "0") |

### Inherited flags

| Flag | Description |
| --- | --- |
| `--env string` | Override Sourcecraft environment (use 'src envs' to list available) |
| `--json string` | Output JSON, optionally filtered (--json or --json=field1,field2) |
| `--json-compact string` | Output compact JSON, optionally filtered |
| `-R, --repo string` | Select another repository using OWNER/REPO format |
| `-V, --verbose` | Enable debug logging output |

### Learn more

Use `src codex serve <subcommand> --help` for more information about a command.
