|
1 | 1 | # MongoDB MCP Server |
2 | 2 |
|
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 | | - |
| 3 | +A Model Context Protocol server for interacting with MongoDB Databases and MongoDB Atlas. |
5 | 4 |
|
6 | 5 | ## 📚 Table of Contents |
7 | 6 |
|
8 | 7 | - [🚀 Getting Started](#getting-started) |
9 | 8 | - [Prerequisites](#prerequisites) |
10 | | - - [Installation](#installation) |
11 | | - - [WindSurf](#windsurf) |
12 | | - - [VSCode](#vscode) |
13 | | - - [Claude Desktop](#claude) |
| 9 | + - [Setup](#setup) |
| 10 | + - [Quick Start](#quick-start) |
14 | 11 | - [🛠️ Supported Tools](#supported-tools) |
15 | | - - [Tool List](#tool-list) |
| 12 | + - [MongoDB Atlas Tools](#mongodb-atlas-tools) |
| 13 | + - [MongoDB Database Tools](#mongodb-database-tools) |
16 | 14 | - [⚙️ Configuration](#configuration) |
17 | 15 | - [Configuration Options](#configuration-options) |
| 16 | + - [Connection Options](#configuration-options) |
| 17 | + - [Log Path](#log-path) |
| 18 | + - [Disabled Tools](#disabled-tools) |
| 19 | + - [Read-Only Mode](#read-only-mode) |
| 20 | + - [Telemetry Settings](#telemetry) |
18 | 21 | - [Atlas API Access](#atlas-api-access) |
19 | 22 | - [Configuration Methods](#configuration-methods) |
20 | | -- [👩💻 Client Integration](#client-integration) |
21 | | - - [WindSurf](#windsurf) |
22 | | - - [VSCode](#vscode) |
23 | | - - [Claude](#claude) |
| 23 | + - [Environment Variables](#environment-variables) |
| 24 | + - [Command-Line Arguments](#command-line-arguments) |
| 25 | + - [MCP Client Configuration](#mcp-configuration-file-examples) |
24 | 26 | - [🤝 Contributing](#contributing) |
25 | 27 |
|
26 | 28 | ## Prerequisites |
27 | 29 |
|
28 | 30 | - Node.js (v20 or later) |
29 | | -- MongoDB Atlas account |
30 | 31 |
|
31 | | -## Installation |
| 32 | +```shell |
| 33 | +node -v |
| 34 | +``` |
32 | 35 |
|
33 | | -Common prerequisites: |
| 36 | +- A MongoDB connection string or Atlas API credentials, **_the Server will not start unless configured_**. |
| 37 | + - **_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. |
| 38 | + - If you have a MongoDB connection string, you can use it directly to connect to your MongoDB instance. |
34 | 39 |
|
35 | | -- Node.js v20.x |
36 | | -- A MongoDB connection string or Atlas API credentials, the Server will not start unless configured, see [configuration](#configuration) section for more details. |
| 40 | +## Setup |
37 | 41 |
|
38 | | -### WindSurf |
| 42 | +### Quick Start |
39 | 43 |
|
40 | | -The latest instructions can be found at https://docs.windsurf.com/windsurf/mcp |
| 44 | +Most MCP clients require a configuration file to be created or modified to add the MCP server. |
41 | 45 |
|
42 | | -Step 1: Create MCP configuration file |
| 46 | +- **Windsurf** ([latest instructions](https://docs.windsurf.com/windsurf/mcp)): Save the file in `~/.codeium/windsurf/mcp_config.json` |
| 47 | +- **VSCode**: https://docs.codeium.com/docs/mcp |
| 48 | +- **Claude Desktop**: https://modelcontextprotocol.io/quickstart/user |
| 49 | +- **Cursor**: follow https://docs.cursor.com/context/model-context-protocol |
43 | 50 |
|
44 | | -Create or edit the configuration file at `~/.codeium/windsurf/mcp_config.json`: |
| 51 | +#### Option 1: Connection String args |
| 52 | + |
| 53 | +You can pass your connection string via args, make sure to use a valid username and password. |
45 | 54 |
|
46 | 55 | ```json |
47 | 56 | { |
48 | 57 | "servers": { |
49 | 58 | "MongoDB": { |
50 | 59 | "command": "npx", |
51 | | - "args": ["-y", "mongodb-mcp-server"] |
| 60 | + "args": [ |
| 61 | + "-y", |
| 62 | + "mongodb-mcp-server", |
| 63 | + "--connectionString", |
| 64 | + "mongodb+srv://username:password@cluster.mongodb.net/myDatabase" |
| 65 | + ] |
52 | 66 | } |
53 | 67 | } |
54 | 68 | } |
55 | 69 | ``` |
56 | 70 |
|
57 | | -Step 2: Setup a connection string or Atlas API credentials |
58 | | - |
59 | | -- Option 1: Connection String via args [example](#connection-string-with-args) |
60 | | -- Option 2: Atlas API credentials via args [example](#atlas-api-credentials-with-args) |
61 | | -- Option 3: Connection String via environment variables [example](#connection-string-with-environment-variables) |
62 | | -- Option 4: Atlas API credentials via environment variables [example](#atlas-api-credentials-with-environment-variables) |
63 | | - |
64 | | -### VSCode |
65 | | - |
66 | | -Step 1: Add the mcp server to VSCode configuration |
67 | | - |
68 | | -- Press `Cmd + Shift + P` and type `MCP: Add MCP Server` and select it. |
69 | | -- Select command (Stdio). |
70 | | -- Input command `npx -y mongodb-mcp-server`. |
71 | | -- Choose between user / workspace |
72 | | -- Add arguments to the file |
73 | | - |
74 | | -Note: the file should look like: |
75 | | - |
76 | | -``` |
77 | | -{ |
78 | | - "servers": { |
79 | | - "MongoDB": { |
80 | | - "type": "stdio", |
81 | | - "command": "npx", |
82 | | - "args": [ |
83 | | - "-y", |
84 | | - "mongodb-mcp-server" |
85 | | - ] |
86 | | - } |
87 | | - } |
88 | | -} |
89 | | -``` |
90 | | - |
91 | | -Step 2: Setup a connection string or Atlas API credentials |
92 | | - |
93 | | -- Option 1: Connection String via args [example](#connection-string-with-args) |
94 | | -- Option 2: Atlas API credentials via args [example](#atlas-api-credentials-with-args) |
95 | | -- Option 3: Connection String via environment variables [example](#connection-string-with-environment-variables) |
96 | | -- Option 4: Atlas API credentials via environment variables [example](#atlas-api-credentials-with-environment-variables) |
| 71 | +#### Option 2: Atlas API credentials args |
97 | 72 |
|
98 | | -### Claude Desktop |
99 | | - |
100 | | -Step 1: Launch Claude Settings -> Developer -> Edit Config |
101 | | - |
102 | | -Paste the mcp server configuration into the file |
| 73 | +Use your Atlas API Service Account credentials. More details in the [Atlas API Access](#atlas-api-access) section. |
103 | 74 |
|
104 | 75 | ```json |
105 | 76 | { |
106 | | - "mcpServers": { |
| 77 | + "servers": { |
107 | 78 | "MongoDB": { |
108 | 79 | "command": "npx", |
109 | | - "args": ["-y", "mongodb-mcp-server"] |
| 80 | + "args": [ |
| 81 | + "-y", |
| 82 | + "mongodb-mcp-server", |
| 83 | + "--apiClientId", |
| 84 | + "your-atlas-client-id", |
| 85 | + "--apiClientSecret", |
| 86 | + "your-atlas-client-secret" |
| 87 | + ] |
110 | 88 | } |
111 | 89 | } |
112 | 90 | } |
113 | 91 | ``` |
114 | 92 |
|
115 | | -Step 2: Setup a connection string or Atlas API credentials |
| 93 | +#### Other options |
| 94 | + |
| 95 | +Alternatively you can use environment variables in the config file or set them and run the server via npx. |
116 | 96 |
|
117 | | -- Option 1: Connection String via args [example](#connection-string-with-args) |
118 | | -- Option 2: Atlas API credentials via args [example](#atlas-api-credentials-with-args) |
119 | | -- Option 3: Connection String via environment variables [example](#connection-string-with-environment-variables) |
120 | | -- Option 4: Atlas API credentials via environment variables [example](#atlas-api-credentials-with-environment-variables) |
| 97 | +- Connection String via environment variables [example](#connection-string-with-environment-variables) |
| 98 | +- Atlas API credentials via environment variables [example](#atlas-api-credentials-with-environment-variables) |
121 | 99 |
|
122 | 100 | ## 🛠️ Supported Tools |
123 | 101 |
|
@@ -181,7 +159,7 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow |
181 | 159 | | `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations | |
182 | 160 | | `telemetry` | When set to disabled, disables telemetry collection | |
183 | 161 |
|
184 | | -#### `logPath` |
| 162 | +#### Log Path |
185 | 163 |
|
186 | 164 | Default log location is as follows: |
187 | 165 |
|
|
0 commit comments