Skip to main content
Glama
Zbrooklyn

dsh-codex-mcp

by Zbrooklyn
README.md
# dsh-codex-mcp

Codex models in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), through OpenAI's official CLI — **without giving any third-party code custody of your ChatGPT credentials.**

## Install

```sh
npm i -g @openai/codex   # if you don't already have it
codex login              # sign in with your ChatGPT account
dsh plugin --profile web add dsh-codex-mcp
dsh web
```

That's it. Codex appears in the agent's tools as `mcp__codex__codex`. No API key, no OAuth flow inside the harness, nothing to paste.

## Why this exists

Other plugins that put a ChatGPT subscription into the harness run their own OAuth flow, obtain a token scoped to your plan, and store it. To OpenAI those requests appear to come from Codex CLI. In practice a third-party package is holding a credential for something you pay for.

This plugin does not authenticate at all. It locates the Codex executable, launches it as an [MCP](https://modelcontextprotocol.io) server, and lets the harness talk to it over stdio. Authentication happens inside OpenAI's own signed binary, against its own `~/.codex/auth.json`. **There is no token here to leak, and uninstalling leaves nothing behind to revoke.**

```
DeepSeek Harness  ──MCP/stdio──▶  codex mcp-server  ──HTTPS──▶  OpenAI
                                  (official binary,
                                   own credentials)
```

## Why MCP rather than shelling out per call

Measured on the same prompt and model:

| Approach | Latency |
| --- | --- |
| MCP server (persistent process) | **11.4s** |
| `codex exec` (new process per call) | 31.5s |

Every `codex exec` invocation cold-starts the binary and reloads its skills context before answering. The MCP server pays that once. It also keeps thread state, so `codex-reply` can continue a conversation.

The cost is a resident process — around 140 MB in observed use.

## Configuration

Every option is optional; the defaults are what you want.

| Option | Default | Purpose |
| --- | --- | --- |
| `command` | auto-detected | Full path to the Codex executable |
| `serverName` | `codex` | Tool namespace (`mcp__<serverName>__…`) |
| `cwd` | harness working directory | Working directory for the Codex process |
| `env` | `{}` | Extra environment variables |
| `toolCallTimeoutMs` | `900000` | Per-call ceiling — Codex turns are agent runs, not completions |
| `failOnStartupError` | `false` | Whether a missing Codex should stop the harness booting |

`DSH_CODEX_BINARY` overrides detection without editing config.

### How the executable is found

1. An explicit `command`, or `DSH_CODEX_BINARY`
2. The native binary inside a global `@openai/codex` install, enumerated from disk rather than hardcoded — a new platform or architecture needs no change here
3. A `codex` executable on `PATH`

On Windows the npm `.cmd` and `.ps1` shims are deliberately skipped: the MCP stdio transport spawns without a shell, and a shim cannot be launched that way.

## When Codex is missing

The plugin logs one warning naming the fix and mounts nothing. The harness starts normally with Codex tools absent. Set `failOnStartupError: true` if you would rather boot loudly than run without it.

## Requirements

- DeepSeek Harness with `@deepseek-ai/dsh-mcp-client` `0.1.0-rc.6`–`0.1.0-rc.8`
- Node `^22.19.0 || >=24`
- Codex CLI, signed in
- A ChatGPT plan that includes Codex

Verified against harness `0.1.0-rc.8` and `codex-cli 0.144.5`.

## Uninstall

```sh
dsh plugin --profile web remove dsh-codex-mcp
```

No credentials were stored, so there is nothing else to clean up. Your Codex CLI login is untouched.

## Development

```sh
npm install
npm test
```

Tests build synthetic npm layouts in a temp directory, so the suite passes on machines with no Codex installed. CI runs them on Linux, macOS and Windows across both supported Node versions, and separately verifies that a clean install of the packed tarball works.

## Licence

MIT