@@ -10,38 +10,88 @@ A Model Context Protocol server for interacting with MongoDB Atlas. This project
10
10
- [ 🚀 Getting Started] ( #getting-started )
11
11
- [ Prerequisites] ( #prerequisites )
12
12
- [ Installation] ( #installation )
13
- - [ Running the MCP Server] ( #running-the-mcp-server )
13
+ - [ VSCode] ( #vscode )
14
+ - [ Claude Desktop] ( #claude )
14
15
- [ 🛠️ Supported Tools] ( #supported-tools )
15
16
- [ Tool List] ( #tool-list )
17
+ - [ ⚙️ Configuration] ( #configuration )
18
+ - [ Configuration Options] ( #configuration-options )
19
+ - [ Atlas API Access] ( #atlas-api-access )
20
+ - [ Configuration Methods] ( #configuration-methods )
16
21
- [ 👩💻 Client Integration] ( #client-integration )
17
22
- [ VSCode] ( #vscode )
18
23
- [ Claude] ( #claude )
19
24
- [ 🤝 Contributing] ( #contributing )
20
25
21
- ## 🚀 Getting Started
22
-
23
- ### Prerequisites
26
+ ## Prerequisites
24
27
25
28
- Node.js (v20 or later)
26
29
- MongoDB Atlas account
27
30
28
- ### Installation
31
+ ## Installation
29
32
30
- ``` shell
31
- # Clone the repository
32
- git clone https://github.com/mongodb-labs/mongodb-mcp-server.git
33
- cd mongodb-mcp-server
33
+ ### VSCode
34
+
35
+ Prerequisites:
36
+
37
+ - Node.js v20.x
38
+
39
+ Step 1: Add the mcp server to VSCode configuration
40
+
41
+ - Press ` Cmd + Shift + P ` and type ` MCP: Add MCP Server ` and select it.
42
+ - Select command (Stdio).
43
+ - Input command ` npx -y @mongodb-js/mongodb-mcp-server ` .
44
+ - Choose between user / workspace
45
+ - Add arguments to the file
46
+
47
+ Note: the file should look like:
34
48
35
- # Install dependencies
36
- npm install
49
+ ```
50
+ {
51
+ "servers": {
52
+ "MongoDB": {
53
+ "type": "stdio",
54
+ "command": "npx",
55
+ "args": [
56
+ "-y",
57
+ "@mongodb-js/mongodb-mcp-server"
58
+ ]
59
+ }
60
+ }
61
+ }
37
62
```
38
63
39
- ### Running the MCP Server
64
+ Notes: You can configure the server with atlas access, make sure to follow configuration section for more details.
40
65
41
- ``` shell
42
- npm run build
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
77
+
78
+ Paste the mcp server configuration into the file
79
+
80
+ ``` json
81
+ {
82
+ "mcpServers" : {
83
+ "MongoDB" : {
84
+ "command" : " npx" ,
85
+ "args" : [" -y" , " @mongodb-js/mongodb-mcp-server" ]
86
+ }
87
+ }
88
+ }
43
89
```
44
90
91
+ Step 3: Close and Relaunch Claude Desktop and click on the hammer icon, the MongoDB MCP server should be detected.
92
+
93
+ You may experiment asking ` Can you connect to my mongodb instance? ` .
94
+
45
95
## 🛠️ Supported Tools
46
96
47
97
### Tool List
@@ -80,77 +130,6 @@ npm run build
80
130
- ` collection-storage-size ` - Get the size of a collection in MB
81
131
- ` db-stats ` - Return statistics about a MongoDB database
82
132
83
- ## 👩💻 Client Integration (Use the server!)
84
-
85
- ### VSCode
86
-
87
- Prerequisites:
88
-
89
- - Node.js v20.x
90
-
91
- Step 1: Add the mcp server to VSCode configuration
92
-
93
- - Press ` Cmd + Shift + P ` and type ` MCP: Add MCP Server ` and select it.
94
- - Select the first option for a local MCP server.
95
- - Add the path to dist/index.js in the prompt
96
-
97
- Step 2: Verify the created mcp file
98
-
99
- It should look like this
100
-
101
- ``` json
102
- {
103
- "servers" : {
104
- "mongodb-mcp-server" : {
105
- "type" : " stdio" ,
106
- "command" : " npx" ,
107
- "args" : [" -y" , " @mongodb-js/mongodb-mcp-server" ]
108
- }
109
- }
110
- }
111
- ```
112
-
113
- Notes: You can configure the server with atlas access, make sure to follow configuration section for more details.
114
-
115
- Step 3: Open the copilot chat and check that the toolbox icon is visible and has the mcp server listed.
116
-
117
- Step 4: Try running a command
118
-
119
- - Can you list my clusters?
120
-
121
- ### Claude
122
-
123
- Step 1: Install claude and login
124
-
125
- ``` shell
126
- brew install claude
127
- ```
128
-
129
- Step 2: Create a configuration file for your MCP server
130
-
131
- Open the file
132
-
133
- ``` shell
134
- code ~ /Library/Application\ Support/Claude/claude_desktop_config.json
135
- ```
136
-
137
- Paste the mcp server configuration into the file
138
-
139
- ``` json
140
- {
141
- "mcpServers" : {
142
- "Demo" : {
143
- "command" : " npx" ,
144
- "args" : [" -y" , " @mongodb-js/mongodb-mcp-server" ]
145
- }
146
- }
147
- }
148
- ```
149
-
150
- Step 3: Launch Claude Desktop and click on the hammer icon, the Demo MCP server should be detected. Type in the chat "show me a demo of MCP" and allow the tool to get access.
151
-
152
- Note: If you make changes to your MCP server code, rebuild the project with ` npm run build ` and restart the server and Claude Desktop.
153
-
154
133
## Configuration
155
134
156
135
The MongoDB MCP Server can be configured using multiple methods, with the following precedence (highest to lowest):
@@ -219,7 +198,7 @@ export MDB_MCP_LOG_PATH="/path/to/logs"
219
198
Pass configuration options as command-line arguments when starting the server:
220
199
221
200
``` shell
222
- node dist/index.js --apiClientId=" your-atlas-client-id" --apiClientSecret=" your-atlas-client-secret" --connectionString=" mongodb+srv://username:password@cluster.mongodb.net/myDatabase" --logPath=/path/to/logs
201
+ npx -y @mongodb-js/mongodb-mcp-server --apiClientId=" your-atlas-client-id" --apiClientSecret=" your-atlas-client-secret" --connectionString=" mongodb+srv://username:password@cluster.mongodb.net/myDatabase" --logPath=/path/to/logs
223
202
```
224
203
225
204
## 🤝 Contributing
0 commit comments