mongodb-mcp-server 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/.github/workflows/accuracy-tests.yml +55 -0
  2. package/.github/workflows/check.yml +1 -1
  3. package/.github/workflows/code_health.yaml +1 -1
  4. package/.github/workflows/code_health_fork.yaml +0 -14
  5. package/.github/workflows/dependabot_pr.yaml +26 -0
  6. package/.github/workflows/jira-issue.yml +72 -0
  7. package/.vscode/extensions.json +1 -1
  8. package/.vscode/launch.json +11 -1
  9. package/.vscode/settings.json +1 -11
  10. package/Dockerfile +1 -0
  11. package/README.md +118 -31
  12. package/dist/common/atlas/accessListUtils.js +36 -0
  13. package/dist/common/atlas/accessListUtils.js.map +1 -0
  14. package/dist/common/atlas/apiClient.js +25 -6
  15. package/dist/common/atlas/apiClient.js.map +1 -1
  16. package/dist/common/atlas/cluster.js +1 -1
  17. package/dist/common/atlas/cluster.js.map +1 -1
  18. package/dist/{config.js → common/config.js} +7 -1
  19. package/dist/common/config.js.map +1 -0
  20. package/dist/common/errors.js.map +1 -0
  21. package/dist/{logger.js → common/logger.js} +20 -18
  22. package/dist/common/logger.js.map +1 -0
  23. package/dist/common/managedTimeout.js +20 -0
  24. package/dist/common/managedTimeout.js.map +1 -0
  25. package/dist/common/packageInfo.js.map +1 -0
  26. package/dist/{session.js → common/session.js} +20 -21
  27. package/dist/common/session.js.map +1 -0
  28. package/dist/common/sessionStore.js +73 -0
  29. package/dist/common/sessionStore.js.map +1 -0
  30. package/dist/helpers/container.js +28 -0
  31. package/dist/helpers/container.js.map +1 -0
  32. package/dist/helpers/generatePassword.js.map +1 -0
  33. package/dist/helpers/indexCheck.js +1 -1
  34. package/dist/helpers/indexCheck.js.map +1 -1
  35. package/dist/index.js +30 -37
  36. package/dist/index.js.map +1 -1
  37. package/dist/server.js +43 -6
  38. package/dist/server.js.map +1 -1
  39. package/dist/telemetry/constants.js +1 -1
  40. package/dist/telemetry/constants.js.map +1 -1
  41. package/dist/telemetry/telemetry.js +28 -21
  42. package/dist/telemetry/telemetry.js.map +1 -1
  43. package/dist/tools/atlas/atlasTool.js +3 -3
  44. package/dist/tools/atlas/atlasTool.js.map +1 -1
  45. package/dist/tools/atlas/connect/connectCluster.js +198 -0
  46. package/dist/tools/atlas/connect/connectCluster.js.map +1 -0
  47. package/dist/tools/atlas/create/createAccessList.js +9 -10
  48. package/dist/tools/atlas/create/createAccessList.js.map +1 -1
  49. package/dist/tools/atlas/create/createDBUser.js +3 -1
  50. package/dist/tools/atlas/create/createDBUser.js.map +1 -1
  51. package/dist/tools/atlas/create/createFreeCluster.js +2 -0
  52. package/dist/tools/atlas/create/createFreeCluster.js.map +1 -1
  53. package/dist/tools/atlas/create/createProject.js.map +1 -1
  54. package/dist/tools/atlas/read/inspectAccessList.js.map +1 -1
  55. package/dist/tools/atlas/read/inspectCluster.js.map +1 -1
  56. package/dist/tools/atlas/read/listAlerts.js.map +1 -1
  57. package/dist/tools/atlas/read/listClusters.js.map +1 -1
  58. package/dist/tools/atlas/read/listDBUsers.js.map +1 -1
  59. package/dist/tools/atlas/read/listOrgs.js.map +1 -1
  60. package/dist/tools/atlas/read/listProjects.js.map +1 -1
  61. package/dist/tools/atlas/tools.js +1 -1
  62. package/dist/tools/atlas/tools.js.map +1 -1
  63. package/dist/tools/mongodb/{metadata → connect}/connect.js +7 -4
  64. package/dist/tools/mongodb/connect/connect.js.map +1 -0
  65. package/dist/tools/mongodb/create/createCollection.js.map +1 -1
  66. package/dist/tools/mongodb/create/createIndex.js +1 -1
  67. package/dist/tools/mongodb/create/createIndex.js.map +1 -1
  68. package/dist/tools/mongodb/create/insertMany.js +1 -1
  69. package/dist/tools/mongodb/create/insertMany.js.map +1 -1
  70. package/dist/tools/mongodb/delete/deleteMany.js +2 -1
  71. package/dist/tools/mongodb/delete/deleteMany.js.map +1 -1
  72. package/dist/tools/mongodb/delete/dropCollection.js.map +1 -1
  73. package/dist/tools/mongodb/delete/dropDatabase.js.map +1 -1
  74. package/dist/tools/mongodb/metadata/collectionSchema.js.map +1 -1
  75. package/dist/tools/mongodb/metadata/collectionStorageSize.js.map +1 -1
  76. package/dist/tools/mongodb/metadata/dbStats.js.map +1 -1
  77. package/dist/tools/mongodb/metadata/explain.js +1 -1
  78. package/dist/tools/mongodb/metadata/explain.js.map +1 -1
  79. package/dist/tools/mongodb/metadata/listCollections.js.map +1 -1
  80. package/dist/tools/mongodb/metadata/listDatabases.js.map +1 -1
  81. package/dist/tools/mongodb/metadata/logs.js.map +1 -1
  82. package/dist/tools/mongodb/mongodbTool.js +37 -10
  83. package/dist/tools/mongodb/mongodbTool.js.map +1 -1
  84. package/dist/tools/mongodb/read/aggregate.js +1 -1
  85. package/dist/tools/mongodb/read/aggregate.js.map +1 -1
  86. package/dist/tools/mongodb/read/collectionIndexes.js.map +1 -1
  87. package/dist/tools/mongodb/read/count.js +2 -1
  88. package/dist/tools/mongodb/read/count.js.map +1 -1
  89. package/dist/tools/mongodb/read/find.js +7 -4
  90. package/dist/tools/mongodb/read/find.js.map +1 -1
  91. package/dist/tools/mongodb/tools.js +1 -1
  92. package/dist/tools/mongodb/tools.js.map +1 -1
  93. package/dist/tools/mongodb/update/renameCollection.js.map +1 -1
  94. package/dist/tools/mongodb/update/updateMany.js +4 -2
  95. package/dist/tools/mongodb/update/updateMany.js.map +1 -1
  96. package/dist/tools/tool.js +8 -5
  97. package/dist/tools/tool.js.map +1 -1
  98. package/dist/transports/base.js +26 -0
  99. package/dist/transports/base.js.map +1 -0
  100. package/dist/{helpers/EJsonTransport.js → transports/stdio.js} +24 -2
  101. package/dist/transports/stdio.js.map +1 -0
  102. package/dist/transports/streamableHttp.js +140 -0
  103. package/dist/transports/streamableHttp.js.map +1 -0
  104. package/eslint.config.js +13 -4
  105. package/package.json +43 -33
  106. package/resources/test-summary-template.html +415 -0
  107. package/scripts/accuracy/generateTestSummary.ts +335 -0
  108. package/scripts/accuracy/runAccuracyTests.sh +45 -0
  109. package/scripts/accuracy/updateAccuracyRunStatus.ts +21 -0
  110. package/src/common/atlas/accessListUtils.ts +54 -0
  111. package/src/common/atlas/apiClient.ts +25 -6
  112. package/src/common/atlas/cluster.ts +1 -1
  113. package/src/{config.ts → common/config.ts} +14 -2
  114. package/src/{logger.ts → common/logger.ts} +21 -23
  115. package/src/common/managedTimeout.ts +27 -0
  116. package/src/{session.ts → common/session.ts} +24 -26
  117. package/src/common/sessionStore.ts +111 -0
  118. package/src/helpers/container.ts +35 -0
  119. package/src/helpers/indexCheck.ts +1 -1
  120. package/src/index.ts +30 -40
  121. package/src/server.ts +54 -10
  122. package/src/telemetry/constants.ts +1 -1
  123. package/src/telemetry/telemetry.ts +34 -26
  124. package/src/telemetry/types.ts +2 -0
  125. package/src/tools/atlas/atlasTool.ts +4 -4
  126. package/src/tools/atlas/connect/connectCluster.ts +259 -0
  127. package/src/tools/atlas/create/createAccessList.ts +15 -13
  128. package/src/tools/atlas/create/createDBUser.ts +5 -3
  129. package/src/tools/atlas/create/createFreeCluster.ts +4 -2
  130. package/src/tools/atlas/create/createProject.ts +2 -2
  131. package/src/tools/atlas/read/inspectAccessList.ts +2 -2
  132. package/src/tools/atlas/read/inspectCluster.ts +2 -2
  133. package/src/tools/atlas/read/listAlerts.ts +2 -2
  134. package/src/tools/atlas/read/listClusters.ts +2 -2
  135. package/src/tools/atlas/read/listDBUsers.ts +2 -2
  136. package/src/tools/atlas/read/listOrgs.ts +2 -2
  137. package/src/tools/atlas/read/listProjects.ts +2 -2
  138. package/src/tools/atlas/tools.ts +1 -1
  139. package/src/tools/mongodb/{metadata → connect}/connect.ts +12 -9
  140. package/src/tools/mongodb/create/createCollection.ts +2 -2
  141. package/src/tools/mongodb/create/createIndex.ts +3 -3
  142. package/src/tools/mongodb/create/insertMany.ts +3 -3
  143. package/src/tools/mongodb/delete/deleteMany.ts +4 -3
  144. package/src/tools/mongodb/delete/dropCollection.ts +2 -2
  145. package/src/tools/mongodb/delete/dropDatabase.ts +2 -2
  146. package/src/tools/mongodb/metadata/collectionSchema.ts +2 -2
  147. package/src/tools/mongodb/metadata/collectionStorageSize.ts +2 -2
  148. package/src/tools/mongodb/metadata/dbStats.ts +2 -2
  149. package/src/tools/mongodb/metadata/explain.ts +3 -3
  150. package/src/tools/mongodb/metadata/listCollections.ts +2 -2
  151. package/src/tools/mongodb/metadata/listDatabases.ts +2 -2
  152. package/src/tools/mongodb/metadata/logs.ts +2 -2
  153. package/src/tools/mongodb/mongodbTool.ts +50 -14
  154. package/src/tools/mongodb/read/aggregate.ts +3 -3
  155. package/src/tools/mongodb/read/collectionIndexes.ts +2 -2
  156. package/src/tools/mongodb/read/count.ts +4 -3
  157. package/src/tools/mongodb/read/find.ts +11 -6
  158. package/src/tools/mongodb/tools.ts +1 -1
  159. package/src/tools/mongodb/update/renameCollection.ts +2 -2
  160. package/src/tools/mongodb/update/updateMany.ts +6 -4
  161. package/src/tools/tool.ts +18 -13
  162. package/src/transports/base.ts +34 -0
  163. package/src/{helpers/EJsonTransport.ts → transports/stdio.ts} +30 -1
  164. package/src/transports/streamableHttp.ts +178 -0
  165. package/tests/accuracy/aggregate.test.ts +27 -0
  166. package/tests/accuracy/collectionIndexes.test.ts +40 -0
  167. package/tests/accuracy/collectionSchema.test.ts +28 -0
  168. package/tests/accuracy/collectionStorageSize.test.ts +41 -0
  169. package/tests/accuracy/count.test.ts +44 -0
  170. package/tests/accuracy/createCollection.test.ts +46 -0
  171. package/tests/accuracy/createIndex.test.ts +37 -0
  172. package/tests/accuracy/dbStats.test.ts +15 -0
  173. package/tests/accuracy/deleteMany.test.ts +44 -0
  174. package/tests/accuracy/dropCollection.test.ts +74 -0
  175. package/tests/accuracy/dropDatabase.test.ts +41 -0
  176. package/tests/accuracy/explain.test.ts +73 -0
  177. package/tests/accuracy/find.test.ts +114 -0
  178. package/tests/accuracy/insertMany.test.ts +48 -0
  179. package/tests/accuracy/listCollections.test.ts +60 -0
  180. package/tests/accuracy/listDatabases.test.ts +31 -0
  181. package/tests/accuracy/logs.test.ts +28 -0
  182. package/tests/accuracy/renameCollection.test.ts +31 -0
  183. package/tests/accuracy/sdk/accuracyResultStorage/diskStorage.ts +189 -0
  184. package/tests/accuracy/sdk/accuracyResultStorage/getAccuracyResultStorage.ts +11 -0
  185. package/tests/accuracy/sdk/accuracyResultStorage/mongodbStorage.ts +151 -0
  186. package/tests/accuracy/sdk/accuracyResultStorage/resultStorage.ts +117 -0
  187. package/tests/accuracy/sdk/accuracyScorer.ts +93 -0
  188. package/tests/accuracy/sdk/accuracyTestingClient.ts +94 -0
  189. package/tests/accuracy/sdk/agent.ts +56 -0
  190. package/tests/accuracy/sdk/constants.ts +26 -0
  191. package/tests/accuracy/sdk/describeAccuracyTests.ts +126 -0
  192. package/tests/accuracy/sdk/gitInfo.ts +7 -0
  193. package/tests/accuracy/sdk/matcher.ts +193 -0
  194. package/tests/accuracy/sdk/models.ts +95 -0
  195. package/tests/accuracy/test-data-dumps/comics.books.json +417 -0
  196. package/tests/accuracy/test-data-dumps/comics.characters.json +402 -0
  197. package/tests/accuracy/test-data-dumps/mflix.movies.json +496 -0
  198. package/tests/accuracy/test-data-dumps/mflix.shows.json +572 -0
  199. package/tests/accuracy/updateMany.test.ts +42 -0
  200. package/tests/integration/helpers.ts +9 -9
  201. package/tests/integration/indexCheck.test.ts +1 -0
  202. package/tests/integration/server.test.ts +1 -0
  203. package/tests/integration/telemetry.test.ts +4 -3
  204. package/tests/integration/tools/atlas/accessLists.test.ts +22 -2
  205. package/tests/integration/tools/atlas/alerts.test.ts +3 -2
  206. package/tests/integration/tools/atlas/atlasHelpers.ts +3 -0
  207. package/tests/integration/tools/atlas/clusters.test.ts +68 -16
  208. package/tests/integration/tools/atlas/dbUsers.test.ts +14 -1
  209. package/tests/integration/tools/atlas/orgs.test.ts +2 -1
  210. package/tests/integration/tools/atlas/projects.test.ts +4 -3
  211. package/tests/integration/tools/mongodb/{metadata → connect}/connect.test.ts +34 -3
  212. package/tests/integration/tools/mongodb/create/createCollection.test.ts +1 -0
  213. package/tests/integration/tools/mongodb/create/createIndex.test.ts +1 -0
  214. package/tests/integration/tools/mongodb/create/insertMany.test.ts +1 -0
  215. package/tests/integration/tools/mongodb/delete/deleteMany.test.ts +1 -0
  216. package/tests/integration/tools/mongodb/delete/dropCollection.test.ts +1 -1
  217. package/tests/integration/tools/mongodb/delete/dropDatabase.test.ts +1 -0
  218. package/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts +1 -0
  219. package/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts +1 -0
  220. package/tests/integration/tools/mongodb/metadata/dbStats.test.ts +1 -0
  221. package/tests/integration/tools/mongodb/metadata/explain.test.ts +1 -0
  222. package/tests/integration/tools/mongodb/metadata/listCollections.test.ts +1 -0
  223. package/tests/integration/tools/mongodb/metadata/listDatabases.test.ts +3 -2
  224. package/tests/integration/tools/mongodb/metadata/logs.test.ts +1 -0
  225. package/tests/integration/tools/mongodb/mongodbHelpers.ts +66 -2
  226. package/tests/integration/tools/mongodb/read/aggregate.test.ts +2 -1
  227. package/tests/integration/tools/mongodb/read/collectionIndexes.test.ts +1 -0
  228. package/tests/integration/tools/mongodb/read/count.test.ts +1 -0
  229. package/tests/integration/tools/mongodb/read/find.test.ts +2 -1
  230. package/tests/integration/tools/mongodb/update/renameCollection.test.ts +1 -0
  231. package/tests/integration/tools/mongodb/update/updateMany.test.ts +1 -0
  232. package/tests/integration/transports/stdio.test.ts +40 -0
  233. package/tests/integration/transports/streamableHttp.test.ts +56 -0
  234. package/tests/matchers/toIncludeSameMembers.test.ts +59 -0
  235. package/tests/matchers/toIncludeSameMembers.ts +12 -0
  236. package/tests/setup.ts +7 -0
  237. package/tests/unit/accessListUtils.test.ts +39 -0
  238. package/tests/unit/accuracyScorer.test.ts +390 -0
  239. package/tests/unit/{apiClient.test.ts → common/apiClient.test.ts} +15 -15
  240. package/tests/unit/common/managedTimeout.test.ts +67 -0
  241. package/tests/unit/{session.test.ts → common/session.test.ts} +7 -12
  242. package/tests/unit/{indexCheck.test.ts → helpers/indexCheck.test.ts} +2 -1
  243. package/tests/unit/telemetry.test.ts +52 -42
  244. package/tests/unit/{EJsonTransport.test.ts → transports/stdio.test.ts} +4 -4
  245. package/tests/vitest.d.ts +11 -0
  246. package/tsconfig.json +0 -1
  247. package/{tsconfig.jest.json → tsconfig.test.json} +1 -2
  248. package/vitest.config.ts +41 -0
  249. package/dist/common/atlas/generatePassword.js.map +0 -1
  250. package/dist/config.js.map +0 -1
  251. package/dist/errors.js.map +0 -1
  252. package/dist/helpers/EJsonTransport.js.map +0 -1
  253. package/dist/helpers/packageInfo.js.map +0 -1
  254. package/dist/logger.js.map +0 -1
  255. package/dist/session.js.map +0 -1
  256. package/dist/tools/atlas/metadata/connectCluster.js +0 -100
  257. package/dist/tools/atlas/metadata/connectCluster.js.map +0 -1
  258. package/dist/tools/mongodb/metadata/connect.js.map +0 -1
  259. package/global.d.ts +0 -1
  260. package/jest.config.cjs +0 -22
  261. package/src/tools/atlas/metadata/connectCluster.ts +0 -121
  262. /package/dist/{errors.js → common/errors.js} +0 -0
  263. /package/dist/{helpers → common}/packageInfo.js +0 -0
  264. /package/dist/{common/atlas → helpers}/generatePassword.js +0 -0
  265. /package/src/{errors.ts → common/errors.ts} +0 -0
  266. /package/src/{helpers → common}/packageInfo.ts +0 -0
  267. /package/src/{common/atlas → helpers}/generatePassword.ts +0 -0
@@ -0,0 +1,55 @@
1
+ name: Accuracy Tests
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request:
9
+ types:
10
+ - labeled
11
+
12
+ jobs:
13
+ run-accuracy-tests:
14
+ name: Run Accuracy Tests
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: read
18
+ pull-requests: write
19
+ if: |
20
+ github.event_name == 'workflow_dispatch' ||
21
+ (github.event_name == 'pull_request' && github.event.label.name == 'accuracy-tests')
22
+ env:
23
+ MDB_OPEN_AI_API_KEY: ${{ secrets.ACCURACY_OPEN_AI_API_KEY }}
24
+ MDB_GEMINI_API_KEY: ${{ secrets.ACCURACY_GEMINI_API_KEY }}
25
+ MDB_AZURE_OPEN_AI_API_KEY: ${{ secrets.ACCURACY_AZURE_OPEN_AI_API_KEY }}
26
+ MDB_AZURE_OPEN_AI_API_URL: ${{ vars.ACCURACY_AZURE_OPEN_AI_API_URL }}
27
+ MDB_ACCURACY_MDB_URL: ${{ secrets.ACCURACY_MDB_CONNECTION_STRING }}
28
+ MDB_ACCURACY_MDB_DB: ${{ vars.ACCURACY_MDB_DB }}
29
+ MDB_ACCURACY_MDB_COLLECTION: ${{ vars.ACCURACY_MDB_COLLECTION }}
30
+ MDB_ACCURACY_BASELINE_COMMIT: ${{ github.event.pull_request.base.sha || '' }}
31
+ steps:
32
+ - uses: GitHubSecurityLab/actions-permissions/monitor@v1
33
+ - uses: actions/checkout@v4
34
+ - uses: actions/setup-node@v4
35
+ with:
36
+ node-version-file: package.json
37
+ cache: "npm"
38
+ - name: Install dependencies
39
+ run: npm ci
40
+ - name: Run accuracy tests
41
+ run: npm run test:accuracy
42
+ - name: Upload accuracy test summary
43
+ if: always()
44
+ uses: actions/upload-artifact@v4
45
+ with:
46
+ name: accuracy-test-summary
47
+ path: .accuracy/test-summary.html
48
+ - name: Comment summary on PR
49
+ if: github.event_name == 'pull_request' && github.event.label.name == 'accuracy-tests'
50
+ uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943 # v2
51
+ with:
52
+ # Hides the previous comment and add a comment at the end
53
+ hide_and_recreate: true
54
+ hide_classify: "OUTDATED"
55
+ path: .accuracy/test-brief.md
@@ -55,4 +55,4 @@ jobs:
55
55
  rm -rf node_modules
56
56
  npm pkg set scripts.prepare="exit 0"
57
57
  npm install --omit=dev
58
- - run: npx -y @modelcontextprotocol/inspector --cli --method tools/list -- node dist/index.js --connectionString "mongodb://localhost"
58
+ - run: npx -y @modelcontextprotocol/inspector --cli --method tools/list -- node dist/index.js
@@ -54,7 +54,7 @@ jobs:
54
54
  MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }}
55
55
  MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }}
56
56
  MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }}
57
- run: npm test -- --testPathIgnorePatterns "tests/unit" --testPathIgnorePatterns "tests/integration/tools/mongodb" --testPathIgnorePatterns "tests/integration/[^/]+\.ts"
57
+ run: npm test -- --exclude "tests/unit/**" --exclude "tests/integration/tools/mongodb/**" --exclude "tests/integration/*.ts"
58
58
  - name: Upload test results
59
59
  uses: actions/upload-artifact@v4
60
60
  if: always()
@@ -34,17 +34,3 @@ jobs:
34
34
  with:
35
35
  name: test-results
36
36
  path: coverage/lcov.info
37
-
38
- merge-dependabot-pr:
39
- name: Merge Dependabot PR
40
- if: github.event.pull_request.user.login == 'dependabot[bot]'
41
- runs-on: ubuntu-latest
42
- permissions:
43
- pull-requests: write
44
- contents: write
45
- steps:
46
- - name: Enable auto-merge for Dependabot PRs
47
- run: gh pr merge --auto --squash "$PR_URL"
48
- env:
49
- PR_URL: ${{github.event.pull_request.html_url}}
50
- GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: Dependabot PR
3
+ on:
4
+ pull_request:
5
+ types: [opened]
6
+ branches:
7
+ - main
8
+
9
+ permissions: {}
10
+
11
+ jobs:
12
+ merge-dependabot-pr:
13
+ name: Merge Dependabot PR
14
+ if: github.event.pull_request.user.login == 'dependabot[bot]'
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
18
+ id: app-token
19
+ with:
20
+ app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
21
+ private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
22
+ - name: Enable auto-merge for Dependabot PRs
23
+ run: gh pr merge --auto --squash "$PR_URL"
24
+ env:
25
+ PR_URL: ${{github.event.pull_request.html_url}}
26
+ GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: Create JIRA ticket for new issues
3
+
4
+ on:
5
+ issues:
6
+ types: [opened, labeled]
7
+
8
+ permissions:
9
+ issues: write
10
+ contents: read
11
+
12
+ jobs:
13
+ jira_task:
14
+ name: Create Jira issue
15
+ runs-on: ubuntu-latest
16
+ if: github.event.action == 'opened' || github.event.label.name == 'create-jira'
17
+ steps:
18
+ - uses: GitHubSecurityLab/actions-permissions/monitor@v1
19
+ with:
20
+ config: ${{ vars.PERMISSIONS_CONFIG }}
21
+
22
+ - name: Create JIRA ticket
23
+ uses: mongodb/apix-action/create-jira@v8
24
+ id: create
25
+ continue-on-error: true
26
+ with:
27
+ token: ${{ secrets.JIRA_API_TOKEN }}
28
+ project-key: MCP
29
+ summary: "HELP: GitHub Issue n. ${{ github.event.issue.number }}"
30
+ issuetype: Bug
31
+ description: "This ticket tracks the following GitHub issue: ${{ github.event.issue.html_url }}."
32
+ extra-data: |
33
+ {
34
+ "fields": {
35
+ "customfield_12751": [
36
+ {
37
+ "id": "22223"
38
+ },
39
+ {
40
+ "id": "27326"
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ - name: Show result
46
+ run: |
47
+ echo "JIRA action result: ${{ steps.create.outputs.issue-key || 'FAILED' }}"
48
+
49
+ - name: Add comment
50
+ if: steps.create.outputs.issue-key
51
+ uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
52
+ with:
53
+ issue-number: ${{ github.event.issue.number }}
54
+ body: |
55
+ Thanks for opening this issue. The ticket [${{ steps.create.outputs.issue-key }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.issue-key }}) was created for internal tracking.
56
+
57
+ - name: Remove create-jira label
58
+ if: github.event.action == 'labeled' && github.event.label.name == 'create-jira'
59
+ uses: actions/github-script@v7
60
+ with:
61
+ script: |
62
+ try {
63
+ await github.rest.issues.removeLabel({
64
+ owner: context.repo.owner,
65
+ repo: context.repo.repo,
66
+ issue_number: context.issue.number,
67
+ name: 'create-jira'
68
+ });
69
+ console.log('✅ Removed create-jira label');
70
+ } catch (error) {
71
+ console.log('⚠️ Could not remove create-jira label:', error.message);
72
+ }
@@ -3,7 +3,7 @@
3
3
  // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4
4
 
5
5
  // List of extensions which should be recommended for users of this workspace.
6
- "recommendations": ["firsttris.vscode-jest-runner", "orta.vscode-jest"],
6
+ "recommendations": ["vitest.explorer"],
7
7
  // List of extensions recommended by VS Code that should not be recommended for users of this workspace.
8
8
  "unwantedRecommendations": []
9
9
  }
@@ -4,12 +4,22 @@
4
4
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
+ {
8
+ "type": "node",
9
+ "request": "launch",
10
+ "name": "Launch Tests",
11
+ "runtimeExecutable": "npm",
12
+ "runtimeArgs": ["test"],
13
+ "cwd": "${workspaceFolder}",
14
+ "envFile": "${workspaceFolder}/.env"
15
+ },
7
16
  {
8
17
  "type": "node",
9
18
  "request": "launch",
10
19
  "name": "Launch Program",
11
20
  "skipFiles": ["<node_internals>/**"],
12
- "program": "${workspaceFolder}/dist/index.js",
21
+ "runtimeExecutable": "npm",
22
+ "runtimeArgs": ["start"],
13
23
  "preLaunchTask": "tsc: build - tsconfig.build.json",
14
24
  "outFiles": ["${workspaceFolder}/dist/**/*.js"]
15
25
  }
@@ -1,11 +1 @@
1
- {
2
- "jestrunner.jestCommand": "npm test --",
3
- "jestrunner.debugOptions": {
4
- "runtimeExecutable": "node",
5
- "runtimeArgs": [
6
- "--experimental-vm-modules",
7
- "node_modules/jest/bin/jest.js",
8
- "--coverage"
9
- ]
10
- }
11
- }
1
+ {}
package/Dockerfile CHANGED
@@ -4,6 +4,7 @@ RUN addgroup -S mcp && adduser -S mcp -G mcp
4
4
  RUN npm install -g mongodb-mcp-server@${VERSION}
5
5
  USER mcp
6
6
  WORKDIR /home/mcp
7
+ ENV MDB_MCP_LOGGERS=stderr,mcp
7
8
  ENTRYPOINT ["mongodb-mcp-server"]
8
9
  LABEL maintainer="MongoDB Inc <info@mongodb.com>"
9
10
  LABEL description="MongoDB MCP Server"
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?logo=data:image/svg%2bxml;base64,PHN2ZyBmaWxsPSIjRkZGRkZGIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciICB2aWV3Qm94PSIwIDAgNDggNDgiIHdpZHRoPSIyNHB4IiBoZWlnaHQ9IjI0cHgiPjxwYXRoIGQ9Ik00NC45OTkgMTAuODd2MjYuMjFjMCAxLjAzLS41OSAxLjk3LTEuNTEgMi40Mi0yLjY4IDEuMjktOCAzLjg1LTguMzUgNC4wMS0uMTMuMDctLjM4LjItLjY3LjMxLjM1LS42LjUzLTEuMy41My0yLjAyVjYuMmMwLS43NS0uMi0xLjQ1LS41Ni0yLjA2LjA5LjA0LjE3LjA4LjI0LjExLjIuMSA1Ljk4IDIuODYgOC44IDQuMkM0NC40MDkgOC45IDQ0Ljk5OSA5Ljg0IDQ0Ljk5OSAxMC44N3pNNy40OTkgMjYuMDNjMS42IDEuNDYgMy40MyAzLjEzIDUuMzQgNC44NmwtNC42IDMuNWMtLjc3LjU3LTEuNzguNS0yLjU2LS4wNS0uNS0uMzYtMS44OS0xLjY1LTEuODktMS42NS0xLjAxLS44MS0xLjA2LTIuMzItLjExLTMuMTlDMy42NzkgMjkuNSA1LjE3OSAyOC4xMyA3LjQ5OSAyNi4wM3pNMzEuOTk5IDYuMnYxMC4xMWwtNy42MyA1LjgtNi44NS01LjIxYzQuOTgtNC41MyAxMC4wMS05LjExIDEyLjY1LTExLjUyQzMwLjg2OSA0Ljc0IDMxLjk5OSA1LjI1IDMxLjk5OSA2LjJ6TTMyIDQxLjc5OFYzMS42OUw4LjI0IDEzLjYxYy0uNzctLjU3LTEuNzgtLjUtMi41Ni4wNS0uNS4zNi0xLjg5IDEuNjUtMS44OSAxLjY1LTEuMDEuODEtMS4wNiAyLjMyLS4xMSAzLjE5IDAgMCAyMC4xNDUgMTguMzM4IDI2LjQ4NSAyNC4xMTZDMzAuODcxIDQzLjI2IDMyIDQyLjc1MyAzMiA0MS43OTh6Ii8+PC9zdmc+)](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D)
2
- [![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Server-1e1e1e?logo=data:image/svg%2bxml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgc3R5bGU9ImZsZXg6bm9uZTtsaW5lLWhlaWdodDoxIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIxZW0iCiAgICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHRpdGxlPkN1cnNvcjwvdGl0bGU+CiAgICA8cGF0aCBkPSJNMTEuOTI1IDI0bDEwLjQyNS02LTEwLjQyNS02TDEuNSAxOGwxMC40MjUgNnoiCiAgICAgICAgZmlsbD0idXJsKCNsb2JlLWljb25zLWN1cnNvcnVuZGVmaW5lZC1maWxsLTApIj48L3BhdGg+CiAgICA8cGF0aCBkPSJNMjIuMzUgMThWNkwxMS45MjUgMHYxMmwxMC40MjUgNnoiIGZpbGw9InVybCgjbG9iZS1pY29ucy1jdXJzb3J1bmRlZmluZWQtZmlsbC0xKSI+PC9wYXRoPgogIC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PHN0b3Agb2Zmc2V0PSIuNzE1IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9IjAiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgICAgIDxsaW5lYXJHcmFkaWVudCBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaWQ9ImxvYmUtaWNvbnMtY3Vyc29ydW5kZWZpbmVkLWZpbGwtMiIKICAgICAgICAgICAgeDE9IjExLjkyNSIgeDI9IjEuNSIgeTE9IjAiIHkyPSIxOCI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiNmZmYiIHN0b3Atb3BhY2l0eT0iLjYiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agb2Zmc2V0PSIuNjY3IiBzdG9wLWNvbG9yPSIjZmZmIiBzdG9wLW9wYWNpdHk9Ii4yMiI+PC9zdG9wPgogICAgICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgICA8L2RlZnM+Cjwvc3ZnPgo=)](https://cursor.com/install-mcp?name=MongoDB&config=eyJjb21tYW5kIjoibnB4IC15IG1vbmdvZGItbWNwLXNlcnZlciJ9)
1
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?logo=data:image/svg%2bxml;base64,PHN2ZyBmaWxsPSIjRkZGRkZGIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciICB2aWV3Qm94PSIwIDAgNDggNDgiIHdpZHRoPSIyNHB4IiBoZWlnaHQ9IjI0cHgiPjxwYXRoIGQ9Ik00NC45OTkgMTAuODd2MjYuMjFjMCAxLjAzLS41OSAxLjk3LTEuNTEgMi40Mi0yLjY4IDEuMjktOCAzLjg1LTguMzUgNC4wMS0uMTMuMDctLjM4LjItLjY3LjMxLjM1LS42LjUzLTEuMy41My0yLjAyVjYuMmMwLS43NS0uMi0xLjQ1LS41Ni0yLjA2LjA5LjA0LjE3LjA4LjI0LjExLjIuMSA1Ljk4IDIuODYgOC44IDQuMkM0NC40MDkgOC45IDQ0Ljk5OSA5Ljg0IDQ0Ljk5OSAxMC44N3pNNy40OTkgMjYuMDNjMS42IDEuNDYgMy40MyAzLjEzIDUuMzQgNC44NmwtNC42IDMuNWMtLjc3LjU3LTEuNzguNS0yLjU2LS4wNS0uNS0uMzYtMS44OS0xLjY1LTEuODktMS42NS0xLjAxLS44MS0xLjA2LTIuMzItLjExLTMuMTlDMy42NzkgMjkuNSA1LjE3OSAyOC4xMyA3LjQ5OSAyNi4wM3pNMzEuOTk5IDYuMnYxMC4xMWwtNy42MyA1LjgtNi44NS01LjIxYzQuOTgtNC41MyAxMC4wMS05LjExIDEyLjY1LTExLjUyQzMwLjg2OSA0Ljc0IDMxLjk5OSA1LjI1IDMxLjk5OSA2LjJ6TTMyIDQxLjc5OFYzMS42OUw4LjI0IDEzLjYxYy0uNzctLjU3LTEuNzgtLjUtMi41Ni4wNS0uNS4zNi0xLjg5IDEuNjUtMS44OSAxLjY1LTEuMDEuODEtMS4wNiAyLjMyLS4xMSAzLjE5IDAgMCAyMC4xNDUgMTguMzM4IDI2LjQ4NSAyNC4xMTZDMzAuODcxIDQzLjI2IDMyIDQyLjc1MyAzMiA0MS43OTh6Ii8+PC9zdmc+)](https://insiders.vscode.dev/redirect/mcp/install?name=mongodb&inputs=%5B%7B%22id%22%3A%22connection_string%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22MongoDB%20connection%20string%22%7D%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22mongodb-mcp-server%22%2C%22--readOnly%22%5D%2C%22env%22%3A%7B%22MDB_MCP_CONNECTION_STRING%22%3A%22%24%7Binput%3Aconnection_string%7D%22%7D%7D)
2
+ [![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Server-1e1e1e?logo=data:image/svg%2bxml;base64,PHN2ZyBoZWlnaHQ9IjFlbSIgc3R5bGU9ImZsZXg6bm9uZTtsaW5lLWhlaWdod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ciAtLXJlYWRPbmx5In0%3D)
3
3
  [![View on Smithery](https://smithery.ai/badge/@mongodb-js/mongodb-mcp-server)](https://smithery.ai/server/@mongodb-js/mongodb-mcp-server)
4
4
 
5
5
  # MongoDB MCP Server
@@ -24,9 +24,14 @@ A Model Context Protocol server for interacting with MongoDB Databases and Mongo
24
24
  - [MCP Client Configuration](#mcp-configuration-file-examples)
25
25
  - [🤝 Contributing](#contributing)
26
26
 
27
+ <a name="getting-started"></a>
28
+
27
29
  ## Prerequisites
28
30
 
29
- - Node.js (v20.10.0 or later)
31
+ - Node.js
32
+ - At least 20.19.0
33
+ - When using v22 then at least v22.12.0
34
+ - Otherwise any version 23+
30
35
 
31
36
  ```shell
32
37
  node -v
@@ -40,17 +45,19 @@ node -v
40
45
 
41
46
  ### Quick Start
42
47
 
43
- > **Note:** When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See [Atlas API Permissions](#atlas-api-permissions) for details.
48
+ **Note:** When using Atlas API credentials, be sure to assign only the minimum required permissions to your service account. See [Atlas API Permissions](#atlas-api-permissions) for details.
44
49
 
45
50
  Most MCP clients require a configuration file to be created or modified to add the MCP server.
46
51
 
47
52
  Note: The configuration file syntax can be different across clients. Please refer to the following links for the latest expected syntax:
48
53
 
49
- - **Windsurf**:https://docs.windsurf.com/windsurf/mcp
54
+ - **Windsurf**: https://docs.windsurf.com/windsurf/mcp
50
55
  - **VSCode**: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
51
56
  - **Claude Desktop**: https://modelcontextprotocol.io/quickstart/user
52
57
  - **Cursor**: https://docs.cursor.com/context/model-context-protocol
53
58
 
59
+ > **Default Safety Notice:** All examples below include `--readOnly` by default to ensure safe, read-only access to your data. Remove `--readOnly` if you need to enable write operations.
60
+
54
61
  #### Option 1: Connection String args
55
62
 
56
63
  You can pass your connection string via args, make sure to use a valid username and password.
@@ -64,7 +71,8 @@ You can pass your connection string via args, make sure to use a valid username
64
71
  "-y",
65
72
  "mongodb-mcp-server",
66
73
  "--connectionString",
67
- "mongodb://localhost:27017/myDatabase"
74
+ "mongodb://localhost:27017/myDatabase",
75
+ "--readOnly"
68
76
  ]
69
77
  }
70
78
  }
@@ -88,7 +96,8 @@ Use your Atlas API Service Accounts credentials. Must follow all the steps in [A
88
96
  "--apiClientId",
89
97
  "your-atlas-service-accounts-client-id",
90
98
  "--apiClientSecret",
91
- "your-atlas-service-accounts-client-secret"
99
+ "your-atlas-service-accounts-client-secret",
100
+ "--readOnly"
92
101
  ]
93
102
  }
94
103
  }
@@ -100,7 +109,7 @@ Use your Atlas API Service Accounts credentials. Must follow all the steps in [A
100
109
  Start Server using npx command:
101
110
 
102
111
  ```shell
103
- npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret"
112
+ npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id" --apiClientSecret="your-atlas-service-accounts-client-secret" --readOnly
104
113
  ```
105
114
 
106
115
  - For a complete list of arguments see [Configuration Options](#configuration-options)
@@ -109,7 +118,7 @@ Start Server using npx command:
109
118
  #### Option 4: Standalone Service using environment variables
110
119
 
111
120
  ```shell
112
- npx -y mongodb-mcp-server
121
+ npx -y mongodb-mcp-server --readOnly
113
122
  ```
114
123
 
115
124
  You can use environment variables in the config file or set them and run the server via npx.
@@ -137,6 +146,7 @@ docker run --rm -i \
137
146
  ```shell
138
147
  docker run --rm -i \
139
148
  -e MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" \
149
+ -e MDB_MCP_READ_ONLY="true" \
140
150
  mongodb/mongodb-mcp-server:latest
141
151
  ```
142
152
 
@@ -146,6 +156,7 @@ docker run --rm -i \
146
156
  docker run --rm -i \
147
157
  -e MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" \
148
158
  -e MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" \
159
+ -e MDB_MCP_READ_ONLY="true" \
149
160
  mongodb/mongodb-mcp-server:latest
150
161
  ```
151
162
 
@@ -158,7 +169,14 @@ Without options:
158
169
  "mcpServers": {
159
170
  "MongoDB": {
160
171
  "command": "docker",
161
- "args": ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"]
172
+ "args": [
173
+ "run",
174
+ "--rm",
175
+ "-e",
176
+ "MDB_MCP_READ_ONLY=true",
177
+ "-i",
178
+ "mongodb/mongodb-mcp-server:latest"
179
+ ]
162
180
  }
163
181
  }
164
182
  }
@@ -177,6 +195,8 @@ With connection string:
177
195
  "-i",
178
196
  "-e",
179
197
  "MDB_MCP_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/myDatabase",
198
+ "-e",
199
+ "MDB_MCP_READ_ONLY=true",
180
200
  "mongodb/mongodb-mcp-server:latest"
181
201
  ]
182
202
  }
@@ -196,6 +216,8 @@ With Atlas API credentials:
196
216
  "--rm",
197
217
  "-i",
198
218
  "-e",
219
+ "MDB_MCP_READ_ONLY=true",
220
+ "-e",
199
221
  "MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id",
200
222
  "-e",
201
223
  "MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret",
@@ -206,6 +228,39 @@ With Atlas API credentials:
206
228
  }
207
229
  ```
208
230
 
231
+ #### Option 6: Running as an HTTP Server
232
+
233
+ > **⚠️ Security Notice:** This server now supports Streamable HTTP transport for remote connections. **HTTP transport is NOT recommended for production use without implementing proper authentication and security measures.**
234
+
235
+ **Suggested Security Measures Examples:**
236
+
237
+ - Implement authentication (e.g., API gateway, reverse proxy)
238
+ - Use HTTPS/TLS encryption
239
+ - Deploy behind a firewall or in private networks
240
+ - Implement rate limiting
241
+ - Never expose directly to the internet
242
+
243
+ For more details, see [MCP Security Best Practices](https://modelcontextprotocol.io/docs/concepts/transports#security-considerations).
244
+
245
+ You can run the MongoDB MCP Server as an HTTP server instead of the default stdio transport. This is useful if you want to interact with the server over HTTP, for example from a web client or to expose the server on a specific port.
246
+
247
+ To start the server with HTTP transport, use the `--transport http` option:
248
+
249
+ ```shell
250
+ npx -y mongodb-mcp-server --transport http
251
+ ```
252
+
253
+ By default, the server will listen on `http://127.0.0.1:3000`. You can customize the host and port using the `--httpHost` and `--httpPort` options:
254
+
255
+ ```shell
256
+ npx -y mongodb-mcp-server --transport http --httpHost=0.0.0.0 --httpPort=8080
257
+ ```
258
+
259
+ - `--httpHost` (default: 127.0.0.1): The host to bind the HTTP server.
260
+ - `--httpPort` (default: 3000): The port number for the HTTP server.
261
+
262
+ > **Note:** The default transport is `stdio`, which is suitable for integration with most MCP clients. Use `http` transport if you need to interact with the server over HTTP.
263
+
209
264
  ## 🛠️ Supported Tools
210
265
 
211
266
  ### Tool List
@@ -259,23 +314,55 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow
259
314
 
260
315
  ### Configuration Options
261
316
 
262
- | Option | Description |
263
- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
264
- | `apiClientId` | Atlas API client ID for authentication. Required for running Atlas tools. |
265
- | `apiClientSecret` | Atlas API client secret for authentication. Required for running Atlas tools. |
266
- | `connectionString` | MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the `connect` tool before interacting with MongoDB data. |
267
- | `logPath` | Folder to store logs. |
268
- | `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled. |
269
- | `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations. |
270
- | `indexCheck` | When set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan. |
271
- | `telemetry` | When set to disabled, disables telemetry collection. |
317
+ | CLI Option | Environment Variable | Default | Description |
318
+ | ----------------------- | --------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
319
+ | `apiClientId` | `MDB_MCP_API_CLIENT_ID` | <not set> | Atlas API client ID for authentication. Required for running Atlas tools. |
320
+ | `apiClientSecret` | `MDB_MCP_API_CLIENT_SECRET` | <not set> | Atlas API client secret for authentication. Required for running Atlas tools. |
321
+ | `connectionString` | `MDB_MCP_CONNECTION_STRING` | <not set> | MongoDB connection string for direct database connections. Optional, if not set, you'll need to call the `connect` tool before interacting with MongoDB data. |
322
+ | `loggers` | `MDB_MCP_LOGGERS` | disk,mcp | Comma separated values, possible values are `mcp`, `disk` and `stderr`. See [Logger Options](#logger-options) for details. |
323
+ | `logPath` | `MDB_MCP_LOG_PATH` | see note\* | Folder to store logs. |
324
+ | `disabledTools` | `MDB_MCP_DISABLED_TOOLS` | <not set> | An array of tool names, operation types, and/or categories of tools that will be disabled. |
325
+ | `readOnly` | `MDB_MCP_READ_ONLY` | false | When set to true, only allows read, connect, and metadata operation types, disabling create/update/delete operations. |
326
+ | `indexCheck` | `MDB_MCP_INDEX_CHECK` | false | When set to true, enforces that query operations must use an index, rejecting queries that perform a collection scan. |
327
+ | `telemetry` | `MDB_MCP_TELEMETRY` | enabled | When set to disabled, disables telemetry collection. |
328
+ | `transport` | `MDB_MCP_TRANSPORT` | stdio | Either 'stdio' or 'http'. |
329
+ | `httpPort` | `MDB_MCP_HTTP_PORT` | 3000 | Port number. |
330
+ | `httpHost` | `MDB_MCP_HTTP_HOST` | 127.0.0.1 | Host to bind the http server. |
331
+ | `idleTimeoutMs` | `MDB_MCP_IDLE_TIMEOUT_MS` | 600000 | Idle timeout for a client to disconnect (only applies to http transport). |
332
+ | `notificationTimeoutMs` | `MDB_MCP_NOTIFICATION_TIMEOUT_MS` | 540000 | Notification timeout for a client to be aware of diconnect (only applies to http transport). |
333
+
334
+ #### Logger Options
335
+
336
+ The `loggers` configuration option controls where logs are sent. You can specify one or more logger types as a comma-separated list. The available options are:
337
+
338
+ - `mcp`: Sends logs to the MCP client (if supported by the client/transport).
339
+ - `disk`: Writes logs to disk files. Log files are stored in the log path (see `logPath` above).
340
+ - `stderr`: Outputs logs to standard error (stderr), useful for debugging or when running in containers.
341
+
342
+ **Default:** `disk,mcp` (logs are written to disk and sent to the MCP client).
343
+
344
+ You can combine multiple loggers, e.g. `--loggers disk stderr` or `export MDB_MCP_LOGGERS="mcp,stderr"`.
345
+
346
+ ##### Example: Set logger via environment variable
272
347
 
273
- #### Log Path
348
+ ```shell
349
+ export MDB_MCP_LOGGERS="disk,stderr"
350
+ ```
351
+
352
+ ##### Example: Set logger via command-line argument
353
+
354
+ ```shell
355
+ npx -y mongodb-mcp-server --loggers mcp stderr
356
+ ```
274
357
 
275
- Default log location is as follows:
358
+ ##### Log File Location
276
359
 
277
- - Windows: `%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs`
278
- - macOS/Linux: `~/.mongodb/mongodb-mcp/.app-logs`
360
+ When using the `disk` logger, log files are stored in:
361
+
362
+ - **Windows:** `%LOCALAPPDATA%\mongodb\mongodb-mcp\.app-logs`
363
+ - **macOS/Linux:** `~/.mongodb/mongodb-mcp/.app-logs`
364
+
365
+ You can override the log directory with the `logPath` option.
279
366
 
280
367
  #### Disabled Tools
281
368
 
@@ -299,10 +386,11 @@ Operation types:
299
386
  - `delete` - Tools that delete resources, such as delete document, drop collection, etc.
300
387
  - `read` - Tools that read resources, such as find, aggregate, list clusters, etc.
301
388
  - `metadata` - Tools that read metadata, such as list databases, list collections, collection schema, etc.
389
+ - `connect` - Tools that allow you to connect or switch the connection to a MongoDB instance. If this is disabled, you will need to provide a connection string through the config when starting the server.
302
390
 
303
391
  #### Read-Only Mode
304
392
 
305
- The `readOnly` configuration option allows you to restrict the MCP server to only use tools with "read" and "metadata" operation types. When enabled, all tools that have "create", "update" or "delete" operation types will not be registered with the server.
393
+ The `readOnly` configuration option allows you to restrict the MCP server to only use tools with "read", "connect", and "metadata" operation types. When enabled, all tools that have "create", "update" or "delete" operation types will not be registered with the server.
306
394
 
307
395
  This is useful for scenarios where you want to provide access to MongoDB data for analysis without allowing any modifications to the data or infrastructure.
308
396
 
@@ -343,7 +431,6 @@ To use the Atlas API tools, you'll need to create a service account in MongoDB A
343
431
  > **ℹ️ Note:** For a detailed breakdown of the minimum required permissions for each Atlas operation, see the [Atlas API Permissions](#atlas-api-permissions) section below.
344
432
 
345
433
  1. **Create a Service Account:**
346
-
347
434
  - Log in to MongoDB Atlas at [cloud.mongodb.com](https://cloud.mongodb.com)
348
435
  - Navigate to Access Manager > Organization Access
349
436
  - Click Add New > Applications > Service Accounts
@@ -355,12 +442,10 @@ To use the Atlas API tools, you'll need to create a service account in MongoDB A
355
442
  To learn more about Service Accounts, check the [MongoDB Atlas documentation](https://www.mongodb.com/docs/atlas/api/service-accounts-overview/).
356
443
 
357
444
  2. **Save Client Credentials:**
358
-
359
445
  - After creation, you'll be shown the Client ID and Client Secret
360
446
  - **Important:** Copy and save the Client Secret immediately as it won't be displayed again
361
447
 
362
448
  3. **Add Access List Entry:**
363
-
364
449
  - Add your IP address to the API access list
365
450
 
366
451
  4. **Configure the MCP Server:**
@@ -460,7 +545,8 @@ npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id"
460
545
  "-y",
461
546
  "mongodb-mcp-server",
462
547
  "--connectionString",
463
- "mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
548
+ "mongodb+srv://username:password@cluster.mongodb.net/myDatabase",
549
+ "--readOnly"
464
550
  ]
465
551
  }
466
552
  }
@@ -480,13 +566,14 @@ npx -y mongodb-mcp-server --apiClientId="your-atlas-service-accounts-client-id"
480
566
  "--apiClientId",
481
567
  "your-atlas-service-accounts-client-id",
482
568
  "--apiClientSecret",
483
- "your-atlas-service-accounts-client-secret"
569
+ "your-atlas-service-accounts-client-secret",
570
+ "--readOnly"
484
571
  ]
485
572
  }
486
573
  }
487
574
  }
488
575
  ```
489
576
 
490
- ## 🤝 Contributing
577
+ ## 🤝Contributing
491
578
 
492
579
  Interested in contributing? Great! Please check our [Contributing Guide](CONTRIBUTING.md) for guidelines on code contributions, standards, adding new tools, and troubleshooting information.
@@ -0,0 +1,36 @@
1
+ import logger, { LogId } from "../logger.js";
2
+ import { ApiClientError } from "./apiClientError.js";
3
+ export const DEFAULT_ACCESS_LIST_COMMENT = "Added by MongoDB MCP Server to enable tool access";
4
+ export async function makeCurrentIpAccessListEntry(apiClient, projectId, comment = DEFAULT_ACCESS_LIST_COMMENT) {
5
+ const { currentIpv4Address } = await apiClient.getIpInfo();
6
+ return {
7
+ groupId: projectId,
8
+ ipAddress: currentIpv4Address,
9
+ comment,
10
+ };
11
+ }
12
+ /**
13
+ * Ensures the current public IP is in the access list for the given Atlas project.
14
+ * If the IP is already present, this is a no-op.
15
+ * @param apiClient The Atlas API client instance
16
+ * @param projectId The Atlas project ID
17
+ */
18
+ export async function ensureCurrentIpInAccessList(apiClient, projectId) {
19
+ const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
20
+ try {
21
+ await apiClient.createProjectIpAccessList({
22
+ params: { path: { groupId: projectId } },
23
+ body: [entry],
24
+ });
25
+ logger.debug(LogId.atlasIpAccessListAdded, "accessListUtils", `IP access list created: ${JSON.stringify(entry)}`);
26
+ }
27
+ catch (err) {
28
+ if (err instanceof ApiClientError && err.response?.status === 409) {
29
+ // 409 Conflict: entry already exists, log info
30
+ logger.debug(LogId.atlasIpAccessListAdded, "accessListUtils", `IP address ${entry.ipAddress} is already present in the access list for project ${projectId}.`);
31
+ return;
32
+ }
33
+ logger.warning(LogId.atlasIpAccessListAddFailure, "accessListUtils", `Error adding IP access list: ${err instanceof Error ? err.message : String(err)}`);
34
+ }
35
+ }
36
+ //# sourceMappingURL=accessListUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessListUtils.js","sourceRoot":"","sources":["../../../src/common/atlas/accessListUtils.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,CAAC,MAAM,2BAA2B,GAAG,mDAAmD,CAAC;AAE/F,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAC9C,SAAoB,EACpB,SAAiB,EACjB,UAAkB,2BAA2B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