Skip to content

Commit 165440d

Browse files
committed
Merge branch 'main' into ni/smithery
* main: (21 commits) fix: updates count tool (#254) fix: docker security warnings (#259) feat: docker support (#238) docs: list alerts docs (#250) chore: add hints and update mcp (#249) chore: base model SEO change (#248) chore(ci): add a PR title check workflow (#247) docs: bump node.js version (#246) chore: corrects the description of atlas-create-db-user (#240) chore: auto-close stale issues (#237) chore(deps-dev): bump globals from 16.0.0 to 16.1.0 (#231) chore(deps-dev): bump @types/node from 22.15.9 to 22.15.17 (#233) chore(deps-dev): bump eslint-config-prettier from 10.1.2 to 10.1.5 (#234) feat: Alerts Listing (#230) chore(deps-dev): bump @redocly/cli from 1.34.2 to 1.34.3 (#235) chore(deps-dev): bump openapi-typescript from 7.6.1 to 7.8.0 (#232) chore: release v0.1.1 (#223) fix: improve uncaught exception for getAccessToken (#224) chore: update issue template (#227) chore: switch to `@mongodb-js/device-id` (#196) ...
2 parents 08a72b1 + 5f779a3 commit 165440d

29 files changed

+2053
-295
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ body:
77
- type: markdown
88
attributes:
99
value: "Please fill out the following details to help us address the issue."
10+
- type: textarea
11+
id: version
12+
attributes:
13+
label: "Version"
14+
description: "Please provide the version of the MCP Server where the bug occurred. (e.g., 0.1.0, main branch sha, etc.)"
15+
placeholder: "e.g., 0.1.0"
16+
validations:
17+
required: true
1018
- type: checkboxes
1119
id: app
1220
attributes:

.github/workflows/check-pr-title.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Check PR Title"
2+
on:
3+
pull_request:
4+
types:
5+
[
6+
opened,
7+
synchronize,
8+
reopened,
9+
ready_for_review,
10+
labeled,
11+
unlabeled,
12+
converted_to_draft,
13+
edited,
14+
]
15+
16+
permissions:
17+
pull-requests: read # to read PR title and labels
18+
19+
jobs:
20+
check-pr-title:
21+
name: Check PR Title
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Enforce conventional commit style
25+
uses: realm/ci-actions/title-checker@d6cc8f067474759d38e6d24e272027b4c88bc0a9
26+
with:
27+
regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|ops){1}(\([\w\-\.]+\))?(!)?: .*'
28+
error-hint: 'Invalid PR title. Make sure it follows the conventional commit specification (i.e. "<type>(<optional scope>): <description>") or add the no-title-validation label'
29+
ignore-labels: "no-title-validation"

.github/workflows/docker.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Daily Release Docker Image
2+
on:
3+
schedule:
4+
- cron: "0 1 * * *" # Every day at 1:00 AM
5+
workflow_dispatch: # Run the action manually
6+
permissions:
7+
contents: read
8+
issues: write
9+
jobs:
10+
push:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
14+
with:
15+
config: ${{ vars.PERMISSIONS_CONFIG }}
16+
- name: Check out code
17+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2
20+
- name: Login to Docker Hub
21+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
22+
with:
23+
username: "${{ secrets.DOCKERHUB_USERNAME }}"
24+
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
25+
- name: Set date and version
26+
id: set-properties
27+
run: |
28+
DATE=$(date +'%Y-%m-%d')
29+
VERSION=$(npm pkg get version | tr -d '"')
30+
echo "DATE=${DATE}" >> "$GITHUB_OUTPUT"
31+
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
32+
- name: Build and push image to dockerhub registry
33+
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1
34+
with:
35+
context: .
36+
platforms: linux/amd64,linux/arm64
37+
tags: ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:latest, ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:${{ steps.set-properties.outputs.VERSION }}, ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:${{ steps.set-properties.outputs.VERSION }}-${{ steps.set-properties.outputs.DATE }}
38+
file: Dockerfile
39+
push: true
40+
provenance: mode=max
41+
sbom: true
42+
build-args: |
43+
VERSION=${{ steps.set-properties.outputs.VERSION }}
44+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
45+
id: app-token
46+
if: ${{ failure() }}
47+
with:
48+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
49+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
50+
- name: Create Issue
51+
if: ${{ failure() }}
52+
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
53+
with:
54+
token: ${{ steps.app-token.outputs.token }}
55+
title: Release Failure for Docker Image ${{ steps.set-properties.outputs.VERSION }}-${{ steps.set-properties.outputs.DATE }}
56+
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
57+
labels: "docker, release_failure"

.github/workflows/stale.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: "Stale issues and PRs handler"
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
permissions: read-all
9+
10+
jobs:
11+
stale:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
issues: write
15+
pull-requests: write
16+
steps:
17+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
18+
- uses: actions/stale@v9
19+
id: stale
20+
with:
21+
repo-token: ${{ secrets.GITHUB_TOKEN }}
22+
stale-issue-message: |
23+
This issue has gone 30 days without any activity and meets the project's definition of "stale". This will be auto-closed if there is no new activity over the next 30 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!
24+
stale-pr-message: |
25+
This PR has gone 30 days without any activity and meets the project's definition of "stale". This will be auto-closed if there is no new activity over the next 30 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!
26+
stale-issue-label: "no-issue-activity"
27+
stale-pr-label: "no-pr-activity"
28+
days-before-stale: 30
29+
days-before-close: 30
30+
exempt-all-milestones: true
31+
exempt-issue-labels: "not_stale"
32+
exempt-pr-labels: "not_stale"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This project implements a Model Context Protocol (MCP) server for MongoDB and Mo
5555
npm run inspect
5656
```
5757

58-
4. Commit your changes with a descriptive commit message
58+
4. Commit your changes using [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format.
5959

6060
## Adding tests to the MCP Server
6161

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:22-alpine
2+
ARG VERSION=latest
3+
RUN addgroup -S mcp && adduser -S mcp -G mcp
4+
RUN npm install -g mongodb-mcp-server@${VERSION}
5+
USER mcp
6+
WORKDIR /home/mcp
7+
ENTRYPOINT ["mongodb-mcp-server"]
8+
LABEL maintainer="MongoDB Inc <info@mongodb.com>"
9+
LABEL description="MongoDB MCP Server"
10+
LABEL version=${VERSION}

README.md

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A Model Context Protocol server for interacting with MongoDB Databases and Mongo
2222

2323
## Prerequisites
2424

25-
- Node.js (v20 or later)
25+
- Node.js (v20.10.0 or later)
2626

2727
```shell
2828
node -v
@@ -58,13 +58,15 @@ You can pass your connection string via args, make sure to use a valid username
5858
"-y",
5959
"mongodb-mcp-server",
6060
"--connectionString",
61-
"mongodb+srv://username:password@cluster.mongodb.net/myDatabase"
61+
"mongodb://localhost:27017/myDatabase"
6262
]
6363
}
6464
}
6565
}
6666
```
6767

68+
NOTE: The connection string can be configured to connect to any MongoDB cluster, whether it's a local instance or an Atlas cluster.
69+
6870
#### Option 2: Atlas API credentials args
6971

7072
Use your Atlas API Service Accounts credentials. Must follow all the steps in [Atlas API Access](#atlas-api-access) section.
@@ -87,7 +89,7 @@ Use your Atlas API Service Accounts credentials. Must follow all the steps in [A
8789
}
8890
```
8991

90-
### Option 3: Standalone Service using command arguments
92+
#### Option 3: Standalone Service using command arguments
9193

9294
Start Server using npx command:
9395

@@ -109,6 +111,95 @@ You can use environment variables in the config file or set them and run the ser
109111
- Connection String via environment variables in the MCP file [example](#connection-string-with-environment-variables)
110112
- Atlas API credentials via environment variables in the MCP file [example](#atlas-api-credentials-with-environment-variables)
111113

114+
#### Option 5: Using Docker
115+
116+
You can run the MongoDB MCP Server in a Docker container, which provides isolation and doesn't require a local Node.js installation.
117+
118+
#### Run with Environment Variables
119+
120+
You may provide either a MongoDB connection string OR Atlas API credentials:
121+
122+
##### Option A: No configuration
123+
124+
```shell
125+
docker run --rm -i \
126+
mongodb/mongodb-mcp-server:latest
127+
```
128+
129+
##### Option B: With MongoDB connection string
130+
131+
```shell
132+
docker run --rm -i \
133+
-e MDB_MCP_CONNECTION_STRING="mongodb+srv://username:password@cluster.mongodb.net/myDatabase" \
134+
mongodb/mongodb-mcp-server:latest
135+
```
136+
137+
##### Option C: With Atlas API credentials
138+
139+
```shell
140+
docker run --rm -i \
141+
-e MDB_MCP_API_CLIENT_ID="your-atlas-service-accounts-client-id" \
142+
-e MDB_MCP_API_CLIENT_SECRET="your-atlas-service-accounts-client-secret" \
143+
mongodb/mongodb-mcp-server:latest
144+
```
145+
146+
##### Docker in MCP Configuration File
147+
148+
Without options:
149+
150+
```json
151+
{
152+
"mcpServers": {
153+
"MongoDB": {
154+
"command": "docker",
155+
"args": ["run", "--rm", "-i", "mongodb/mongodb-mcp-server:latest"]
156+
}
157+
}
158+
}
159+
```
160+
161+
With connection string:
162+
163+
```json
164+
{
165+
"mcpServers": {
166+
"MongoDB": {
167+
"command": "docker",
168+
"args": [
169+
"run",
170+
"--rm",
171+
"-i",
172+
"-e",
173+
"MDB_MCP_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/myDatabase",
174+
"mongodb/mongodb-mcp-server:latest"
175+
]
176+
}
177+
}
178+
}
179+
```
180+
181+
With Atlas API credentials:
182+
183+
```json
184+
{
185+
"mcpServers": {
186+
"MongoDB": {
187+
"command": "docker",
188+
"args": [
189+
"run",
190+
"--rm",
191+
"-i",
192+
"-e",
193+
"MDB_MCP_API_CLIENT_ID=your-atlas-service-accounts-client-id",
194+
"-e",
195+
"MDB_MCP_API_CLIENT_SECRET=your-atlas-service-accounts-client-secret",
196+
"mongodb/mongodb-mcp-server:latest"
197+
]
198+
}
199+
}
200+
}
201+
```
202+
112203
## 🛠️ Supported Tools
113204

114205
### Tool List
@@ -125,7 +216,8 @@ You can use environment variables in the config file or set them and run the ser
125216
- `atlas-inspect-access-list` - Inspect IP/CIDR ranges with access to MongoDB Atlas clusters
126217
- `atlas-create-access-list` - Configure IP/CIDR access list for MongoDB Atlas clusters
127218
- `atlas-list-db-users` - List MongoDB Atlas database users
128-
- `atlas-create-db-user` - List MongoDB Atlas database users
219+
- `atlas-create-db-user` - Creates a MongoDB Atlas database user
220+
- `atlas-list-alerts` - List MongoDB Atlas Alerts for a Project
129221

130222
NOTE: atlas tools are only available when you set credentials on [configuration](#configuration) section.
131223

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default defineConfig([
4848
"coverage",
4949
"global.d.ts",
5050
"eslint.config.js",
51-
"jest.config.ts",
51+
"jest.config.cjs",
5252
"src/types/*.d.ts",
5353
]),
5454
eslintPluginPrettierRecommended,

jest.config.ts renamed to jest.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2-
export default {
2+
module.exports = {
33
preset: "ts-jest/presets/default-esm",
44
testEnvironment: "node",
55
extensionsToTreatAsEsm: [".ts"],

0 commit comments

Comments
 (0)