@trishchuk/codex-mcp-tool 1.2.0 → 1.4.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 +84 -170
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/ask-codex.tool.d.ts.map +1 -1
- package/dist/tools/ask-codex.tool.js +82 -54
- package/dist/tools/ask-codex.tool.js.map +1 -1
- package/dist/tools/batch-codex.tool.js +1 -1
- package/dist/tools/batch-codex.tool.js.map +1 -1
- package/dist/tools/health.tool.d.ts +3 -0
- package/dist/tools/health.tool.d.ts.map +1 -0
- package/dist/tools/health.tool.js +189 -0
- package/dist/tools/health.tool.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +4 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/list-sessions.tool.d.ts +3 -0
- package/dist/tools/list-sessions.tool.d.ts.map +1 -0
- package/dist/tools/list-sessions.tool.js +71 -0
- package/dist/tools/list-sessions.tool.js.map +1 -0
- package/dist/utils/codexCommandBuilder.d.ts +87 -0
- package/dist/utils/codexCommandBuilder.d.ts.map +1 -0
- package/dist/utils/codexCommandBuilder.js +285 -0
- package/dist/utils/codexCommandBuilder.js.map +1 -0
- package/dist/utils/codexExecutor.d.ts +12 -1
- package/dist/utils/codexExecutor.d.ts.map +1 -1
- package/dist/utils/codexExecutor.js +18 -181
- package/dist/utils/codexExecutor.js.map +1 -1
- package/dist/utils/commandExecutor.js +3 -3
- package/dist/utils/commandExecutor.js.map +1 -1
- package/dist/utils/errorTypes.d.ts +74 -0
- package/dist/utils/errorTypes.d.ts.map +1 -0
- package/dist/utils/errorTypes.js +268 -0
- package/dist/utils/errorTypes.js.map +1 -0
- 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/sessionStorage.d.ts +79 -0
- package/dist/utils/sessionStorage.d.ts.map +1 -0
- package/dist/utils/sessionStorage.js +276 -0
- package/dist/utils/sessionStorage.js.map +1 -0
- package/dist/utils/versionDetection.d.ts +123 -0
- package/dist/utils/versionDetection.d.ts.map +1 -0
- package/dist/utils/versionDetection.js +188 -0
- package/dist/utils/versionDetection.js.map +1 -0
- package/dist/utils/workingDirResolver.d.ts +13 -8
- package/dist/utils/workingDirResolver.d.ts.map +1 -1
- package/dist/utils/workingDirResolver.js +44 -26
- package/dist/utils/workingDirResolver.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -6,67 +6,32 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@trishchuk/codex-mcp-tool)
|
|
7
7
|
[](https://www.npmjs.com/package/@trishchuk/codex-mcp-tool)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
|
-
[](https://github.com/x51xxx/codex-mcp-tool)
|
|
10
9
|
|
|
11
10
|
</div>
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
MCP server connecting Claude/Cursor to Codex CLI. Enables code analysis via `@` file references, multi-turn conversations, sandboxed edits, and structured change mode.
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
## Features
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
- **File Analysis** — Reference files with `@src/`, `@package.json` syntax
|
|
17
|
+
- **Multi-Turn Sessions** — Conversation continuity with workspace isolation
|
|
18
|
+
- **Native Resume** — Uses `codex resume` for context preservation (CLI v0.36.0+)
|
|
19
|
+
- **Web Search** — Research capabilities with `search: true`
|
|
20
|
+
- **Sandbox Mode** — Safe code execution with `--full-auto`
|
|
21
|
+
- **Change Mode** — Structured OLD/NEW patch output for refactoring
|
|
22
|
+
- **Brainstorming** — SCAMPER, design-thinking, lateral thinking frameworks
|
|
23
|
+
- **Health Diagnostics** — CLI version, features, and session monitoring
|
|
24
|
+
- **Cross-Platform** — Windows, macOS, Linux fully supported
|
|
20
25
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
Goal: Use Codex directly from your MCP-enabled editor to analyze and edit code efficiently.
|
|
24
|
-
|
|
25
|
-
## Prerequisites
|
|
26
|
-
|
|
27
|
-
Before using this tool, ensure you have:
|
|
28
|
-
|
|
29
|
-
1. **[Node.js](https://nodejs.org/)** (v18.0.0 or higher)
|
|
30
|
-
2. **[Codex CLI](https://github.com/openai/codex)** installed and authenticated
|
|
31
|
-
|
|
32
|
-
### One-Line Setup
|
|
26
|
+
## Quick Start
|
|
33
27
|
|
|
34
28
|
```bash
|
|
35
29
|
claude mcp add codex-cli -- npx -y @trishchuk/codex-mcp-tool
|
|
36
30
|
```
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Type `/mcp` inside Claude Code to verify the Codex MCP is active.
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
### Alternative: Import from Claude Desktop
|
|
32
|
+
**Prerequisites:** Node.js 18+, [Codex CLI](https://github.com/openai/codex) installed and authenticated.
|
|
45
33
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
1. Add to your Claude Desktop config:
|
|
49
|
-
|
|
50
|
-
```json
|
|
51
|
-
"codex-cli": {
|
|
52
|
-
"command": "npx",
|
|
53
|
-
"args": ["-y", "@trishchuk/codex-mcp-tool"]
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
2. Import to Claude Code:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
claude mcp add-from-claude-desktop
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Configuration
|
|
64
|
-
|
|
65
|
-
Register the MCP server with your MCP client:
|
|
66
|
-
|
|
67
|
-
### For NPX Usage (Recommended)
|
|
68
|
-
|
|
69
|
-
Add this configuration to your Claude Desktop config file:
|
|
34
|
+
### Configuration
|
|
70
35
|
|
|
71
36
|
```json
|
|
72
37
|
{
|
|
@@ -79,158 +44,107 @@ Add this configuration to your Claude Desktop config file:
|
|
|
79
44
|
}
|
|
80
45
|
```
|
|
81
46
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
If you installed globally, use this configuration instead:
|
|
85
|
-
|
|
86
|
-
```json
|
|
87
|
-
{
|
|
88
|
-
"mcpServers": {
|
|
89
|
-
"codex-cli": {
|
|
90
|
-
"command": "codex-mcp"
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Configuration File Locations:**
|
|
97
|
-
|
|
98
|
-
- **Claude Desktop**:
|
|
99
|
-
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
100
|
-
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
101
|
-
- **Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
102
|
-
|
|
103
|
-
After updating the configuration, restart your terminal session.
|
|
104
|
-
|
|
105
|
-
## Example Workflow
|
|
106
|
-
|
|
107
|
-
- Natural language: "use codex to explain index.html", "understand this repo with @src", "look for vulnerabilities and suggest fixes"
|
|
108
|
-
- Claude Code: Type `/codex-cli` to access the MCP server tools.
|
|
47
|
+
**Config locations:** macOS: `~/Library/Application Support/Claude/claude_desktop_config.json` | Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
109
48
|
|
|
110
49
|
## Usage Examples
|
|
111
50
|
|
|
112
|
-
### Model Selection
|
|
113
|
-
|
|
114
51
|
```javascript
|
|
115
|
-
//
|
|
116
|
-
'explain the architecture of @src/'
|
|
52
|
+
// File analysis
|
|
53
|
+
'explain the architecture of @src/'
|
|
54
|
+
'analyze @package.json and list dependencies'
|
|
117
55
|
|
|
118
|
-
//
|
|
119
|
-
'use codex with model
|
|
56
|
+
// With specific model
|
|
57
|
+
'use codex with model o3 to analyze @algorithm.py'
|
|
120
58
|
|
|
121
|
-
//
|
|
122
|
-
'
|
|
59
|
+
// Multi-turn conversations (v1.4.0+)
|
|
60
|
+
'ask codex sessionId:"my-project" prompt:"explain @src/"'
|
|
61
|
+
'ask codex sessionId:"my-project" prompt:"now add error handling"'
|
|
123
62
|
|
|
124
|
-
//
|
|
125
|
-
'
|
|
63
|
+
// Brainstorming
|
|
64
|
+
'brainstorm ways to optimize CI/CD using SCAMPER method'
|
|
126
65
|
|
|
127
|
-
//
|
|
128
|
-
'use codex
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### With File References (using @ syntax)
|
|
66
|
+
// Sandbox mode
|
|
67
|
+
'use codex sandbox:true to create and run a Python script'
|
|
132
68
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
69
|
+
// Web search
|
|
70
|
+
'ask codex search:true prompt:"latest TypeScript 5.7 features"'
|
|
71
|
+
```
|
|
136
72
|
|
|
137
|
-
|
|
73
|
+
## Tools
|
|
138
74
|
|
|
139
|
-
|
|
140
|
-
|
|
75
|
+
| Tool | Description |
|
|
76
|
+
|------|-------------|
|
|
77
|
+
| `ask-codex` | Execute Codex CLI with file analysis, models, sessions |
|
|
78
|
+
| `brainstorm` | Generate ideas with SCAMPER, design-thinking, etc. |
|
|
79
|
+
| `list-sessions` | View/delete/clear conversation sessions |
|
|
80
|
+
| `health` | Diagnose CLI installation, version, features |
|
|
81
|
+
| `ping` / `help` | Test connection, show CLI help |
|
|
141
82
|
|
|
142
|
-
|
|
83
|
+
## Models
|
|
143
84
|
|
|
144
|
-
|
|
145
|
-
- `use codex to brainstorm 10 innovative features for our app with feasibility analysis`
|
|
146
|
-
- `ask codex to generate product ideas for the healthcare domain with design-thinking approach`
|
|
85
|
+
Default: `gpt-5.1-codex-max` with fallback → `gpt-5-codex` → `gpt-5`
|
|
147
86
|
|
|
148
|
-
|
|
87
|
+
| Model | Use Case |
|
|
88
|
+
|-------|----------|
|
|
89
|
+
| `gpt-5.1-codex-max` | Complex multi-file edits (default) |
|
|
90
|
+
| `gpt-5.1-codex-mini` | Cost-efficient quick tasks |
|
|
91
|
+
| `o3` | Deep reasoning |
|
|
92
|
+
| `o4-mini` | Fast & efficient |
|
|
93
|
+
| `codex-1` | Software engineering |
|
|
149
94
|
|
|
150
|
-
|
|
95
|
+
## Key Features
|
|
151
96
|
|
|
152
|
-
|
|
153
|
-
- `ask codex to safely test @script.py and explain what it does`
|
|
97
|
+
### Session Management (v1.4.0+)
|
|
154
98
|
|
|
155
|
-
|
|
99
|
+
Multi-turn conversations with workspace isolation:
|
|
156
100
|
|
|
157
101
|
```javascript
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// Brainstorming with constraints
|
|
162
|
-
"brainstorm solutions for reducing API latency with constraints: 'must use existing infrastructure, budget under $5k'";
|
|
163
|
-
|
|
164
|
-
// Change mode for structured edits
|
|
165
|
-
'use codex in change mode to update all console.log to use winston logger in @src/';
|
|
102
|
+
{ "prompt": "analyze code", "sessionId": "my-session" }
|
|
103
|
+
{ "prompt": "continue from here", "sessionId": "my-session" }
|
|
104
|
+
{ "prompt": "start fresh", "sessionId": "my-session", "resetSession": true }
|
|
166
105
|
```
|
|
167
106
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
#### Core Tools
|
|
173
|
-
|
|
174
|
-
- **`ask-codex`**: Sends a prompt to Codex via `codex exec`.
|
|
175
|
-
- Supports `@` file references for including file content
|
|
176
|
-
- Optional `model` parameter - available models:
|
|
177
|
-
- `gpt-5-codex` (default, optimized for coding)
|
|
178
|
-
- `gpt-5` (general purpose, fast reasoning)
|
|
179
|
-
- `o3` (smartest, deep reasoning)
|
|
180
|
-
- `o4-mini` (fast & efficient)
|
|
181
|
-
- `codex-1` (o3-based for software engineering)
|
|
182
|
-
- `codex-mini-latest` (low-latency code Q&A)
|
|
183
|
-
- `gpt-4.1` (also available)
|
|
184
|
-
- `sandbox=true` enables `--full-auto` mode
|
|
185
|
-
- `changeMode=true` returns structured OLD/NEW edits
|
|
186
|
-
- Supports approval policies and sandbox modes
|
|
187
|
-
|
|
188
|
-
- **`brainstorm`**: Generate novel ideas with structured methodologies.
|
|
189
|
-
- Multiple frameworks: divergent, convergent, SCAMPER, design-thinking, lateral
|
|
190
|
-
- Domain-specific context (software, business, creative, research, product, marketing)
|
|
191
|
-
- Supports same models as `ask-codex` (default: `gpt-5-codex`)
|
|
192
|
-
- Configurable idea count and analysis depth
|
|
193
|
-
- Includes feasibility, impact, and innovation scoring
|
|
194
|
-
- Example: `brainstorm prompt:"ways to improve code review process" domain:"software" methodology:"scamper"`
|
|
195
|
-
|
|
196
|
-
- **`ping`**: A simple test tool that echoes back a message.
|
|
197
|
-
- Use to verify MCP connection is working
|
|
198
|
-
- Example: `/codex-cli:ping (MCP) "Hello from Codex MCP!"`
|
|
107
|
+
**Environment:**
|
|
108
|
+
- `CODEX_SESSION_TTL_MS` - Session TTL (default: 24h)
|
|
109
|
+
- `CODEX_MAX_SESSIONS` - Max sessions (default: 50)
|
|
199
110
|
|
|
200
|
-
|
|
111
|
+
### Advanced Options
|
|
201
112
|
|
|
202
|
-
|
|
113
|
+
| Parameter | Description |
|
|
114
|
+
|-----------|-------------|
|
|
115
|
+
| `model` | Model selection |
|
|
116
|
+
| `sessionId` | Enable conversation continuity |
|
|
117
|
+
| `sandbox` | Enable `--full-auto` mode |
|
|
118
|
+
| `search` | Enable web search |
|
|
119
|
+
| `changeMode` | Structured OLD/NEW edits |
|
|
120
|
+
| `addDirs` | Additional writable directories |
|
|
121
|
+
| `toolOutputTokenLimit` | Cap response verbosity (100-10,000) |
|
|
203
122
|
|
|
204
|
-
|
|
205
|
-
- Used for paginating large structured edit responses
|
|
206
|
-
- Requires `cacheKey` and `chunkIndex` parameters
|
|
123
|
+
## CLI Compatibility
|
|
207
124
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
125
|
+
| Version | Features |
|
|
126
|
+
|---------|----------|
|
|
127
|
+
| v0.59.0+ | `--add-dir`, token limits, full GPT-5.1 |
|
|
128
|
+
| v0.52.0+ | Native `--search` flag |
|
|
129
|
+
| v0.36.0+ | Native `codex resume` (sessions) |
|
|
211
130
|
|
|
212
|
-
|
|
131
|
+
## Troubleshooting
|
|
213
132
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
- **/sandbox**: Safely tests code or scripts with Codex approval modes.
|
|
219
|
-
- **`prompt`** (required): Code testing request (e.g., `/sandbox prompt:Create and run a Python script that processes CSV data` or `/sandbox prompt:@script.py Test this script safely`).
|
|
220
|
-
- **/help**: Displays the Codex CLI help information.
|
|
221
|
-
- **/ping**: Tests the connection to the server.
|
|
222
|
-
- **`message`** (optional): A message to echo back.
|
|
223
|
-
|
|
224
|
-
## Acknowledgments
|
|
133
|
+
```bash
|
|
134
|
+
codex --version # Check CLI version
|
|
135
|
+
codex login # Authenticate
|
|
136
|
+
```
|
|
225
137
|
|
|
226
|
-
|
|
138
|
+
Use `health` tool for diagnostics: `'use health verbose:true'`
|
|
227
139
|
|
|
228
|
-
##
|
|
140
|
+
## Migration
|
|
229
141
|
|
|
230
|
-
|
|
142
|
+
**v1.3.x → v1.4.0:** New `sessionId` parameter, `list-sessions`/`health` tools, structured error handling. No breaking changes.
|
|
231
143
|
|
|
232
144
|
## License
|
|
233
145
|
|
|
234
|
-
|
|
146
|
+
MIT License. Not affiliated with OpenAI.
|
|
147
|
+
|
|
148
|
+
---
|
|
235
149
|
|
|
236
|
-
|
|
150
|
+
[Documentation](https://x51xxx.github.io/codex-mcp-tool/) | [Issues](https://github.com/x51xxx/codex-mcp-tool/issues) | Inspired by [jamubc/gemini-mcp-tool](https://github.com/jamubc/gemini-mcp-tool)
|
package/dist/constants.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare const STATUS_MESSAGES: {
|
|
|
17
17
|
readonly PROCESSING_COMPLETE: "✅ Analysis completed successfully";
|
|
18
18
|
};
|
|
19
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";
|
|
20
25
|
readonly GPT5_CODEX: "gpt-5-codex";
|
|
21
26
|
readonly GPT5: "gpt-5";
|
|
22
27
|
readonly O3: "o3";
|
|
@@ -80,6 +85,9 @@ export declare const CLI: {
|
|
|
80
85
|
readonly OSS: "--oss";
|
|
81
86
|
readonly ENABLE: "--enable";
|
|
82
87
|
readonly DISABLE: "--disable";
|
|
88
|
+
readonly SEARCH: "--search";
|
|
89
|
+
readonly ADD_DIR: "--add-dir";
|
|
90
|
+
readonly RESUME: "resume";
|
|
83
91
|
};
|
|
84
92
|
readonly DEFAULTS: {
|
|
85
93
|
readonly MODEL: "default";
|
|
@@ -104,6 +112,8 @@ export interface ToolArguments {
|
|
|
104
112
|
cd?: string;
|
|
105
113
|
workingDir?: string;
|
|
106
114
|
changeMode?: boolean | string;
|
|
115
|
+
sessionId?: string;
|
|
116
|
+
resetSession?: boolean;
|
|
107
117
|
chunkIndex?: number | string;
|
|
108
118
|
chunkCacheKey?: string;
|
|
109
119
|
message?: string;
|
|
@@ -118,6 +128,8 @@ export interface ToolArguments {
|
|
|
118
128
|
oss?: boolean;
|
|
119
129
|
enableFeatures?: string[];
|
|
120
130
|
disableFeatures?: string[];
|
|
131
|
+
addDirs?: string[];
|
|
132
|
+
toolOutputTokenLimit?: number;
|
|
121
133
|
methodology?: string;
|
|
122
134
|
domain?: string;
|
|
123
135
|
constraints?: string;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,gBAA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X: '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
|
|
26
33
|
GPT5: 'gpt-5',
|
|
34
|
+
// Other Models
|
|
27
35
|
O3: 'o3',
|
|
28
36
|
O4_MINI: 'o4-mini',
|
|
29
37
|
CODEX_1: 'codex-1',
|
|
@@ -96,6 +104,11 @@ export const CLI = {
|
|
|
96
104
|
OSS: '--oss',
|
|
97
105
|
ENABLE: '--enable',
|
|
98
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+)
|
|
110
|
+
// Session/Resume flags (v1.4.0+)
|
|
111
|
+
RESUME: 'resume', // Resume command (replaces 'exec' when resuming)
|
|
99
112
|
},
|
|
100
113
|
// Default values
|
|
101
114
|
DEFAULTS: {
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,0EAA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KAAK,EAAE;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI,EAAE,qEAAqE;QACpF,SAAS,EAAE,aAAa;QACxB,gBAAgB,EAAE,oBAAoB;QACtC,YAAY,EAAE,WAAW;QACzB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,4CAA4C;QAClD,EAAE,EAAE,MAAM;QACV,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,WAAW;QACpB,WAAW,EAAE,IAAI;QACjB,GAAG,EAAE,OAAO;QACZ,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,WAAW;QACpB,sBAAsB;QACtB,MAAM,EAAE,UAAU,EAAE,8CAA8C;QAClE,OAAO,EAAE,WAAW,EAAE,uDAAuD;QAC7E,iCAAiC;QACjC,MAAM,EAAE,QAAQ,EAAE,iDAAiD;KACpE;IACD,iBAAiB;IACjB,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS,EAAE,yDAAyD;QAC3E,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,OAAO;KACvB;IACD,yDAAyD;IACzD,QAAQ,EAAE;QACR,aAAa,EAAE,eAAe,EAAE,2CAA2C;QAC3E,GAAG,EAAE,KAAK,EAAE,oCAAoC;QAChD,QAAQ,EAAE,UAAU,EAAE,sCAAsC;KAC7D;CACO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,11 @@ import { PROTOCOL } from './constants.js';
|
|
|
7
7
|
import { getToolDefinitions, getPromptDefinitions, executeTool, toolExists, getPromptMessage, } from './tools/index.js';
|
|
8
8
|
const server = new Server({
|
|
9
9
|
name: 'codex-cli-mcp',
|
|
10
|
-
version: '1.
|
|
10
|
+
version: '1.4.0',
|
|
11
11
|
}, {
|
|
12
12
|
capabilities: {
|
|
13
13
|
tools: {},
|
|
14
14
|
prompts: {},
|
|
15
|
-
notifications: {},
|
|
16
15
|
logging: {},
|
|
17
16
|
},
|
|
18
17
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,GAUtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,EAAE;QACX,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,qBAAqB,GAUtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,gBAAgB,GACjB,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CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-codex.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask-codex.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ask-codex.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask-codex.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAyH5C,eAAO,MAAM,YAAY,EAAE,WAyJ1B,CAAC"}
|
|
@@ -3,6 +3,9 @@ import { executeCodex } from '../utils/codexExecutor.js';
|
|
|
3
3
|
import { processChangeModeOutput } from '../utils/changeModeRunner.js';
|
|
4
4
|
import { formatCodexResponseForMCP } from '../utils/outputParser.js';
|
|
5
5
|
import { MODELS, APPROVAL_POLICIES, ERROR_MESSAGES } from '../constants.js';
|
|
6
|
+
import { createCodexError, formatErrorForUser } from '../utils/errorTypes.js';
|
|
7
|
+
import { getOrCreateSession, saveSession, getCodexConversationId, setCodexConversationId, parseConversationIdFromOutput, deleteSession, } from '../utils/sessionStorage.js';
|
|
8
|
+
import { resolveWorkingDirectory } from '../utils/workingDirResolver.js';
|
|
6
9
|
const askCodexArgsSchema = z.object({
|
|
7
10
|
prompt: z
|
|
8
11
|
.string()
|
|
@@ -11,7 +14,7 @@ const askCodexArgsSchema = z.object({
|
|
|
11
14
|
model: z
|
|
12
15
|
.string()
|
|
13
16
|
.optional()
|
|
14
|
-
.describe(`Model: ${Object.values(MODELS).join(', ')}. Default: gpt-5-codex`),
|
|
17
|
+
.describe(`Model: ${Object.values(MODELS).join(', ')}. Default: gpt-5.1-codex-max`),
|
|
15
18
|
sandbox: z
|
|
16
19
|
.boolean()
|
|
17
20
|
.default(false)
|
|
@@ -66,7 +69,7 @@ const askCodexArgsSchema = z.object({
|
|
|
66
69
|
search: z
|
|
67
70
|
.boolean()
|
|
68
71
|
.optional()
|
|
69
|
-
.describe('Enable web search
|
|
72
|
+
.describe('Enable web search using native --search flag (v0.52.0+). Requires network access - automatically sets sandbox to workspace-write if not specified.'),
|
|
70
73
|
oss: z
|
|
71
74
|
.boolean()
|
|
72
75
|
.optional()
|
|
@@ -79,6 +82,26 @@ const askCodexArgsSchema = z.object({
|
|
|
79
82
|
.array(z.string())
|
|
80
83
|
.optional()
|
|
81
84
|
.describe('Disable feature flags (repeatable). Equivalent to -c features.<name>=false'),
|
|
85
|
+
// New parameters (v1.3.0+)
|
|
86
|
+
addDirs: z
|
|
87
|
+
.array(z.string())
|
|
88
|
+
.optional()
|
|
89
|
+
.describe('Additional writable directories beyond workspace (e.g., ["/tmp", "/var/log"]). Useful for monorepos and multi-directory projects.'),
|
|
90
|
+
toolOutputTokenLimit: z
|
|
91
|
+
.number()
|
|
92
|
+
.min(100)
|
|
93
|
+
.max(10000)
|
|
94
|
+
.optional()
|
|
95
|
+
.describe('Maximum tokens for tool outputs (100-10,000). Controls response verbosity.'),
|
|
96
|
+
// Session management (v1.4.0+)
|
|
97
|
+
sessionId: z
|
|
98
|
+
.string()
|
|
99
|
+
.optional()
|
|
100
|
+
.describe('Session ID for conversation continuity. Enables native Codex resume.'),
|
|
101
|
+
resetSession: z
|
|
102
|
+
.boolean()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe('Clear session context before execution. Starts fresh conversation.'),
|
|
82
105
|
});
|
|
83
106
|
export const askCodexTool = {
|
|
84
107
|
name: 'ask-codex',
|
|
@@ -89,7 +112,7 @@ export const askCodexTool = {
|
|
|
89
112
|
},
|
|
90
113
|
category: 'utility',
|
|
91
114
|
execute: async (args, onProgress) => {
|
|
92
|
-
const { prompt, model, sandbox, fullAuto, approvalPolicy, approval, sandboxMode, yolo, cd, workingDir, changeMode, chunkIndex, chunkCacheKey, image, config, profile, timeout, includeThinking, includeMetadata, search, oss, enableFeatures, disableFeatures, } = args;
|
|
115
|
+
const { prompt, model, sandbox, fullAuto, approvalPolicy, approval, sandboxMode, yolo, cd, workingDir, changeMode, chunkIndex, chunkCacheKey, image, config, profile, timeout, includeThinking, includeMetadata, search, oss, enableFeatures, disableFeatures, addDirs, toolOutputTokenLimit, sessionId, resetSession, } = args;
|
|
93
116
|
if (!prompt?.trim()) {
|
|
94
117
|
throw new Error(ERROR_MESSAGES.NO_PROMPT_PROVIDED);
|
|
95
118
|
}
|
|
@@ -100,6 +123,33 @@ export const askCodexTool = {
|
|
|
100
123
|
prompt: prompt,
|
|
101
124
|
});
|
|
102
125
|
}
|
|
126
|
+
// Session management (v1.4.0+)
|
|
127
|
+
let codexConversationId;
|
|
128
|
+
let activeSessionId;
|
|
129
|
+
if (sessionId) {
|
|
130
|
+
// Handle session reset
|
|
131
|
+
if (resetSession) {
|
|
132
|
+
deleteSession(sessionId);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// Try to get existing Codex conversation ID for resume
|
|
136
|
+
codexConversationId = getCodexConversationId(sessionId);
|
|
137
|
+
}
|
|
138
|
+
activeSessionId = sessionId;
|
|
139
|
+
}
|
|
140
|
+
// Resolve working directory for session
|
|
141
|
+
const resolvedWorkingDir = resolveWorkingDirectory({
|
|
142
|
+
workingDir: (workingDir || cd),
|
|
143
|
+
prompt: prompt,
|
|
144
|
+
});
|
|
145
|
+
// Get or create session if sessionId provided
|
|
146
|
+
if (activeSessionId && resolvedWorkingDir) {
|
|
147
|
+
const session = getOrCreateSession(resolvedWorkingDir, activeSessionId);
|
|
148
|
+
activeSessionId = session.sessionId;
|
|
149
|
+
if (!codexConversationId) {
|
|
150
|
+
codexConversationId = session.codexConversationId;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
103
153
|
try {
|
|
104
154
|
// Use enhanced executeCodex for better feature support
|
|
105
155
|
const result = await executeCodex(prompt, {
|
|
@@ -119,66 +169,44 @@ export const askCodexTool = {
|
|
|
119
169
|
oss: oss,
|
|
120
170
|
enableFeatures: enableFeatures,
|
|
121
171
|
disableFeatures: disableFeatures,
|
|
172
|
+
addDirs: addDirs,
|
|
173
|
+
toolOutputTokenLimit: toolOutputTokenLimit,
|
|
174
|
+
codexConversationId, // Pass conversation ID for resume
|
|
122
175
|
}, onProgress);
|
|
176
|
+
// Parse and store conversation ID from response for future resume
|
|
177
|
+
// Conversation ID may be in stdout OR stderr - check both
|
|
178
|
+
if (activeSessionId) {
|
|
179
|
+
const combinedOutput = `${result.output}\n${result.stderr}`;
|
|
180
|
+
const newConversationId = parseConversationIdFromOutput(combinedOutput);
|
|
181
|
+
if (newConversationId) {
|
|
182
|
+
setCodexConversationId(activeSessionId, newConversationId);
|
|
183
|
+
}
|
|
184
|
+
// Update session with latest prompt/response
|
|
185
|
+
saveSession({
|
|
186
|
+
sessionId: activeSessionId,
|
|
187
|
+
lastPrompt: prompt,
|
|
188
|
+
lastResponse: result.output.substring(0, 1000), // Store truncated response
|
|
189
|
+
model: model,
|
|
190
|
+
workingDir: resolvedWorkingDir,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
123
193
|
if (changeMode) {
|
|
124
|
-
return processChangeModeOutput(result, {
|
|
194
|
+
return processChangeModeOutput(result.output, {
|
|
125
195
|
chunkIndex: args.chunkIndex,
|
|
126
196
|
prompt: prompt,
|
|
127
197
|
});
|
|
128
198
|
}
|
|
129
199
|
// Format response with enhanced output parsing
|
|
130
|
-
return formatCodexResponseForMCP(result, includeThinking, includeMetadata);
|
|
200
|
+
return formatCodexResponseForMCP(result.output, includeThinking, includeMetadata);
|
|
131
201
|
}
|
|
132
202
|
catch (error) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
npm install -g @openai/codex
|
|
141
|
-
\`\`\`
|
|
142
|
-
|
|
143
|
-
**Verification:** Run \`codex --version\` to confirm installation.`;
|
|
144
|
-
}
|
|
145
|
-
if (errorMessage.includes('authentication') || errorMessage.includes('unauthorized')) {
|
|
146
|
-
return `❌ **Authentication Failed**: ${ERROR_MESSAGES.AUTHENTICATION_FAILED}
|
|
147
|
-
|
|
148
|
-
**Setup Options:**
|
|
149
|
-
1. **API Key:** \`export OPENAI_API_KEY=your-key\`
|
|
150
|
-
2. **Login:** \`codex login\` (requires ChatGPT subscription)
|
|
151
|
-
|
|
152
|
-
**Troubleshooting:** Verify key has Codex access in OpenAI dashboard.`;
|
|
153
|
-
}
|
|
154
|
-
if (errorMessage.includes('quota') || errorMessage.includes('rate limit')) {
|
|
155
|
-
return `❌ **Usage Limit Reached**: ${ERROR_MESSAGES.QUOTA_EXCEEDED}
|
|
156
|
-
|
|
157
|
-
**Solutions:**
|
|
158
|
-
1. Wait and retry - rate limits reset periodically
|
|
159
|
-
2. Check quota in OpenAI dashboard`;
|
|
160
|
-
}
|
|
161
|
-
if (errorMessage.includes('timeout')) {
|
|
162
|
-
return `❌ **Request Timeout**: Operation took longer than expected
|
|
163
|
-
|
|
164
|
-
**Solutions:**
|
|
165
|
-
1. Increase timeout: Add \`timeout: 300000\` (5 minutes)
|
|
166
|
-
2. Simplify request: Break complex queries into smaller parts`;
|
|
167
|
-
}
|
|
168
|
-
if (errorMessage.includes('sandbox') || errorMessage.includes('permission')) {
|
|
169
|
-
return `❌ **Permission Error**: ${ERROR_MESSAGES.SANDBOX_VIOLATION}
|
|
170
|
-
|
|
171
|
-
**Solutions:**
|
|
172
|
-
1. Relax sandbox: Use \`sandboxMode: "workspace-write"\`
|
|
173
|
-
2. Adjust approval: Try \`approval: "on-request"\``;
|
|
174
|
-
}
|
|
175
|
-
// Generic error with context
|
|
176
|
-
return `❌ **Codex Execution Error**: ${errorMessage}
|
|
177
|
-
|
|
178
|
-
**Debug Steps:**
|
|
179
|
-
1. Verify Codex CLI: \`codex --version\`
|
|
180
|
-
2. Check authentication: \`codex login\`
|
|
181
|
-
3. Try simpler query first`;
|
|
203
|
+
// Use structured error handling
|
|
204
|
+
const codexError = createCodexError(error instanceof Error ? error : String(error), {
|
|
205
|
+
sessionId: activeSessionId,
|
|
206
|
+
model: model,
|
|
207
|
+
workingDir: resolvedWorkingDir,
|
|
208
|
+
});
|
|
209
|
+
return `❌ ${formatErrorForUser(codexError)}`;
|
|
182
210
|
}
|
|
183
211
|
},
|
|
184
212
|
};
|