@@ -5,15 +5,15 @@ import argv from "yargs-parser";
55import packageJson from "../package.json" with { type : "json" } ;
66import fs from "fs" ;
77import { ReadConcernLevel , ReadPreferenceMode , W } from "mongodb" ;
8- const { localDataPath , configPath } = getLocalDataPath ( ) ;
8+ import { log } from "console" ;
99
1010// If we decide to support non-string config options, we'll need to extend the mechanism for parsing
1111// env variables.
1212interface UserConfig {
1313 apiBaseUrl : string ;
1414 apiClientId ?: string ;
1515 apiClientSecret ?: string ;
16- stateFile : string ;
16+ logPath : string ;
1717 connectionString ?: string ;
1818 connectOptions : {
1919 readConcern : ReadConcernLevel ;
@@ -25,7 +25,7 @@ interface UserConfig {
2525
2626const defaults : UserConfig = {
2727 apiBaseUrl : "https://cloud.mongodb.com/" ,
28- stateFile : path . join ( localDataPath , "state.json" ) ,
28+ logPath : getLogPath ( ) ,
2929 connectOptions : {
3030 readConcern : "local" ,
3131 readPreference : "secondaryPreferred" ,
@@ -36,7 +36,6 @@ const defaults: UserConfig = {
3636
3737const mergedUserConfig = {
3838 ...defaults ,
39- ...getFileConfig ( ) ,
4039 ...getEnvConfig ( ) ,
4140 ...getCliConfig ( ) ,
4241} ;
@@ -46,33 +45,28 @@ const config = {
4645 atlasApiVersion : `2025-03-12` ,
4746 version : packageJson . version ,
4847 userAgent : `AtlasMCP/${ packageJson . version } (${ process . platform } ; ${ process . arch } ; ${ process . env . HOSTNAME || "unknown" } )` ,
49- localDataPath,
5048} ;
5149
5250export default config ;
5351
54- function getLocalDataPath ( ) : { localDataPath : string ; configPath : string } {
52+ function getLogPath ( ) : string {
5553 let localDataPath : string | undefined ;
56- let configPath : string | undefined ;
5754
5855 if ( process . platform === "win32" ) {
5956 const appData = process . env . APPDATA ;
6057 const localAppData = process . env . LOCALAPPDATA ?? process . env . APPDATA ;
6158 if ( localAppData && appData ) {
6259 localDataPath = path . join ( localAppData , "mongodb" , "mongodb-mcp" ) ;
63- configPath = path . join ( localDataPath , "mongodb-mcp.conf" ) ;
6460 }
6561 }
6662
6763 localDataPath ??= path . join ( os . homedir ( ) , ".mongodb" , "mongodb-mcp" ) ;
68- configPath ??= "/etc/mongodb-mcp.conf" ;
6964
70- fs . mkdirSync ( localDataPath , { recursive : true } ) ;
65+ const logPath = path . join ( localDataPath , ".app-logs" ) ;
7166
72- return {
73- localDataPath,
74- configPath,
75- } ;
67+ fs . mkdirSync ( logPath , { recursive : true } ) ;
68+
69+ return logPath ;
7670}
7771
7872// Gets the config supplied by the user as environment variables. The variable names
@@ -125,17 +119,6 @@ function SNAKE_CASE_toCamelCase(str: string): string {
125119 return str . toLowerCase ( ) . replace ( / ( [ - _ ] [ a - z ] ) / g, ( group ) => group . toUpperCase ( ) . replace ( "_" , "" ) ) ;
126120}
127121
128- // Gets the config supplied by the user as a JSON file. The file is expected to be located in the local data path
129- // and named `config.json`.
130- function getFileConfig ( ) : Partial < UserConfig > {
131- try {
132- const config = fs . readFileSync ( configPath , "utf8" ) ;
133- return JSON . parse ( config ) ;
134- } catch {
135- return { } ;
136- }
137- }
138-
139122// Reads the cli args and parses them into a UserConfig object.
140123function getCliConfig ( ) {
141124 return argv ( process . argv . slice ( 2 ) ) as unknown as Partial < UserConfig > ;
0 commit comments