@@ -6,10 +6,10 @@ import { applyEdits, findNodeAtLocation, modify, parseTree } from "jsonc-parser"
66import type { Platform } from "./setupAiToolsUtils.js" ;
77import { formatError , getPlatform } from "./setupAiToolsUtils.js" ;
88
9- export type AIToolType = "cursor" | "vscode" | "windsurf" | "claudeDesktop" | "claudeCode" | "codex" | " opencode";
9+ export type AIToolType = "cursor" | "vscode" | "windsurf" | "claudeDesktop" | "claudeCode" | "opencode" ;
1010
1111// These are tools that don't have a designated editor to open the config file
12- export const TOOLS_WITHOUT_EDITORS : AIToolType [ ] = [ "claudeDesktop" , "claudeCode" , "codex" , " opencode"] ;
12+ export const TOOLS_WITHOUT_EDITORS : AIToolType [ ] = [ "claudeDesktop" , "claudeCode" , "opencode" ] ;
1313
1414const MCP_SERVER_KEY = "mongodb-mcp-server" ;
1515type EnvironmentKey = "env" | "environment" ;
@@ -195,10 +195,10 @@ export abstract class AITool {
195195
196196 const existingContent = fs . existsSync ( configPath ) ? fs . readFileSync ( configPath , "utf-8" ) : null ;
197197 if ( existingContent !== null && existingContent . trim ( ) . length > 0 ) {
198- // Patch in place with jsonc-parser (preserves comments and rest of file)
199198 const resolvedPath = path . resolve ( configPath ) ;
200199 ensureConfigDir ( configPath ) ;
201200 try {
201+ // Patch in place if file already has content
202202 const patch = toPatch ( updatedMcpConfigEntry , environmentKey ) ;
203203 const newContent = updateConfigInPlace ( existingContent , serversKey , patch , updatedMcpConfigEntry ) ;
204204 fs . writeFileSync ( resolvedPath , newContent , "utf-8" ) ;
@@ -315,49 +315,6 @@ class ClaudeCode extends AITool {
315315 }
316316}
317317
318- class Codex extends AITool {
319- name = "OpenAI Codex" ;
320- configFileName = "config.toml" ;
321- get configPath ( ) : string {
322- return path . join ( getBasePath ( ) , ".codex" , "config.toml" ) ;
323- }
324-
325- // The config file for codex is in TOML format, so the the values for each field is in-line
326- override updateConfig ( configPath : string , env : Record < string , string > , isReadOnly : boolean ) : void {
327- const args = [ "-y" , "mongodb-mcp-server@latest" ] ;
328- if ( isReadOnly ) {
329- args . push ( "--readOnly" ) ;
330- }
331- const envEntry =
332- Object . keys ( env ) . length > 0
333- ? `\nenv = { ${ Object . entries ( env )
334- . map ( ( [ k , v ] ) => `${ JSON . stringify ( k ) } = ${ JSON . stringify ( v ) } ` )
335- . join ( ", " ) } }`
336- : "" ;
337- const section = `[mcp_servers.mongodb-mcp-server]
338- command = "npx"
339- args = ${ JSON . stringify ( args ) } ${ envEntry } ` ;
340-
341- let existing = "" ;
342- if ( fs . existsSync ( configPath ) ) {
343- existing = fs . readFileSync ( configPath , "utf-8" ) ;
344- if ( existing . includes ( "[mcp_servers.mongodb-mcp-server]" ) ) {
345- // TODO: this cannot return, we'd need to modify with new fields
346- return ;
347- }
348- if ( ! existing . endsWith ( "\n" ) ) {
349- existing += "\n" ;
350- }
351- } else {
352- const configDir = path . dirname ( configPath ) ;
353- if ( ! fs . existsSync ( configDir ) ) {
354- fs . mkdirSync ( configDir , { recursive : true } ) ;
355- }
356- }
357- fs . writeFileSync ( configPath , existing + "\n" + section + "\n" ) ;
358- }
359- }
360-
361318class OpenCode extends AITool {
362319 name = "Open Code" ;
363320 configFileName = "opencode.json" ;
@@ -390,6 +347,5 @@ export const AI_TOOL_REGISTRY: Record<AIToolType, AITool> = {
390347 [ "windsurf" ] : new Windsurf ( ) ,
391348 [ "claudeDesktop" ] : new ClaudeDesktop ( ) ,
392349 [ "claudeCode" ] : new ClaudeCode ( ) ,
393- [ "codex" ] : new Codex ( ) ,
394350 [ "opencode" ] : new OpenCode ( ) ,
395351} ;
0 commit comments