Skip to content

Commit ab80e65

Browse files
chore: update readme with config file information
1 parent f43f956 commit ab80e65

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow
341341

342342
1. Command-line arguments
343343
2. Environment variables
344+
3. Configuration File
344345

345346
### Configuration Options
346347

@@ -562,6 +563,63 @@ For a full list of roles and their privileges, see the [Atlas User Roles documen
562563

563564
### Configuration Methods
564565

566+
#### Configuration File
567+
568+
Store configuration in a JSON file and load it using the `MDB_MCP_CONFIG` environment variable (recommended) or `--config` command-line argument.
569+
570+
> **🔒 Security Best Practice:** Prefer using the `MDB_MCP_CONFIG` environment variable over the `--config` CLI argument. Command-line arguments are visible in process listings.
571+
572+
> **🔒 File Security:** Ensure your configuration file has proper ownership and permissions, limited to the user running the MongoDB MCP server:
573+
>
574+
> **Linux/macOS:**
575+
>
576+
> ```bash
577+
> chmod 600 /path/to/config.json
578+
> chown your-username /path/to/config.json
579+
> ```
580+
>
581+
> **Windows:** Right-click the file → Properties → Security → Restrict access to your user account only.
582+
583+
Create a JSON file with your configuration (all keys use camelCase):
584+
585+
```json
586+
{
587+
"connectionString": "mongodb://localhost:27017",
588+
"readOnly": true,
589+
"loggers": ["stderr", "mcp"],
590+
"apiClientId": "your-atlas-service-accounts-client-id",
591+
"apiClientSecret": "your-atlas-service-accounts-client-secret",
592+
"maxDocumentsPerQuery": 100
593+
}
594+
```
595+
596+
**Linux/macOS (bash/zsh):**
597+
598+
```bash
599+
export MDB_MCP_CONFIG="/path/to/config.json"
600+
npx -y mongodb-mcp-server@latest
601+
```
602+
603+
**Windows Command Prompt (cmd):**
604+
605+
```cmd
606+
set "MDB_MCP_CONFIG=C:\path\to\config.json"
607+
npx -y mongodb-mcp-server@latest
608+
```
609+
610+
**Windows PowerShell:**
611+
612+
```powershell
613+
$env:MDB_MCP_CONFIG="C:\path\to\config.json"
614+
npx -y mongodb-mcp-server@latest
615+
```
616+
617+
Alternatively, use `--config` argument (less secure):
618+
619+
```bash
620+
npx -y mongodb-mcp-server@latest --config /path/to/config.json
621+
```
622+
565623
#### Environment Variables
566624

567625
Set environment variables with the prefix `MDB_MCP_` followed by the option name in uppercase with underscores:

0 commit comments

Comments
 (0)