@@ -4,7 +4,7 @@ import argv from "yargs-parser";
4
4
5
5
import packageJson from "../package.json" with { type : "json" } ;
6
6
import fs from "fs" ;
7
- const localDataPath = getLocalDataPath ( ) ;
7
+ const { localDataPath, configPath } = getLocalDataPath ( ) ;
8
8
9
9
// If we decide to support non-string config options, we'll need to extend the mechanism for parsing
10
10
// env variables.
@@ -37,22 +37,28 @@ const config = {
37
37
38
38
export default config ;
39
39
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 ;
42
43
43
44
if ( process . platform === "win32" ) {
44
45
const appData = process . env . APPDATA ;
45
46
const localAppData = process . env . LOCALAPPDATA ?? process . env . APPDATA ;
46
47
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" ) ;
48
50
}
49
51
}
50
52
51
- result ??= path . join ( os . homedir ( ) , ".mongodb" , "mongodb-mcp" ) ;
53
+ localDataPath ??= path . join ( os . homedir ( ) , ".mongodb" , "mongodb-mcp" ) ;
54
+ configPath ??= "/etc/mongodb-mcp.conf" ;
52
55
53
- fs . mkdirSync ( result , { recursive : true } ) ;
56
+ fs . mkdirSync ( localDataPath , { recursive : true } ) ;
54
57
55
- return result ;
58
+ return {
59
+ localDataPath,
60
+ configPath,
61
+ } ;
56
62
}
57
63
58
64
// Gets the config supplied by the user as environment variables. The variable names
@@ -77,8 +83,6 @@ function getEnvConfig(): Partial<UserConfig> {
77
83
// Gets the config supplied by the user as a JSON file. The file is expected to be located in the local data path
78
84
// and named `config.json`.
79
85
function getFileConfig ( ) : Partial < UserConfig > {
80
- const configPath = path . join ( localDataPath , "config.json" ) ;
81
-
82
86
try {
83
87
const config = fs . readFileSync ( configPath , "utf8" ) ;
84
88
return JSON . parse ( config ) ;
0 commit comments