Skip to content

Commit e4c1ee1

Browse files
authored
feat: docker support (#238)
1 parent c437106 commit e4c1ee1

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

.github/workflows/docker.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
build-args: |
41+
VERSION=${{ steps.set-properties.outputs.VERSION }}
42+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
43+
id: app-token
44+
if: ${{ failure() }}
45+
with:
46+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
47+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
48+
- name: Create Issue
49+
if: ${{ failure() }}
50+
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
51+
with:
52+
token: ${{ steps.app-token.outputs.token }}
53+
title: Release Failure for Docker Image ${{ steps.set-properties.outputs.VERSION }}-${{ steps.set-properties.outputs.DATE }}
54+
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
55+
labels: "docker, release_failure"

Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:22-alpine
2+
ARG VERSION=latest
3+
RUN npm install -g mongodb-mcp-server@${VERSION}
4+
ENTRYPOINT ["mongodb-mcp-server"]
5+
LABEL maintainer="MongoDB Inc <[email protected]>"
6+
LABEL description="MongoDB MCP Server"
7+
LABEL version=${VERSION}

README.md

+90-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Use your Atlas API Service Accounts credentials. Must follow all the steps in [A
8989
}
9090
```
9191

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

9494
Start Server using npx command:
9595

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

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:[email protected]/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:[email protected]/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+
114203
## 🛠️ Supported Tools
115204

116205
### Tool List

0 commit comments

Comments
 (0)