@trishchuk/codex-mcp-tool 1.0.6 → 1.3.0
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 +92 -16
- package/dist/constants.d.ts +64 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +85 -31
- package/dist/constants.js.map +1 -1
- package/dist/index.js +28 -26
- package/dist/index.js.map +1 -1
- package/dist/tools/apply-diff.tool.d.ts +3 -0
- package/dist/tools/apply-diff.tool.d.ts.map +1 -0
- package/dist/tools/apply-diff.tool.js +52 -0
- package/dist/tools/apply-diff.tool.js.map +1 -0
- package/dist/tools/ask-codex.tool.d.ts.map +1 -1
- package/dist/tools/ask-codex.tool.js +171 -33
- package/dist/tools/ask-codex.tool.js.map +1 -1
- package/dist/tools/batch-codex.tool.d.ts +3 -0
- package/dist/tools/batch-codex.tool.d.ts.map +1 -0
- package/dist/tools/batch-codex.tool.js +134 -0
- package/dist/tools/batch-codex.tool.js.map +1 -0
- package/dist/tools/brainstorm.tool.d.ts.map +1 -1
- package/dist/tools/brainstorm.tool.js +62 -29
- package/dist/tools/brainstorm.tool.js.map +1 -1
- package/dist/tools/exec-codex.tool.d.ts +3 -0
- package/dist/tools/exec-codex.tool.d.ts.map +1 -0
- package/dist/tools/exec-codex.tool.js +46 -0
- package/dist/tools/exec-codex.tool.js.map +1 -0
- package/dist/tools/fetch-chunk.tool.d.ts.map +1 -1
- package/dist/tools/fetch-chunk.tool.js +12 -8
- package/dist/tools/fetch-chunk.tool.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/registry.d.ts +3 -3
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +9 -5
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/review-codex.tool.d.ts +3 -0
- package/dist/tools/review-codex.tool.d.ts.map +1 -0
- package/dist/tools/review-codex.tool.js +91 -0
- package/dist/tools/review-codex.tool.js.map +1 -0
- package/dist/tools/simple-tools.d.ts +1 -0
- package/dist/tools/simple-tools.d.ts.map +1 -1
- package/dist/tools/simple-tools.js +42 -11
- package/dist/tools/simple-tools.js.map +1 -1
- package/dist/tools/test-tool.example.d.ts.map +1 -1
- package/dist/tools/test-tool.example.js +12 -10
- package/dist/tools/test-tool.example.js.map +1 -1
- package/dist/tools/timeout-test.tool.js +5 -5
- package/dist/tools/timeout-test.tool.js.map +1 -1
- package/dist/utils/changeModeChunker.d.ts.map +1 -1
- package/dist/utils/changeModeChunker.js +10 -6
- package/dist/utils/changeModeChunker.js.map +1 -1
- package/dist/utils/changeModeParser.d.ts.map +1 -1
- package/dist/utils/changeModeParser.js.map +1 -1
- package/dist/utils/changeModeRunner.d.ts.map +1 -1
- package/dist/utils/changeModeRunner.js +17 -11
- package/dist/utils/changeModeRunner.js.map +1 -1
- package/dist/utils/changeModeTranslator.d.ts.map +1 -1
- package/dist/utils/changeModeTranslator.js +5 -2
- package/dist/utils/changeModeTranslator.js.map +1 -1
- package/dist/utils/chunkCache.d.ts.map +1 -1
- package/dist/utils/chunkCache.js +6 -4
- package/dist/utils/chunkCache.js.map +1 -1
- package/dist/utils/codexCommandBuilder.d.ts +80 -0
- package/dist/utils/codexCommandBuilder.d.ts.map +1 -0
- package/dist/utils/codexCommandBuilder.js +259 -0
- package/dist/utils/codexCommandBuilder.js.map +1 -0
- package/dist/utils/codexExecutor.d.ts +19 -0
- package/dist/utils/codexExecutor.d.ts.map +1 -1
- package/dist/utils/codexExecutor.js +49 -57
- package/dist/utils/codexExecutor.js.map +1 -1
- package/dist/utils/commandExecutor.d.ts.map +1 -1
- package/dist/utils/commandExecutor.js +25 -17
- package/dist/utils/commandExecutor.js.map +1 -1
- package/dist/utils/fibonacci.d.ts +2 -0
- package/dist/utils/fibonacci.d.ts.map +1 -0
- package/dist/utils/fibonacci.js +17 -0
- package/dist/utils/fibonacci.js.map +1 -0
- package/dist/utils/gitHelper.d.ts +20 -0
- package/dist/utils/gitHelper.d.ts.map +1 -0
- package/dist/utils/gitHelper.js +66 -0
- package/dist/utils/gitHelper.js.map +1 -0
- package/dist/utils/logger.d.ts +2 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +21 -15
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/modelDetection.d.ts +45 -0
- package/dist/utils/modelDetection.d.ts.map +1 -0
- package/dist/utils/modelDetection.js +148 -0
- package/dist/utils/modelDetection.js.map +1 -0
- package/dist/utils/outputParser.d.ts +26 -0
- package/dist/utils/outputParser.d.ts.map +1 -0
- package/dist/utils/outputParser.js +174 -0
- package/dist/utils/outputParser.js.map +1 -0
- package/dist/utils/reviewParser.d.ts +28 -0
- package/dist/utils/reviewParser.d.ts.map +1 -0
- package/dist/utils/reviewParser.js +87 -0
- package/dist/utils/reviewParser.js.map +1 -0
- package/dist/utils/versionDetection.d.ts +108 -0
- package/dist/utils/versionDetection.d.ts.map +1 -0
- package/dist/utils/versionDetection.js +160 -0
- package/dist/utils/versionDetection.js.map +1 -0
- package/dist/utils/workingDirResolver.d.ts +52 -0
- package/dist/utils/workingDirResolver.d.ts.map +1 -0
- package/dist/utils/workingDirResolver.js +217 -0
- package/dist/utils/workingDirResolver.js.map +1 -0
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# Codex MCP Tool
|
|
3
2
|
|
|
4
3
|
<div align="center">
|
|
@@ -11,7 +10,6 @@
|
|
|
11
10
|
|
|
12
11
|
</div>
|
|
13
12
|
|
|
14
|
-
|
|
15
13
|
Codex MCP Tool is an open‑source Model Context Protocol (MCP) server that connects your IDE or AI assistant (Claude, Cursor, etc.) to the Codex CLI. It enables non‑interactive automation with `codex exec`, safe sandboxed edits with approvals, and large‑scale code analysis via `@` file references. Built for reliability and speed, it streams progress updates, supports structured change mode (OLD/NEW patch output), and integrates cleanly with standard MCP clients for code review, refactoring, documentation, and CI automation.
|
|
16
14
|
|
|
17
15
|
- Ask Codex questions from your MCP client, or brainstorm ideas programmatically.
|
|
@@ -31,6 +29,11 @@ Before using this tool, ensure you have:
|
|
|
31
29
|
1. **[Node.js](https://nodejs.org/)** (v18.0.0 or higher)
|
|
32
30
|
2. **[Codex CLI](https://github.com/openai/codex)** installed and authenticated
|
|
33
31
|
|
|
32
|
+
### Platform Support
|
|
33
|
+
|
|
34
|
+
✅ **Windows, macOS, and Linux fully supported**
|
|
35
|
+
|
|
36
|
+
**v1.2.4** introduced cross-platform compatibility improvements using `cross-spawn`, ensuring reliable command execution across all operating systems. Windows users no longer experience "spawn codex ENOENT" errors.
|
|
34
37
|
|
|
35
38
|
### One-Line Setup
|
|
36
39
|
|
|
@@ -49,6 +52,7 @@ Type `/mcp` inside Claude Code to verify the Codex MCP is active.
|
|
|
49
52
|
If you already have it configured in Claude Desktop:
|
|
50
53
|
|
|
51
54
|
1. Add to your Claude Desktop config:
|
|
55
|
+
|
|
52
56
|
```json
|
|
53
57
|
"codex-cli": {
|
|
54
58
|
"command": "npx",
|
|
@@ -57,6 +61,7 @@ If you already have it configured in Claude Desktop:
|
|
|
57
61
|
```
|
|
58
62
|
|
|
59
63
|
2. Import to Claude Code:
|
|
64
|
+
|
|
60
65
|
```bash
|
|
61
66
|
claude mcp add-from-claude-desktop
|
|
62
67
|
```
|
|
@@ -112,21 +117,29 @@ After updating the configuration, restart your terminal session.
|
|
|
112
117
|
|
|
113
118
|
### Model Selection
|
|
114
119
|
|
|
120
|
+
Default: `gpt-5.1-codex-max` (v1.3.0+) with automatic fallback → `gpt-5-codex` → `gpt-5` when newer models are unavailable.
|
|
121
|
+
|
|
122
|
+
**GPT-5.1 family with examples**
|
|
123
|
+
|
|
124
|
+
- `gpt-5.1-codex-max` — default for complex, multi-file edits (`'use codex to refactor @src with model gpt-5.1-codex-max'`)
|
|
125
|
+
- `gpt-5.1-codex-mini` — cost-efficient quick passes (`'use codex with model gpt-5.1-codex-mini to scan @utils'`)
|
|
126
|
+
- `gpt-5.1`, `gpt-5.1-mini`, `gpt-5.1-nano` — general-purpose GPT-5.1 variants (`'ask codex using gpt-5.1-nano for a fast read on @README.md'`)
|
|
127
|
+
|
|
115
128
|
```javascript
|
|
116
|
-
// Use the default gpt-5-codex model
|
|
117
|
-
|
|
129
|
+
// Use the default gpt-5.1-codex-max model (falls back to gpt-5-codex → gpt-5)
|
|
130
|
+
'explain the architecture of @src/';
|
|
118
131
|
|
|
119
132
|
// Use gpt-5 for fast general purpose reasoning
|
|
120
|
-
|
|
133
|
+
'use codex with model gpt-5 to analyze @config.json';
|
|
121
134
|
|
|
122
135
|
// Use o3 for deep reasoning tasks
|
|
123
|
-
|
|
136
|
+
'use codex with model o3 to analyze complex algorithm in @algorithm.py';
|
|
124
137
|
|
|
125
138
|
// Use o4-mini for quick tasks
|
|
126
|
-
|
|
139
|
+
'use codex with model o4-mini to add comments to @utils.js';
|
|
127
140
|
|
|
128
141
|
// Use codex-1 for software engineering
|
|
129
|
-
|
|
142
|
+
'use codex with model codex-1 to refactor @legacy-code.js';
|
|
130
143
|
```
|
|
131
144
|
|
|
132
145
|
### With File References (using @ syntax)
|
|
@@ -153,17 +166,23 @@ Codex supports approval/sandbox modes. This server uses `codex exec` and can opt
|
|
|
153
166
|
- `use codex to create and run a Python script that processes data`
|
|
154
167
|
- `ask codex to safely test @script.py and explain what it does`
|
|
155
168
|
|
|
169
|
+
### Native Search
|
|
170
|
+
|
|
171
|
+
- Enable search with `search:true` or the `--search` flag; defaults to `workspace-write` sandbox for network access
|
|
172
|
+
- Dual-flag compatibility: sends native `--search` on Codex CLI v0.52.0+ and always enables the `web_search_request` feature flag for older versions
|
|
173
|
+
- Works alongside `oss`/feature toggles without manual client changes
|
|
174
|
+
|
|
156
175
|
### Advanced Examples
|
|
157
176
|
|
|
158
177
|
```javascript
|
|
159
178
|
// Using ask-codex with specific model
|
|
160
|
-
|
|
179
|
+
'ask codex using gpt-5 to refactor @utils/database.js for better performance';
|
|
161
180
|
|
|
162
181
|
// Brainstorming with constraints
|
|
163
|
-
"brainstorm solutions for reducing API latency with constraints: 'must use existing infrastructure, budget under $5k'"
|
|
182
|
+
"brainstorm solutions for reducing API latency with constraints: 'must use existing infrastructure, budget under $5k'";
|
|
164
183
|
|
|
165
184
|
// Change mode for structured edits
|
|
166
|
-
|
|
185
|
+
'use codex in change mode to update all console.log to use winston logger in @src/';
|
|
167
186
|
```
|
|
168
187
|
|
|
169
188
|
### Tools (for the AI)
|
|
@@ -174,22 +193,28 @@ These tools are designed to be used by the AI assistant.
|
|
|
174
193
|
|
|
175
194
|
- **`ask-codex`**: Sends a prompt to Codex via `codex exec`.
|
|
176
195
|
- Supports `@` file references for including file content
|
|
177
|
-
- Optional `model` parameter -
|
|
178
|
-
|
|
196
|
+
- Optional `model` parameter; default: `gpt-5.1-codex-max` with fallback chain `gpt-5.1-codex-max → gpt-5-codex → gpt-5` when a model is unavailable
|
|
197
|
+
- GPT-5.1 family stays enabled automatically on Codex CLI v0.56.0+; older CLI versions trigger the fallback chain
|
|
198
|
+
- Available models:
|
|
199
|
+
- `gpt-5.1-codex-max` (NEW DEFAULT v1.3.0, highest reliability)
|
|
200
|
+
- `gpt-5.1-codex-mini` (cost-efficient, quick tasks)
|
|
201
|
+
- `gpt-5.1`, `gpt-5.1-mini`, `gpt-5.1-nano` (GPT-5.1 family)
|
|
202
|
+
- `gpt-5-codex` (previous default, still supported)
|
|
179
203
|
- `gpt-5` (general purpose, fast reasoning)
|
|
180
204
|
- `o3` (smartest, deep reasoning)
|
|
181
205
|
- `o4-mini` (fast & efficient)
|
|
182
206
|
- `codex-1` (o3-based for software engineering)
|
|
183
207
|
- `codex-mini-latest` (low-latency code Q&A)
|
|
184
|
-
- `gpt-4.1` (
|
|
208
|
+
- `gpt-4.1` (legacy support)
|
|
209
|
+
- Native Search: uses dual flags (adds `--search` on v0.52.0+ and always enables `web_search_request`) for compatibility
|
|
185
210
|
- `sandbox=true` enables `--full-auto` mode
|
|
186
211
|
- `changeMode=true` returns structured OLD/NEW edits
|
|
187
|
-
- Supports approval policies and
|
|
212
|
+
- Supports approval policies, sandbox modes, and verbose control via `toolOutputTokenLimit`
|
|
188
213
|
|
|
189
214
|
- **`brainstorm`**: Generate novel ideas with structured methodologies.
|
|
190
215
|
- Multiple frameworks: divergent, convergent, SCAMPER, design-thinking, lateral
|
|
191
216
|
- Domain-specific context (software, business, creative, research, product, marketing)
|
|
192
|
-
- Supports same models as `ask-codex` (default: `gpt-5-codex`)
|
|
217
|
+
- Supports same models as `ask-codex` (default: `gpt-5.1-codex-max` with the same fallback chain)
|
|
193
218
|
- Configurable idea count and analysis depth
|
|
194
219
|
- Includes feasibility, impact, and innovation scoring
|
|
195
220
|
- Example: `brainstorm prompt:"ways to improve code review process" domain:"software" methodology:"scamper"`
|
|
@@ -210,6 +235,26 @@ These tools are designed to be used by the AI assistant.
|
|
|
210
235
|
- Runs for a specified duration in milliseconds
|
|
211
236
|
- Useful for testing long-running operations
|
|
212
237
|
|
|
238
|
+
## Advanced Features (v1.3.0+)
|
|
239
|
+
|
|
240
|
+
### Version Detection & Compatibility
|
|
241
|
+
|
|
242
|
+
- Automatically parses `codex --version` to toggle feature flags and pick the safest model available
|
|
243
|
+
- GPT-5.1 family is auto-enabled on Codex CLI v0.56.0+; older versions gracefully fall back to `gpt-5-codex` → `gpt-5`
|
|
244
|
+
- Native search, `--add-dir`, and token-limit flags are only sent when your installed CLI supports them
|
|
245
|
+
|
|
246
|
+
### Multi-Directory Projects
|
|
247
|
+
|
|
248
|
+
- Use `addDirs` to allow writes across multiple repositories or temp folders (requires Codex CLI v0.59.0+)
|
|
249
|
+
- Example: `ask codex prompt:"upgrade shared configs" addDirs:["../shared-config","/tmp/sandbox"]`
|
|
250
|
+
- The tool auto-skips unsupported flags on older CLI builds while logging a warning
|
|
251
|
+
|
|
252
|
+
### Response Verbosity Control
|
|
253
|
+
|
|
254
|
+
- Cap tool outputs with `toolOutputTokenLimit` (range: 100–10,000) to tame noisy commands
|
|
255
|
+
- Example: `ask codex prompt:"summarize @logs" toolOutputTokenLimit:500`
|
|
256
|
+
- Great for CI logs or quick scans where concise responses are needed
|
|
257
|
+
|
|
213
258
|
### Slash Commands (for the User)
|
|
214
259
|
|
|
215
260
|
You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested).
|
|
@@ -222,6 +267,37 @@ You can use these commands directly in Claude Code's interface (compatibility wi
|
|
|
222
267
|
- **/ping**: Tests the connection to the server.
|
|
223
268
|
- **`message`** (optional): A message to echo back.
|
|
224
269
|
|
|
270
|
+
## Codex CLI Compatibility
|
|
271
|
+
|
|
272
|
+
| Codex CLI version | What you get | Model behavior |
|
|
273
|
+
| ----------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
274
|
+
| v0.59.0+ | `--add-dir`, `tool_output_token_limit`, Windows agent mode | Full GPT-5.1 support with fallback chain `gpt-5.1-codex-max → gpt-5-codex → gpt-5` |
|
|
275
|
+
| v0.56.0+ | GPT-5.1 family unlocked | Uses GPT-5.1 models directly; still falls back if a model is missing |
|
|
276
|
+
| v0.52.0+ | Native `--search` flag | Dual-flag search (`--search` + `web_search_request`) for reliability |
|
|
277
|
+
| earlier | Legacy-only flags | Forces fallback to `gpt-5-codex`/`gpt-5`, skips unsupported flags with warnings |
|
|
278
|
+
|
|
279
|
+
## Troubleshooting (legacy versions)
|
|
280
|
+
|
|
281
|
+
- Run `codex --version` to confirm your CLI build; upgrade to v0.59.0+ for full v1.3.0 features
|
|
282
|
+
- If GPT-5.1 models error on older CLIs, explicitly set `model:"gpt-5-codex"` (the fallback will apply automatically otherwise)
|
|
283
|
+
- Remove `addDirs` or `toolOutputTokenLimit` if you see unsupported flag warnings; they require v0.59.0+
|
|
284
|
+
- Web search issues on pre-v0.52.0 builds: rely on the `web_search_request` feature flag only, or upgrade for the `--search` flag
|
|
285
|
+
|
|
286
|
+
## FAQ
|
|
287
|
+
|
|
288
|
+
- **What model is used by default?** `gpt-5.1-codex-max` with fallback to `gpt-5-codex` then `gpt-5`.
|
|
289
|
+
- **How do I switch to a cheaper model?** Set `model:"gpt-5.1-codex-mini"` (or `gpt-5.1-nano` for fastest scans) in your tool call.
|
|
290
|
+
- **Can I limit output verbosity?** Yes—use `toolOutputTokenLimit` between 100 and 10,000 to cap tool responses.
|
|
291
|
+
- **How do I let Codex touch multiple repos?** Pass `addDirs:["../shared","/tmp/work"]` (CLI v0.59.0+); older versions will warn and skip the flag.
|
|
292
|
+
- **How is native search handled?** The tool sends both `--search` (when available) and the `web_search_request` feature flag to stay compatible.
|
|
293
|
+
|
|
294
|
+
## Migration: v1.2.x → v1.3.0
|
|
295
|
+
|
|
296
|
+
- Default model switches to `gpt-5.1-codex-max`; fallback chain now formalized (`gpt-5.1-codex-max → gpt-5-codex → gpt-5`)
|
|
297
|
+
- New features: `addDirs` for multi-directory writes and `toolOutputTokenLimit` for output control (both require Codex CLI v0.59.0+)
|
|
298
|
+
- Native search now uses the dual-flag approach automatically; no config changes needed
|
|
299
|
+
- Recommendation: update Codex CLI to v0.59.0+ and refresh your MCP config (no schema changes—existing `/mcp` entries still work)
|
|
300
|
+
|
|
225
301
|
## Acknowledgments
|
|
226
302
|
|
|
227
303
|
This project was inspired by the excellent work from [jamubc/gemini-mcp-tool](https://github.com/jamubc/gemini-mcp-tool). Special thanks to [@jamubc](https://github.com/jamubc) for the original MCP server architecture and implementation patterns.
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,14 +2,45 @@ export declare const LOG_PREFIX = "[CODEX-MCP]";
|
|
|
2
2
|
export declare const ERROR_MESSAGES: {
|
|
3
3
|
readonly TOOL_NOT_FOUND: "not found in registry";
|
|
4
4
|
readonly NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions";
|
|
5
|
+
readonly QUOTA_EXCEEDED: "Rate limit exceeded";
|
|
6
|
+
readonly AUTHENTICATION_FAILED: "Authentication failed - please check your OpenAI API key or login status";
|
|
7
|
+
readonly CODEX_NOT_FOUND: "Codex CLI not found - please install with 'npm install -g @openai/codex'";
|
|
8
|
+
readonly SANDBOX_VIOLATION: "Operation blocked by sandbox policy";
|
|
9
|
+
readonly UNSAFE_COMMAND: "Command requires approval or elevated permissions";
|
|
5
10
|
};
|
|
6
11
|
export declare const STATUS_MESSAGES: {
|
|
7
12
|
readonly SANDBOX_EXECUTING: "🔒 Executing CLI command in sandbox/auto mode...";
|
|
8
13
|
readonly CODEX_RESPONSE: "Codex response:";
|
|
14
|
+
readonly AUTHENTICATION_SUCCESS: "✅ Authentication successful";
|
|
9
15
|
readonly PROCESSING_START: "🔍 Starting analysis (may take 5-15 minutes for large codebases)";
|
|
10
16
|
readonly PROCESSING_CONTINUE: "⏳ Still processing...";
|
|
11
17
|
readonly PROCESSING_COMPLETE: "✅ Analysis completed successfully";
|
|
12
18
|
};
|
|
19
|
+
export declare const MODELS: {
|
|
20
|
+
readonly GPT5_1_CODEX_MAX: "gpt-5.1-codex-max";
|
|
21
|
+
readonly GPT5_1_CODEX_MINI: "gpt-5.1-codex-mini";
|
|
22
|
+
readonly GPT5_1: "gpt-5.1";
|
|
23
|
+
readonly GPT5_1_MINI: "gpt-5.1-mini";
|
|
24
|
+
readonly GPT5_1_NANO: "gpt-5.1-nano";
|
|
25
|
+
readonly GPT5_CODEX: "gpt-5-codex";
|
|
26
|
+
readonly GPT5: "gpt-5";
|
|
27
|
+
readonly O3: "o3";
|
|
28
|
+
readonly O4_MINI: "o4-mini";
|
|
29
|
+
readonly CODEX_1: "codex-1";
|
|
30
|
+
readonly CODEX_MINI_LATEST: "codex-mini-latest";
|
|
31
|
+
readonly GPT_4_1: "gpt-4.1";
|
|
32
|
+
};
|
|
33
|
+
export declare const SANDBOX_MODES: {
|
|
34
|
+
readonly READ_ONLY: "read-only";
|
|
35
|
+
readonly WORKSPACE_WRITE: "workspace-write";
|
|
36
|
+
readonly DANGER_FULL_ACCESS: "danger-full-access";
|
|
37
|
+
};
|
|
38
|
+
export declare const APPROVAL_POLICIES: {
|
|
39
|
+
readonly UNTRUSTED: "untrusted";
|
|
40
|
+
readonly ON_FAILURE: "on-failure";
|
|
41
|
+
readonly ON_REQUEST: "on-request";
|
|
42
|
+
readonly NEVER: "never";
|
|
43
|
+
};
|
|
13
44
|
export declare const PROTOCOL: {
|
|
14
45
|
readonly ROLES: {
|
|
15
46
|
readonly USER: "user";
|
|
@@ -32,6 +63,7 @@ export declare const PROTOCOL: {
|
|
|
32
63
|
export declare const CLI: {
|
|
33
64
|
readonly COMMANDS: {
|
|
34
65
|
readonly CODEX: "codex";
|
|
66
|
+
readonly CODEX_EXEC: "codex exec";
|
|
35
67
|
readonly ECHO: "echo";
|
|
36
68
|
};
|
|
37
69
|
readonly FLAGS: {
|
|
@@ -40,37 +72,67 @@ export declare const CLI: {
|
|
|
40
72
|
readonly FULL_AUTO: "--full-auto";
|
|
41
73
|
readonly ASK_FOR_APPROVAL: "--ask-for-approval";
|
|
42
74
|
readonly SANDBOX_MODE: "--sandbox";
|
|
75
|
+
readonly APPROVAL: "-a";
|
|
43
76
|
readonly YOLO: "--dangerously-bypass-approvals-and-sandbox";
|
|
44
77
|
readonly CD: "--cd";
|
|
45
|
-
readonly SKIP_GIT_REPO_CHECK: "--skip-git-repo-check";
|
|
46
78
|
readonly PROMPT: "-p";
|
|
47
79
|
readonly HELP: "-help";
|
|
80
|
+
readonly IMAGE: "-i";
|
|
81
|
+
readonly PROFILE: "--profile";
|
|
82
|
+
readonly CONFIG: "-c";
|
|
83
|
+
readonly VERSION: "--version";
|
|
84
|
+
readonly WORKING_DIR: "-C";
|
|
85
|
+
readonly OSS: "--oss";
|
|
86
|
+
readonly ENABLE: "--enable";
|
|
87
|
+
readonly DISABLE: "--disable";
|
|
88
|
+
readonly SEARCH: "--search";
|
|
89
|
+
readonly ADD_DIR: "--add-dir";
|
|
48
90
|
};
|
|
49
91
|
readonly DEFAULTS: {
|
|
50
92
|
readonly MODEL: "default";
|
|
51
93
|
readonly BOOLEAN_TRUE: "true";
|
|
52
94
|
readonly BOOLEAN_FALSE: "false";
|
|
53
95
|
};
|
|
96
|
+
readonly ENV_VARS: {
|
|
97
|
+
readonly CODEX_MCP_CWD: "CODEX_MCP_CWD";
|
|
98
|
+
readonly PWD: "PWD";
|
|
99
|
+
readonly INIT_CWD: "INIT_CWD";
|
|
100
|
+
};
|
|
54
101
|
};
|
|
55
102
|
export interface ToolArguments {
|
|
56
103
|
prompt?: string;
|
|
57
104
|
model?: string;
|
|
58
105
|
sandbox?: boolean | string;
|
|
59
106
|
approvalPolicy?: 'never' | 'on-request' | 'on-failure' | 'untrusted';
|
|
107
|
+
approval?: string;
|
|
60
108
|
sandboxMode?: 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
61
109
|
fullAuto?: boolean | string;
|
|
62
110
|
yolo?: boolean | string;
|
|
63
111
|
cd?: string;
|
|
112
|
+
workingDir?: string;
|
|
64
113
|
changeMode?: boolean | string;
|
|
65
114
|
chunkIndex?: number | string;
|
|
66
115
|
chunkCacheKey?: string;
|
|
67
116
|
message?: string;
|
|
117
|
+
image?: string | string[];
|
|
118
|
+
config?: string | Record<string, any>;
|
|
119
|
+
profile?: string;
|
|
120
|
+
timeout?: number;
|
|
121
|
+
useExec?: boolean;
|
|
122
|
+
includeThinking?: boolean;
|
|
123
|
+
includeMetadata?: boolean;
|
|
124
|
+
search?: boolean;
|
|
125
|
+
oss?: boolean;
|
|
126
|
+
enableFeatures?: string[];
|
|
127
|
+
disableFeatures?: string[];
|
|
128
|
+
addDirs?: string[];
|
|
129
|
+
toolOutputTokenLimit?: number;
|
|
68
130
|
methodology?: string;
|
|
69
131
|
domain?: string;
|
|
70
132
|
constraints?: string;
|
|
71
133
|
existingContext?: string;
|
|
72
134
|
ideaCount?: number;
|
|
73
135
|
includeAnalysis?: boolean;
|
|
74
|
-
[key: string]: string | boolean | number | undefined;
|
|
136
|
+
[key: string]: string | boolean | number | string[] | Record<string, any> | undefined;
|
|
75
137
|
}
|
|
76
138
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,gBAAgB,CAAC;AAGxC,eAAO,MAAM,cAAc;;;;;;;;CASjB,CAAC;AAGX,eAAO,MAAM,eAAe;;;;;;;CAQlB,CAAC;AAGX,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAgBT,CAAC;AAGX,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAGX,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAGX,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;CAuBX,CAAC;AAGX,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CN,CAAC;AAGX,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE3B,cAAc,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;IACrE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;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_NOT_FOUND: 'not found in registry',
|
|
6
6
|
NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions",
|
|
7
|
+
QUOTA_EXCEEDED: 'Rate limit exceeded',
|
|
8
|
+
AUTHENTICATION_FAILED: 'Authentication failed - please check your OpenAI API key or login status',
|
|
9
|
+
CODEX_NOT_FOUND: "Codex CLI not found - please install with 'npm install -g @openai/codex'",
|
|
10
|
+
SANDBOX_VIOLATION: 'Operation blocked by sandbox policy',
|
|
11
|
+
UNSAFE_COMMAND: 'Command requires approval or elevated permissions',
|
|
7
12
|
};
|
|
8
13
|
// Status messages
|
|
9
14
|
export const STATUS_MESSAGES = {
|
|
10
|
-
SANDBOX_EXECUTING:
|
|
11
|
-
CODEX_RESPONSE:
|
|
15
|
+
SANDBOX_EXECUTING: '🔒 Executing CLI command in sandbox/auto mode...',
|
|
16
|
+
CODEX_RESPONSE: 'Codex response:',
|
|
17
|
+
AUTHENTICATION_SUCCESS: '✅ Authentication successful',
|
|
12
18
|
// Timeout prevention messages
|
|
13
|
-
PROCESSING_START:
|
|
14
|
-
PROCESSING_CONTINUE:
|
|
15
|
-
PROCESSING_COMPLETE:
|
|
19
|
+
PROCESSING_START: '🔍 Starting analysis (may take 5-15 minutes for large codebases)',
|
|
20
|
+
PROCESSING_CONTINUE: '⏳ Still processing...',
|
|
21
|
+
PROCESSING_COMPLETE: '✅ Analysis completed successfully',
|
|
22
|
+
};
|
|
23
|
+
// Models
|
|
24
|
+
export const MODELS = {
|
|
25
|
+
// GPT-5.1 Series (Latest - 2025)
|
|
26
|
+
GPT5_1_CODEX_MAX: 'gpt-5.1-codex-max', // Default (v1.3.0+): Frontier agentic coding with highest reliability
|
|
27
|
+
GPT5_1_CODEX_MINI: 'gpt-5.1-codex-mini', // Cost-efficient compact model
|
|
28
|
+
GPT5_1: 'gpt-5.1', // General purpose GPT-5.1
|
|
29
|
+
GPT5_1_MINI: 'gpt-5.1-mini', // Balanced performance
|
|
30
|
+
GPT5_1_NANO: 'gpt-5.1-nano', // Fastest for simple queries
|
|
31
|
+
// GPT-5 Series (Legacy)
|
|
32
|
+
GPT5_CODEX: 'gpt-5-codex', // Previous default
|
|
33
|
+
GPT5: 'gpt-5',
|
|
34
|
+
// Other Models
|
|
35
|
+
O3: 'o3',
|
|
36
|
+
O4_MINI: 'o4-mini',
|
|
37
|
+
CODEX_1: 'codex-1',
|
|
38
|
+
CODEX_MINI_LATEST: 'codex-mini-latest',
|
|
39
|
+
GPT_4_1: 'gpt-4.1',
|
|
40
|
+
};
|
|
41
|
+
// Sandbox modes
|
|
42
|
+
export const SANDBOX_MODES = {
|
|
43
|
+
READ_ONLY: 'read-only',
|
|
44
|
+
WORKSPACE_WRITE: 'workspace-write',
|
|
45
|
+
DANGER_FULL_ACCESS: 'danger-full-access',
|
|
46
|
+
};
|
|
47
|
+
// Approval policies
|
|
48
|
+
export const APPROVAL_POLICIES = {
|
|
49
|
+
UNTRUSTED: 'untrusted',
|
|
50
|
+
ON_FAILURE: 'on-failure',
|
|
51
|
+
ON_REQUEST: 'on-request',
|
|
52
|
+
NEVER: 'never',
|
|
16
53
|
};
|
|
17
|
-
// Models: pass-through via Codex CLI
|
|
18
54
|
// MCP Protocol Constants
|
|
19
55
|
export const PROTOCOL = {
|
|
20
56
|
// Message roles
|
|
21
57
|
ROLES: {
|
|
22
|
-
USER:
|
|
23
|
-
ASSISTANT:
|
|
58
|
+
USER: 'user',
|
|
59
|
+
ASSISTANT: 'assistant',
|
|
24
60
|
},
|
|
25
61
|
// Content types
|
|
26
62
|
CONTENT_TYPES: {
|
|
27
|
-
TEXT:
|
|
63
|
+
TEXT: 'text',
|
|
28
64
|
},
|
|
29
65
|
// Status codes
|
|
30
66
|
STATUS: {
|
|
31
|
-
SUCCESS:
|
|
32
|
-
ERROR:
|
|
33
|
-
FAILED:
|
|
34
|
-
REPORT:
|
|
67
|
+
SUCCESS: 'success',
|
|
68
|
+
ERROR: 'error',
|
|
69
|
+
FAILED: 'failed',
|
|
70
|
+
REPORT: 'report',
|
|
35
71
|
},
|
|
36
72
|
// Notification methods
|
|
37
73
|
NOTIFICATIONS: {
|
|
38
|
-
PROGRESS:
|
|
74
|
+
PROGRESS: 'notifications/progress',
|
|
39
75
|
},
|
|
40
76
|
// Timeout prevention
|
|
41
77
|
KEEPALIVE_INTERVAL: 25000, // 25 seconds
|
|
@@ -44,27 +80,45 @@ export const PROTOCOL = {
|
|
|
44
80
|
export const CLI = {
|
|
45
81
|
// Command names
|
|
46
82
|
COMMANDS: {
|
|
47
|
-
CODEX:
|
|
48
|
-
|
|
83
|
+
CODEX: 'codex',
|
|
84
|
+
CODEX_EXEC: 'codex exec',
|
|
85
|
+
ECHO: 'echo',
|
|
49
86
|
},
|
|
50
87
|
// Command flags
|
|
51
88
|
FLAGS: {
|
|
52
|
-
MODEL:
|
|
53
|
-
SANDBOX:
|
|
54
|
-
FULL_AUTO:
|
|
55
|
-
ASK_FOR_APPROVAL:
|
|
56
|
-
SANDBOX_MODE:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
PROMPT:
|
|
61
|
-
HELP:
|
|
89
|
+
MODEL: '-m',
|
|
90
|
+
SANDBOX: '-s', // legacy flag. For Codex prefer FULL_AUTO or SANDBOX/APPROVAL flags.
|
|
91
|
+
FULL_AUTO: '--full-auto',
|
|
92
|
+
ASK_FOR_APPROVAL: '--ask-for-approval',
|
|
93
|
+
SANDBOX_MODE: '--sandbox',
|
|
94
|
+
APPROVAL: '-a',
|
|
95
|
+
YOLO: '--dangerously-bypass-approvals-and-sandbox',
|
|
96
|
+
CD: '--cd',
|
|
97
|
+
PROMPT: '-p',
|
|
98
|
+
HELP: '-help',
|
|
99
|
+
IMAGE: '-i',
|
|
100
|
+
PROFILE: '--profile',
|
|
101
|
+
CONFIG: '-c',
|
|
102
|
+
VERSION: '--version',
|
|
103
|
+
WORKING_DIR: '-C',
|
|
104
|
+
OSS: '--oss',
|
|
105
|
+
ENABLE: '--enable',
|
|
106
|
+
DISABLE: '--disable',
|
|
107
|
+
// New flags (v1.3.0+)
|
|
108
|
+
SEARCH: '--search', // Native web search flag (Codex CLI v0.52.0+)
|
|
109
|
+
ADD_DIR: '--add-dir', // Additional writable directories (Codex CLI v0.59.0+)
|
|
62
110
|
},
|
|
63
111
|
// Default values
|
|
64
112
|
DEFAULTS: {
|
|
65
|
-
MODEL:
|
|
66
|
-
BOOLEAN_TRUE:
|
|
67
|
-
BOOLEAN_FALSE:
|
|
113
|
+
MODEL: 'default', // Fallback model used when no specific model is provided
|
|
114
|
+
BOOLEAN_TRUE: 'true',
|
|
115
|
+
BOOLEAN_FALSE: 'false',
|
|
116
|
+
},
|
|
117
|
+
// Environment variables for working directory resolution
|
|
118
|
+
ENV_VARS: {
|
|
119
|
+
CODEX_MCP_CWD: 'CODEX_MCP_CWD', // Primary: Set in MCP client configuration
|
|
120
|
+
PWD: 'PWD', // Secondary: Standard Unix variable
|
|
121
|
+
INIT_CWD: 'INIT_CWD', // Tertiary: Node.js initial directory
|
|
68
122
|
},
|
|
69
123
|
};
|
|
70
124
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;AAExC,iBAAiB;AACjB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc,EAAE,uBAAuB;IACvC,kBAAkB,EAChB,6IAA6I;IAC/I,cAAc,EAAE,qBAAqB;IACrC,qBAAqB,EAAE,0EAA0E;IACjG,eAAe,EAAE,0EAA0E;IAC3F,iBAAiB,EAAE,qCAAqC;IACxD,cAAc,EAAE,mDAAmD;CAC3D,CAAC;AAEX,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;QAChD,QAAQ,EAAE,UAAU,EAAE,sCAAsC;KAC7D;CACO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Server } from
|
|
3
|
-
import { StdioServerTransport } from
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, SetLevelRequestSchema, } from
|
|
5
|
-
import { Logger } from
|
|
6
|
-
import { PROTOCOL } from
|
|
7
|
-
import { getToolDefinitions, getPromptDefinitions, executeTool, toolExists, getPromptMessage } from
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { Logger } from './utils/logger.js';
|
|
6
|
+
import { PROTOCOL } from './constants.js';
|
|
7
|
+
import { getToolDefinitions, getPromptDefinitions, executeTool, toolExists, getPromptMessage, } from './tools/index.js';
|
|
8
8
|
const server = new Server({
|
|
9
|
-
name:
|
|
10
|
-
version:
|
|
9
|
+
name: 'codex-cli-mcp',
|
|
10
|
+
version: '1.3.0',
|
|
11
11
|
}, {
|
|
12
12
|
capabilities: {
|
|
13
13
|
tools: {},
|
|
@@ -29,7 +29,7 @@ async function sendProgressNotification(progressToken, progress, total, message)
|
|
|
29
29
|
try {
|
|
30
30
|
const params = {
|
|
31
31
|
progressToken,
|
|
32
|
-
progress
|
|
32
|
+
progress,
|
|
33
33
|
};
|
|
34
34
|
if (total !== undefined)
|
|
35
35
|
params.total = total; // future cache progress
|
|
@@ -37,11 +37,11 @@ async function sendProgressNotification(progressToken, progress, total, message)
|
|
|
37
37
|
params.message = message;
|
|
38
38
|
await server.notification({
|
|
39
39
|
method: PROTOCOL.NOTIFICATIONS.PROGRESS,
|
|
40
|
-
params
|
|
40
|
+
params,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
catch (error) {
|
|
44
|
-
Logger.error(
|
|
44
|
+
Logger.error('Failed to send progress notification:', error);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function startProgressUpdates(operationName, progressToken) {
|
|
@@ -49,7 +49,7 @@ function startProgressUpdates(operationName, progressToken) {
|
|
|
49
49
|
const state = {
|
|
50
50
|
isProcessing: true,
|
|
51
51
|
currentOperationName: operationName,
|
|
52
|
-
latestOutput:
|
|
52
|
+
latestOutput: '',
|
|
53
53
|
};
|
|
54
54
|
const progressMessages = [
|
|
55
55
|
`🧠 ${operationName} - Codex is analyzing your request...`,
|
|
@@ -87,7 +87,7 @@ function startProgressUpdates(operationName, progressToken) {
|
|
|
87
87
|
return { interval: progressInterval, progressToken, state };
|
|
88
88
|
}
|
|
89
89
|
function stopProgressUpdates(progressData, success = true) {
|
|
90
|
-
const operationName = progressData.state?.currentOperationName ||
|
|
90
|
+
const operationName = progressData.state?.currentOperationName || ''; // Get from state
|
|
91
91
|
if (progressData.state) {
|
|
92
92
|
progressData.state.isProcessing = false;
|
|
93
93
|
}
|
|
@@ -120,7 +120,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
120
120
|
const args = request.params.arguments || {};
|
|
121
121
|
Logger.toolInvocation(toolName, request.params.arguments);
|
|
122
122
|
// Execute the tool using the unified registry with progress callback
|
|
123
|
-
const result = await executeTool(toolName, args,
|
|
123
|
+
const result = await executeTool(toolName, args, newOutput => {
|
|
124
124
|
if (progressData.state) {
|
|
125
125
|
progressData.state.latestOutput = newOutput;
|
|
126
126
|
}
|
|
@@ -130,7 +130,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
130
130
|
return {
|
|
131
131
|
content: [
|
|
132
132
|
{
|
|
133
|
-
type:
|
|
133
|
+
type: 'text',
|
|
134
134
|
text: result,
|
|
135
135
|
},
|
|
136
136
|
],
|
|
@@ -145,7 +145,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
145
145
|
return {
|
|
146
146
|
content: [
|
|
147
147
|
{
|
|
148
|
-
type:
|
|
148
|
+
type: 'text',
|
|
149
149
|
text: `Error executing ${toolName}: ${errorMessage}`,
|
|
150
150
|
},
|
|
151
151
|
],
|
|
@@ -170,24 +170,26 @@ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
|
170
170
|
throw new Error(`Unknown prompt: ${promptName}`);
|
|
171
171
|
}
|
|
172
172
|
return {
|
|
173
|
-
messages: [
|
|
174
|
-
|
|
173
|
+
messages: [
|
|
174
|
+
{
|
|
175
|
+
role: 'user',
|
|
175
176
|
content: {
|
|
176
|
-
type:
|
|
177
|
-
text: promptMessage
|
|
178
|
-
}
|
|
179
|
-
}
|
|
177
|
+
type: 'text',
|
|
178
|
+
text: promptMessage,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
180
182
|
};
|
|
181
183
|
});
|
|
182
184
|
// Start the server
|
|
183
185
|
async function main() {
|
|
184
|
-
Logger.debug(
|
|
186
|
+
Logger.debug('init codex-mcp-tool');
|
|
185
187
|
const transport = new StdioServerTransport();
|
|
186
188
|
await server.connect(transport);
|
|
187
|
-
Logger.debug(
|
|
189
|
+
Logger.debug('codex-mcp-tool listening on stdio');
|
|
188
190
|
}
|
|
189
|
-
main().catch(
|
|
190
|
-
Logger.error(
|
|
191
|
+
main().catch(error => {
|
|
192
|
+
Logger.error('Fatal error:', error);
|
|
191
193
|
process.exit(1);
|
|
192
194
|
});
|
|
193
195
|
//# sourceMappingURL=index.js.map
|