@@ -4,7 +4,7 @@ import argv from "yargs-parser";
44
55import packageJson from "../package.json" with { type : "json" } ;
66import fs from "fs" ;
7- const localDataPath = getLocalDataPath ( ) ;
7+ const { localDataPath, configPath } = getLocalDataPath ( ) ;
88
99// If we decide to support non-string config options, we'll need to extend the mechanism for parsing
1010// env variables.
@@ -37,22 +37,28 @@ const config = {
3737
3838export default config ;
3939
40- function getLocalDataPath ( ) : string {
41- let result : string | undefined ;
40+ function getLocalDataPath ( ) : { localDataPath : string ; configPath : string } {
41+ let localDataPath : string | undefined ;
42+ let configPath : string | undefined ;
4243
4344 if ( process . platform === "win32" ) {
4445 const appData = process . env . APPDATA ;
4546 const localAppData = process . env . LOCALAPPDATA ?? process . env . APPDATA ;
4647 if ( localAppData && appData ) {
47- result = path . join ( localAppData , "mongodb" , "mongodb-mcp" ) ;
48+ localDataPath = path . join ( localAppData , "mongodb" , "mongodb-mcp" ) ;
49+ configPath = path . join ( localAppData , "mongodb" , "mongodb-mcp.conf" ) ;
4850 }
4951 }
5052
51- result ??= path . join ( os . homedir ( ) , ".mongodb" , "mongodb-mcp" ) ;
53+ localDataPath ??= path . join ( os . homedir ( ) , ".mongodb" , "mongodb-mcp" ) ;
54+ configPath ??= "/etc/mongodb-mcp.conf" ;
5255
53- fs . mkdirSync ( result , { recursive : true } ) ;
56+ fs . mkdirSync ( localDataPath , { recursive : true } ) ;
5457
55- return result ;
58+ return {
59+ localDataPath,
60+ configPath,
61+ } ;
5662}
5763
5864// Gets the config supplied by the user as environment variables. The variable names
@@ -77,8 +83,6 @@ function getEnvConfig(): Partial<UserConfig> {
7783// Gets the config supplied by the user as a JSON file. The file is expected to be located in the local data path
7884// and named `config.json`.
7985function getFileConfig ( ) : Partial < UserConfig > {
80- const configPath = path . join ( localDataPath , "config.json" ) ;
81-
8286 try {
8387 const config = fs . readFileSync ( configPath , "utf8" ) ;
8488 return JSON . parse ( config ) ;
0 commit comments