@h0wzy/mcp-server-codex 1.0.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/NOTICE +10 -0
- package/bin/cli.js +6 -0
- package/package.json +20 -0
- package/src/index.js +153 -0
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
H0wZy/mcp - OpenAI Codex Server Bridge
|
|
2
|
+
Original inspiration: codex-mcp-tool (https://github.com/trishchuk/codex-mcp-tool)
|
|
3
|
+
Originally authored by Taras Trishchuk under the MIT License.
|
|
4
|
+
|
|
5
|
+
Enhanced & Unified for H0wZy/mcp by Marcos (H0wZy):
|
|
6
|
+
- Modularized to speak generic MCP to any client (Claude Code, Antigravity, Cursor, VS Code)
|
|
7
|
+
- Replaced 50-file compilation overhead with native, lightweight ES Modules running directly on Node 20+
|
|
8
|
+
- Universal cross-platform binary resolution (PATHEXT, APPDATA, delimiter)
|
|
9
|
+
- Direct zero-latency local execution
|
|
10
|
+
- Resilient Rate Limit (HTTP 429) and ResourceExhausted handling
|
package/bin/cli.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@h0wzy/mcp-server-codex",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenAI Codex MCP Server connecting any MCP client to GPT-5.6 / GPT-6 Astra",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"h0wzy-mcp-codex": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./src/index.js",
|
|
10
|
+
"author": "Marcos (H0wZy) <h0wzymarcos@gmail.com>",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/H0wZy/mcp.git",
|
|
15
|
+
"directory": "servers/codex"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// H0wZy/mcp — OpenAI Codex MCP Server
|
|
2
|
+
// Minimal, DRY bridge exposing OpenAI Codex CLI (GPT-5.6 / GPT-6 Astra) to any MCP client.
|
|
3
|
+
|
|
4
|
+
import { statSync } from 'node:fs';
|
|
5
|
+
import { dirname } from 'node:path';
|
|
6
|
+
import { createMcpServer, resolveBinary, executeProcess, formatResilientResponse } from '../../../shared/index.js';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_MODEL = process.env.CODEX_MODEL || 'gpt-5.6-terra';
|
|
9
|
+
const TIMEOUT_MS = 300000; // 5 minutes
|
|
10
|
+
|
|
11
|
+
export const askCodexTool = {
|
|
12
|
+
name: 'ask_codex',
|
|
13
|
+
description:
|
|
14
|
+
'Ask OpenAI Codex CLI (default model: GPT-5.6 Terra / GPT-6 Astra) for an independent second opinion, ' +
|
|
15
|
+
'reasoning check, or implementation advice. Codex has deep understanding of complex codebases and architectures.',
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
prompt: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'The instruction, question, or verification request.',
|
|
22
|
+
},
|
|
23
|
+
paths: {
|
|
24
|
+
type: 'array',
|
|
25
|
+
items: { type: 'string' },
|
|
26
|
+
description: 'Optional file or folder paths to attach as context.',
|
|
27
|
+
},
|
|
28
|
+
model: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'Optional model override (e.g. "gpt-6-astra", "gpt-5.6-terra", "gpt-5.5").',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: ['prompt'],
|
|
34
|
+
},
|
|
35
|
+
handler: async ({ prompt, paths = [], model }) => {
|
|
36
|
+
if (!prompt) {
|
|
37
|
+
return { text: 'Missing required argument: prompt', isError: true };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const codexBin = resolveBinary('codex', 'CODEX_CLI_PATH');
|
|
41
|
+
if (!codexBin) {
|
|
42
|
+
return {
|
|
43
|
+
isError: true,
|
|
44
|
+
text:
|
|
45
|
+
'❌ OpenAI Codex CLI (`codex`) not found on system.\n' +
|
|
46
|
+
'Please ensure Codex CLI is installed:\n' +
|
|
47
|
+
' npm install -g @openai/codex\n' +
|
|
48
|
+
'Or set CODEX_CLI_PATH to its absolute path.',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const fullPrompt = paths.length
|
|
53
|
+
? `Context files/directories to inspect in full:\n${paths.map((p) => `- ${p}`).join('\n')}\n\n${prompt}`
|
|
54
|
+
: prompt;
|
|
55
|
+
|
|
56
|
+
const args = [
|
|
57
|
+
'exec',
|
|
58
|
+
fullPrompt,
|
|
59
|
+
'-m',
|
|
60
|
+
model || DEFAULT_MODEL,
|
|
61
|
+
'--ephemeral',
|
|
62
|
+
'--skip-git-repo-check',
|
|
63
|
+
'--approve-for-me',
|
|
64
|
+
'--color',
|
|
65
|
+
'never',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
for (const p of paths) {
|
|
69
|
+
try {
|
|
70
|
+
const isDir = statSync(p).isDirectory();
|
|
71
|
+
args.push('--add-dir', isDir ? p : dirname(p));
|
|
72
|
+
} catch {
|
|
73
|
+
/* skip invalid path */
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const res = await executeProcess(codexBin, args, { timeoutMs: TIMEOUT_MS, toolName: 'codex' });
|
|
78
|
+
|
|
79
|
+
if (res.ok) {
|
|
80
|
+
return {
|
|
81
|
+
text: res.stdout || '(Codex completed with no output)',
|
|
82
|
+
isError: false,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return formatResilientResponse({
|
|
87
|
+
provider: 'OpenAI Codex',
|
|
88
|
+
rawOutput: res.stderr || res.stdout,
|
|
89
|
+
exitCode: res.exitCode,
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const reviewCodexTool = {
|
|
95
|
+
name: 'review_codex',
|
|
96
|
+
description:
|
|
97
|
+
'Run a structured code review using OpenAI Codex CLI against the current repository or specified files.',
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
prompt: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'Specific review instructions or focus areas (e.g. security, performance, edge cases).',
|
|
104
|
+
},
|
|
105
|
+
model: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
description: 'Optional model override (e.g. "gpt-6-astra", "gpt-5.6-terra").',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
required: ['prompt'],
|
|
111
|
+
},
|
|
112
|
+
handler: async ({ prompt, model }) => {
|
|
113
|
+
const codexBin = resolveBinary('codex', 'CODEX_CLI_PATH');
|
|
114
|
+
if (!codexBin) {
|
|
115
|
+
return {
|
|
116
|
+
isError: true,
|
|
117
|
+
text: '❌ OpenAI Codex CLI (`codex`) not found on system.',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const args = [
|
|
122
|
+
'review',
|
|
123
|
+
prompt,
|
|
124
|
+
'-m',
|
|
125
|
+
model || DEFAULT_MODEL,
|
|
126
|
+
'--color',
|
|
127
|
+
'never',
|
|
128
|
+
];
|
|
129
|
+
|
|
130
|
+
const res = await executeProcess(codexBin, args, { timeoutMs: TIMEOUT_MS, toolName: 'codex' });
|
|
131
|
+
|
|
132
|
+
if (res.ok) {
|
|
133
|
+
return {
|
|
134
|
+
text: res.stdout || '(Codex review completed with no output)',
|
|
135
|
+
isError: false,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return formatResilientResponse({
|
|
140
|
+
provider: 'OpenAI Codex',
|
|
141
|
+
rawOutput: res.stderr || res.stdout,
|
|
142
|
+
exitCode: res.exitCode,
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export function createServer() {
|
|
148
|
+
return createMcpServer({
|
|
149
|
+
name: 'codex',
|
|
150
|
+
version: '1.0.0',
|
|
151
|
+
tools: [askCodexTool, reviewCodexTool],
|
|
152
|
+
});
|
|
153
|
+
}
|