Skip to content

Commit 6ee5634

Browse files
authored
chore: update config docs (#170)
1 parent de2c604 commit 6ee5634

File tree

1 file changed

+127
-52
lines changed

1 file changed

+127
-52
lines changed

README.md

Lines changed: 127 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
11
# MongoDB MCP Server
22

3-
A Model Context Protocol server for interacting with MongoDB Atlas. This project implements a Model Context Protocol (MCP) server enabling AI assistants to interact with MongoDB Atlas resources through natural language.
4-
5-
> [!CAUTION]
6-
> Do not use this in production. This is a work in progress and is not intended for production use. It is meant for demonstration purposes only.
3+
A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas.
74

85
## 📚 Table of Contents
96

107
- [🚀 Getting Started](#getting-started)
118
- [Prerequisites](#prerequisites)
12-
- [Installation](#installation)
13-
- [VSCode](#vscode)
14-
- [Claude Desktop](#claude)
9+
- [Setup](#setup)
10+
- [Quick Start](#quick-start)
1511
- [🛠️ Supported Tools](#supported-tools)
16-
- [Tool List](#tool-list)
12+
- [MongoDB Atlas Tools](#mongodb-atlas-tools)
13+
- [MongoDB Database Tools](#mongodb-database-tools)
1714
- [⚙️ Configuration](#configuration)
1815
- [Configuration Options](#configuration-options)
1916
- [Atlas API Access](#atlas-api-access)
2017
- [Configuration Methods](#configuration-methods)
21-
- [👩‍💻 Client Integration](#client-integration)
22-
- [VSCode](#vscode)
23-
- [Claude](#claude)
18+
- [Environment Variables](#environment-variables)
19+
- [Command-Line Arguments](#command-line-arguments)
20+
- [MCP Client Configuration](#mcp-configuration-file-examples)
2421
- [🤝 Contributing](#contributing)
2522

2623
## Prerequisites
2724

2825
- Node.js (v20 or later)
29-
- MongoDB Atlas account
3026

31-
## Installation
27+
```shell
28+
node -v
29+
```
3230

33-
### VSCode
31+
- A MongoDB connection string or Atlas API credentials, **_the Server will not start unless configured_**.
32+
- **_Atlas API credentials_** are required to use the Atlas tools. You can create a service account in MongoDB Atlas and use its credentials for authentication. See [Atlas API Access](#atlas-api-access) for more details.
33+
- If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance.
3434

35-
Prerequisites:
35+
## Setup
3636

37-
- Node.js v20.x
37+
### Quick Start
3838

39-
Step 1: Add the mcp server to VSCode configuration
39+
Most MCP clients require a configuration file to be created or modified to add the MCP server.
4040

41-
- Press `Cmd + Shift + P` and type `MCP: Add MCP Server` and select it.
42-
- Select command (Stdio).
43-
- Input command `npx -y mongodb-mcp-server`.
44-
- Choose between user / workspace
45-
- Add arguments to the file
41+
- **Windsurf**:https://docs.windsurf.com/windsurf/mcp
42+
- **VSCode**: https://docs.codeium.com/docs/mcp
43+
- **Claude Desktop**: https://modelcontextprotocol.io/quickstart/user
44+
- **Cursor**: https://docs.cursor.com/context/model-context-protocol
4645

47-
Note: the file should look like:
46+
#### Option 1: Connection String args
4847

49-
```
48+
You can pass your connection string via args, make sure to use a valid username and password.
49+
50+
```json
5051
{
51-
"servers": {
52-
"MongoDB": {
53-
"type": "stdio",
54-
"command": "npx",
55-
"args": [
56-
"-y",
57-
"mongodb-mcp-server"
58-
]
59-
}
52+
"servers": {
53+
"MongoDB": {
54+
"command": "npx",
55+
"args": [
56+
"-y",
57+
"mongodb-mcp-server",
58+
"--connectionString",
59+
"mongodb+srv://username:[email protected]/myDatabase"
60+
]
6061
}
62+
}
6163
}
6264
```
6365

64-
Notes: You can configure the server with atlas access, make sure to follow configuration section for more details.
65-
66-
Step 2: Try talking to github copilot
67-
68-
- Can you connect to my mongodb instance?
69-
70-
### Claude Desktop
71-
72-
Step 1: Install claude and login
73-
74-
Note: follow instructions at https://claude.ai/download
75-
76-
Step 2: Launch Claude Settings -> Developer -> Edit Config
66+
#### Option 2: Atlas API credentials args
7767

78-
Paste the mcp server configuration into the file
68+
Use your Atlas API Service Account credentials. More details in the [Atlas API Access](#atlas-api-access) section.
7969

8070
```json
8171
{
82-
"mcpServers": {
72+
"servers": {
8373
"MongoDB": {
8474
"command": "npx",
85-
"args": ["-y", "mongodb-mcp-server"]
75+
"args": [
76+
"-y",
77+
"mongodb-mcp-server",
78+
"--apiClientId",
79+
"your-atlas-client-id",
80+
"--apiClientSecret",
81+
"your-atlas-client-secret"
82+
]
8683
}
8784
}
8885
}
8986
```
9087

91-
Step 3: Close and Relaunch Claude Desktop and click on the hammer icon, the MongoDB MCP server should be detected.
88+
#### Other options
9289

93-
You may experiment asking `Can you connect to my mongodb instance?`.
90+
Alternatively you can use environment variables in the config file or set them and run the server via npx.
91+
92+
- Connection String via environment variables in the MCP file [example](#connection-string-with-environment-variables)
93+
- Atlas API credentials via environment variables in the MCP file [example](#atlas-api-credentials-with-environment-variables)
9494

9595
## 🛠️ Supported Tools
9696

@@ -154,7 +154,7 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow
154154
| `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations |
155155
| `telemetry` | When set to disabled, disables telemetry collection |
156156

157-
#### `logPath`
157+
#### Log Path
158158

159159
Default log location is as follows:
160160

@@ -250,6 +250,41 @@ export MDB_MCP_LOG_PATH="/path/to/logs"
250250

251251
```
252252

253+
#### MCP configuration file examples
254+
255+
##### Connection String with environment variables
256+
257+
```json
258+
{
259+
"servers": {
260+
"MongoDB": {
261+
"command": "npx",
262+
"args": ["-y", "mongodb-mcp-server"],
263+
"env": {
264+
"MDB_MCP_CONNECTION_STRING": "mongodb+srv://username:[email protected]/myDatabase"
265+
}
266+
}
267+
}
268+
}
269+
```
270+
271+
##### Atlas API credentials with environment variables
272+
273+
```json
274+
{
275+
"servers": {
276+
"MongoDB": {
277+
"command": "npx",
278+
"args": ["-y", "mongodb-mcp-server"],
279+
"env": {
280+
"MDB_MCP_API_CLIENT_ID": "your-atlas-client-id",
281+
"MDB_MCP_API_CLIENT_SECRET": "your-atlas-client-secret"
282+
}
283+
}
284+
}
285+
}
286+
```
287+
253288
#### Command-Line Arguments
254289

255290
Pass configuration options as command-line arguments when starting the server:
@@ -258,6 +293,46 @@ Pass configuration options as command-line arguments when starting the server:
258293
npx -y mongodb-mcp-server --apiClientId="your-atlas-client-id" --apiClientSecret="your-atlas-client-secret" --connectionString="mongodb+srv://username:[email protected]/myDatabase" --logPath=/path/to/logs
259294
```
260295

296+
#### MCP configuration file examples
297+
298+
##### Connection String with command-line arguments
299+
300+
```json
301+
{
302+
"servers": {
303+
"MongoDB": {
304+
"command": "npx",
305+
"args": [
306+
"-y",
307+
"mongodb-mcp-server",
308+
"--connectionString",
309+
"mongodb+srv://username:[email protected]/myDatabase"
310+
]
311+
}
312+
}
313+
}
314+
```
315+
316+
##### Atlas API credentials with command-line arguments
317+
318+
```json
319+
{
320+
"servers": {
321+
"MongoDB": {
322+
"command": "npx",
323+
"args": [
324+
"-y",
325+
"mongodb-mcp-server",
326+
"--apiClientId",
327+
"your-atlas-client-id",
328+
"--apiClientSecret",
329+
"your-atlas-client-secret"
330+
]
331+
}
332+
}
333+
}
334+
```
335+
261336
## 🤝 Contributing
262337

263338
Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information.

0 commit comments

Comments
 (0)