@leo000001/codex-mcp 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -22
- package/dist/index.js +9 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,18 +57,23 @@ Add to your MCP client config (e.g. Claude Desktop, Cursor, etc.):
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
###
|
|
60
|
+
### Claude Code
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
|
|
63
|
+
claude mcp add codex-mcp -- npx -y @leo000001/codex-mcp
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
Or add to `~/.
|
|
66
|
+
Or add to `~/.claude/settings.json`:
|
|
67
67
|
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"codex-mcp": {
|
|
72
|
+
"command": "npx",
|
|
73
|
+
"args": ["-y", "@leo000001/codex-mcp"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
72
77
|
```
|
|
73
78
|
|
|
74
79
|
## STDIO Guard Modes
|
|
@@ -95,16 +100,16 @@ $env:CODEX_MCP_STDIO_MODE = "strict"; npx -y @leo000001/codex-mcp
|
|
|
95
100
|
|
|
96
101
|
Start a Codex agent session asynchronously. Returns immediately with `sessionId`.
|
|
97
102
|
|
|
98
|
-
| Parameter | Type | Required | Description
|
|
99
|
-
| ---------------- | ------ | -------- |
|
|
100
|
-
| `prompt` | string | Yes | Task or question for the Codex agent
|
|
101
|
-
| `approvalPolicy` | string | Yes | Approval policy: `untrusted`, `on-failure`, `on-request`, `never` — caller must set based on its own permission level
|
|
102
|
-
| `sandbox` | string | Yes | Sandbox mode: `read-only`, `workspace-write`, `danger-full-access` — caller must set based on its own permission level
|
|
103
|
+
| Parameter | Type | Required | Description |
|
|
104
|
+
| ---------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
105
|
+
| `prompt` | string | Yes | Task or question for the Codex agent |
|
|
106
|
+
| `approvalPolicy` | string | Yes | Approval policy: `untrusted`, `on-failure`, `on-request`, `never` — caller must set based on its own permission level |
|
|
107
|
+
| `sandbox` | string | Yes | Sandbox mode: `read-only`, `workspace-write`, `danger-full-access` — caller must set based on its own permission level |
|
|
103
108
|
| `effort` | string | No | Reasoning effort: `none`, `minimal`, `low`, `medium`, `high`, `xhigh`. Default: `low`; increase/decrease based on task complexity |
|
|
104
|
-
| `cwd` | string | No | Working directory. Default: server cwd
|
|
105
|
-
| `model` | string | No | Model override. Default: from `~/.codex/config.toml`
|
|
106
|
-
| `profile` | string | No | `config.toml` profile name (passed as `codex app-server -p`)
|
|
107
|
-
| `advanced` | object | No | Low-frequency options (see below)
|
|
109
|
+
| `cwd` | string | No | Working directory. Default: server cwd |
|
|
110
|
+
| `model` | string | No | Model override. Default: from `~/.codex/config.toml` |
|
|
111
|
+
| `profile` | string | No | `config.toml` profile name (passed as `codex app-server -p`) |
|
|
112
|
+
| `advanced` | object | No | Low-frequency options (see below) |
|
|
108
113
|
|
|
109
114
|
<details>
|
|
110
115
|
<summary><code>advanced</code> object parameters (9 low-frequency parameters)</summary>
|
|
@@ -203,12 +208,12 @@ Query a running session for events, respond to approval requests, or answer user
|
|
|
203
208
|
|
|
204
209
|
| Parameter | Type | Required | Description |
|
|
205
210
|
| --------------------- | -------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
206
|
-
| `action` | string | Yes | `"poll"`, `"respond_permission"`,
|
|
211
|
+
| `action` | string | Yes | `"poll"`, `"respond_permission"`, or `"respond_user_input"` |
|
|
207
212
|
| `sessionId` | string | Yes | Target session ID |
|
|
208
|
-
| `cursor` | number | No | Event cursor for incremental polling (`action="poll"`). For `respond_*`, codex-mcp applies monotonic cursor progression: `max(cursor, sessionLastCursor)`.
|
|
209
|
-
| `maxEvents` | number | No | Keep this small. `poll` default: `1` (minimum `1`; increase only for catch-up). `respond_*` default: `0` (recommended; compact ACK, no event replay).
|
|
210
|
-
| `responseMode` | string | No | Response shaping mode: `minimal` (default), `delta_compact`, `full`
|
|
211
|
-
| `pollOptions` | object | No | Optional controls: `includeEvents` (default `true`), `includeActions` (default `true`), `includeResult` (default `true`), `maxBytes` (default unlimited)
|
|
213
|
+
| `cursor` | number | No | Event cursor for incremental polling (`action="poll"`). For `respond_*`, codex-mcp applies monotonic cursor progression: `max(cursor, sessionLastCursor)`. |
|
|
214
|
+
| `maxEvents` | number | No | Keep this small. `poll` default: `1` (minimum `1`; increase only for catch-up). `respond_*` default: `0` (recommended; compact ACK, no event replay). |
|
|
215
|
+
| `responseMode` | string | No | Response shaping mode: `minimal` (default), `delta_compact`, `full` |
|
|
216
|
+
| `pollOptions` | object | No | Optional controls: `includeEvents` (default `true`), `includeActions` (default `true`), `includeResult` (default `true`), `maxBytes` (default unlimited) |
|
|
212
217
|
| `requestId` | string | For respond_permission/user_input | Request ID from `actions[]` |
|
|
213
218
|
| `decision` | string | For respond_permission | For command approvals: `"accept"`, `"acceptForSession"`, `"acceptWithExecpolicyAmendment"`, `"decline"`, `"cancel"`; for file changes: `"accept"`, `"acceptForSession"`, `"decline"`, `"cancel"` |
|
|
214
219
|
| `execpolicyAmendment` | string[] | For acceptWithExecpolicyAmendment | Exec policy amendment list (required when `decision="acceptWithExecpolicyAmendment"`) |
|
|
@@ -260,7 +265,6 @@ When the agent requests approval or user input, `poll` includes an `actions[]` l
|
|
|
260
265
|
|
|
261
266
|
- `respond_permission`: `decision` is one of `accept`, `acceptForSession`, `decline`, `cancel`.
|
|
262
267
|
- For command approvals, `acceptWithExecpolicyAmendment` is supported and requires `execpolicyAmendment`.
|
|
263
|
-
- `respond_approval` is still accepted as a deprecated alias for `respond_permission`.
|
|
264
268
|
- `respond_user_input`: send `answers` keyed by `questionId`.
|
|
265
269
|
|
|
266
270
|
Pending approvals auto-decline after `advanced.approvalTimeoutMs`.
|
package/dist/index.js
CHANGED
|
@@ -165,12 +165,7 @@ var PERSONALITIES = ["none", "friendly", "pragmatic"];
|
|
|
165
165
|
var EFFORT_LEVELS = ["none", "minimal", "low", "medium", "high", "xhigh"];
|
|
166
166
|
var SUMMARY_MODES = ["auto", "concise", "detailed", "none"];
|
|
167
167
|
var SESSION_ACTIONS = ["list", "get", "cancel", "interrupt", "fork"];
|
|
168
|
-
var CHECK_ACTIONS = [
|
|
169
|
-
"poll",
|
|
170
|
-
"respond_permission",
|
|
171
|
-
"respond_approval",
|
|
172
|
-
"respond_user_input"
|
|
173
|
-
];
|
|
168
|
+
var CHECK_ACTIONS = ["poll", "respond_permission", "respond_user_input"];
|
|
174
169
|
var RESPONSE_MODES = ["minimal", "delta_compact", "full"];
|
|
175
170
|
var COMMAND_DECISIONS = [
|
|
176
171
|
"accept",
|
|
@@ -218,7 +213,7 @@ var DEFAULT_TERMINAL_CLEANUP_MS = 5 * 60 * 1e3;
|
|
|
218
213
|
var CLEANUP_INTERVAL_MS = 6e4;
|
|
219
214
|
|
|
220
215
|
// src/app-server/client.ts
|
|
221
|
-
var CLIENT_VERSION = true ? "0.2.
|
|
216
|
+
var CLIENT_VERSION = true ? "0.2.1" : "0.0.0-dev";
|
|
222
217
|
var DEFAULT_REQUEST_TIMEOUT = 3e4;
|
|
223
218
|
var STARTUP_REQUEST_TIMEOUT = 9e4;
|
|
224
219
|
var MAX_WRITE_QUEUE_BYTES = 5 * 1024 * 1024;
|
|
@@ -1084,13 +1079,6 @@ var SessionManager = class {
|
|
|
1084
1079
|
actions: actions.length > 0 ? actions : void 0,
|
|
1085
1080
|
result: includeResult && (session.status === "idle" || session.status === "error" || session.status === "cancelled") ? session.lastResult : void 0
|
|
1086
1081
|
};
|
|
1087
|
-
if (pollOptions?.includeTools === true) {
|
|
1088
|
-
addCompatWarningWithinBudget(
|
|
1089
|
-
result,
|
|
1090
|
-
"pollOptions.includeTools is not yet supported by codex-mcp; returning no tool metadata.",
|
|
1091
|
-
maxBytes
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
1094
1082
|
if (typeof maxBytes === "number") {
|
|
1095
1083
|
const normalizedMaxBytes = Math.max(1, Math.floor(maxBytes));
|
|
1096
1084
|
const hasAnyPayload = result.events.length > 0 || typeof result.actions !== "undefined" || typeof result.result !== "undefined";
|
|
@@ -2126,11 +2114,10 @@ function executeCodexCheck(args, sessionManager) {
|
|
|
2126
2114
|
pollOptions
|
|
2127
2115
|
});
|
|
2128
2116
|
}
|
|
2129
|
-
case "respond_permission":
|
|
2130
|
-
case "respond_approval": {
|
|
2117
|
+
case "respond_permission": {
|
|
2131
2118
|
if (!args.requestId || !args.decision) {
|
|
2132
2119
|
return {
|
|
2133
|
-
error: `Error [${"INVALID_ARGUMENT" /* INVALID_ARGUMENT */}]: requestId and decision required for respond_permission
|
|
2120
|
+
error: `Error [${"INVALID_ARGUMENT" /* INVALID_ARGUMENT */}]: requestId and decision required for respond_permission`,
|
|
2134
2121
|
isError: true
|
|
2135
2122
|
};
|
|
2136
2123
|
}
|
|
@@ -2144,18 +2131,10 @@ function executeCodexCheck(args, sessionManager) {
|
|
|
2144
2131
|
return { error: message, isError: true };
|
|
2145
2132
|
}
|
|
2146
2133
|
const maxEvents = args.maxEvents ?? RESPOND_DEFAULT_MAX_EVENTS;
|
|
2147
|
-
|
|
2134
|
+
return sessionManager.pollEventsMonotonic(args.sessionId, args.cursor, maxEvents, {
|
|
2148
2135
|
responseMode,
|
|
2149
2136
|
pollOptions
|
|
2150
2137
|
});
|
|
2151
|
-
if (args.action === "respond_approval") {
|
|
2152
|
-
return addWarning(
|
|
2153
|
-
result,
|
|
2154
|
-
"Action 'respond_approval' is deprecated, use 'respond_permission'.",
|
|
2155
|
-
pollOptions?.maxBytes
|
|
2156
|
-
);
|
|
2157
|
-
}
|
|
2158
|
-
return result;
|
|
2159
2138
|
}
|
|
2160
2139
|
case "respond_user_input": {
|
|
2161
2140
|
if (!args.requestId || !args.answers) {
|
|
@@ -2183,23 +2162,6 @@ function executeCodexCheck(args, sessionManager) {
|
|
|
2183
2162
|
};
|
|
2184
2163
|
}
|
|
2185
2164
|
}
|
|
2186
|
-
function addWarning(result, warning, maxBytes) {
|
|
2187
|
-
if (!result.compatWarnings) result.compatWarnings = [];
|
|
2188
|
-
result.compatWarnings.push(warning);
|
|
2189
|
-
if (typeof maxBytes !== "number") {
|
|
2190
|
-
return result;
|
|
2191
|
-
}
|
|
2192
|
-
const normalizedMaxBytes = Math.max(1, Math.floor(maxBytes));
|
|
2193
|
-
if (Buffer.byteLength(JSON.stringify(result), "utf8") <= normalizedMaxBytes) {
|
|
2194
|
-
return result;
|
|
2195
|
-
}
|
|
2196
|
-
if (result.compatWarnings.length > 1) {
|
|
2197
|
-
result.compatWarnings.pop();
|
|
2198
|
-
} else {
|
|
2199
|
-
result.compatWarnings = void 0;
|
|
2200
|
-
}
|
|
2201
|
-
return result;
|
|
2202
|
-
}
|
|
2203
2165
|
|
|
2204
2166
|
// src/resources/register-resources.ts
|
|
2205
2167
|
import { spawnSync } from "child_process";
|
|
@@ -2465,7 +2427,6 @@ function buildGotchasText() {
|
|
|
2465
2427
|
`- Poll default is \`maxEvents=${POLL_DEFAULT_MAX_EVENTS}\` (authoritative: tool schema / constants).`,
|
|
2466
2428
|
`- Poll enforces minimum \`maxEvents=${POLL_MIN_MAX_EVENTS}\`; sending \`0\` is normalized to \`${POLL_MIN_MAX_EVENTS}\`.`,
|
|
2467
2429
|
`- \`respond_permission\` and \`respond_user_input\` default to compact ACK with \`maxEvents=${RESPOND_DEFAULT_MAX_EVENTS}\`.`,
|
|
2468
|
-
"- `respond_approval` is a deprecated alias for `respond_permission`.",
|
|
2469
2430
|
"- Default response mode is `minimal`; use `full` if you need full raw event payloads.",
|
|
2470
2431
|
"- respond_* uses monotonic cursor handling: `max(cursor, sessionLastCursor)`.",
|
|
2471
2432
|
"- If `cursorResetTo` is present, your cursor is stale (old events were evicted); restart from that value.",
|
|
@@ -2771,7 +2732,7 @@ function registerResources(server, deps) {
|
|
|
2771
2732
|
}
|
|
2772
2733
|
|
|
2773
2734
|
// src/server.ts
|
|
2774
|
-
var SERVER_VERSION = true ? "0.2.
|
|
2735
|
+
var SERVER_VERSION = true ? "0.2.1" : "0.0.0-dev";
|
|
2775
2736
|
function formatErrorMessage(err) {
|
|
2776
2737
|
const message = err instanceof Error ? err.message : String(err);
|
|
2777
2738
|
const m = /^Error \[([A-Z_]+)\]:\s*(.*)$/.exec(message);
|
|
@@ -3000,8 +2961,6 @@ poll: events since cursor. Default maxEvents=${POLL_DEFAULT_MAX_EVENTS}.
|
|
|
3000
2961
|
|
|
3001
2962
|
respond_permission: approval decision. Default maxEvents=${RESPOND_DEFAULT_MAX_EVENTS} (compact ACK).
|
|
3002
2963
|
|
|
3003
|
-
respond_approval: deprecated alias for respond_permission.
|
|
3004
|
-
|
|
3005
2964
|
respond_user_input: user-input answers. Default maxEvents=${RESPOND_DEFAULT_MAX_EVENTS} (compact ACK).
|
|
3006
2965
|
|
|
3007
2966
|
events[].type is coarse-grained; details are in events[].data.method.
|
|
@@ -3018,13 +2977,12 @@ cursor omitted => use session last cursor. cursorResetTo => reset and continue.`
|
|
|
3018
2977
|
includeEvents: z.boolean().optional().describe("Default: true. Include events[] in response."),
|
|
3019
2978
|
includeActions: z.boolean().optional().describe("Default: true. Include actions[] in response."),
|
|
3020
2979
|
includeResult: z.boolean().optional().describe("Default: true. Include result in response."),
|
|
3021
|
-
maxBytes: z.number().int().positive().optional().describe("Default: unlimited. Best-effort response payload cap in bytes.")
|
|
3022
|
-
includeTools: z.boolean().optional().describe("Default: false. Reserved for future dynamic tool metadata support.")
|
|
2980
|
+
maxBytes: z.number().int().positive().optional().describe("Default: unlimited. Best-effort response payload cap in bytes.")
|
|
3023
2981
|
}).optional().describe("Optional poll shaping controls."),
|
|
3024
|
-
// respond_permission
|
|
2982
|
+
// respond_permission
|
|
3025
2983
|
requestId: z.string().optional().describe("Request ID from actions[]"),
|
|
3026
2984
|
decision: z.enum(ALL_DECISIONS).optional().describe(
|
|
3027
|
-
"Approval decision for respond_permission
|
|
2985
|
+
"Approval decision for respond_permission. acceptWithExecpolicyAmendment requires execpolicyAmendment."
|
|
3028
2986
|
),
|
|
3029
2987
|
execpolicyAmendment: z.array(z.string()).optional().describe("For acceptWithExecpolicyAmendment only"),
|
|
3030
2988
|
denyMessage: z.string().optional().describe("Deny reason (not sent to agent)"),
|