Skip to content

Commit dbb24eb

Browse files
chore: add a section detailing config file parameter
1 parent fc3606a commit dbb24eb

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

README.md

Lines changed: 59 additions & 1 deletion
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

@@ -554,6 +555,63 @@ For a full list of roles and their privileges, see the [Atlas User Roles documen
554555

555556
### Configuration Methods
556557

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

559617
Set environment variables with the prefix `MDB_MCP_` followed by the option name in uppercase with underscores:
@@ -650,7 +708,7 @@ npx -y mongodb-mcp-server@latest --logPath=/path/to/logs --readOnly --indexCheck
650708

651709
> **💡 Platform Note:** The examples above use Unix/Linux/macOS syntax. For Windows users, see [Environment Variables](#environment-variables) for platform-specific instructions.
652710
653-
#### MCP configuration file examples
711+
#### MCP client configuration file examples
654712

655713
##### Connection String with command-line arguments
656714

0 commit comments

Comments
 (0)