Skip to content

Commit 228e0fe

Browse files
authored
Merge branch 'main' into telemetry-2
2 parents 51671c0 + 7b9559c commit 228e0fe

27 files changed

+956
-349
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* @mongodb-js/mcp-server-developers
2+
**/atlas @blva @fmenezes
3+
**/mongodb @nirinchev @gagik

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/code_health.yaml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,13 @@ on:
55
branches:
66
- main
77
pull_request:
8-
jobs:
9-
check-style:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-node@v4
15-
with:
16-
node-version-file: package.json
17-
cache: "npm"
18-
- name: Install dependencies
19-
run: npm ci
20-
- name: Run style check
21-
run: npm run check
228

23-
check-generate:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-node@v4
29-
with:
30-
node-version-file: package.json
31-
cache: "npm"
32-
- name: Install dependencies
33-
run: npm ci
34-
- run: npm run generate
9+
permissions: {}
3510

11+
jobs:
3612
run-tests:
13+
name: Run MongoDB tests
14+
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
3715
strategy:
3816
matrix:
3917
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -59,6 +37,8 @@ jobs:
5937
path: coverage/lcov.info
6038

6139
run-atlas-tests:
40+
name: Run Atlas tests
41+
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
6242
runs-on: ubuntu-latest
6343
steps:
6444
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
@@ -81,10 +61,12 @@ jobs:
8161
with:
8262
name: atlas-test-results
8363
path: coverage/lcov.info
64+
8465
coverage:
66+
name: Run MongoDB tests
67+
if: always() && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
8568
runs-on: ubuntu-latest
8669
needs: [run-tests, run-atlas-tests]
87-
if: always()
8870
steps:
8971
- uses: actions/checkout@v4
9072
- uses: actions/setup-node@v4
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
name: Code Health (fork)
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
8+
permissions: {}
9+
10+
jobs:
11+
run-tests:
12+
name: Run MongoDB tests
13+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version-file: package.json
21+
cache: "npm"
22+
- name: Install dependencies
23+
run: npm ci
24+
- name: Run tests
25+
run: npm test
26+
- name: Upload test results
27+
if: always()
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: test-results
31+
path: coverage/lcov.info
32+
33+
run-atlas-tests:
34+
name: Run Atlas tests
35+
if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version-file: package.json
43+
cache: "npm"
44+
- name: Install dependencies
45+
run: npm ci
46+
- name: Run tests
47+
env:
48+
MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }}
49+
MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }}
50+
MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }}
51+
run: npm test -- --testPathIgnorePatterns "tests/integration/tools/mongodb" --testPathIgnorePatterns "tests/integration/[^/]+\.ts"
52+
- name: Upload test results
53+
uses: actions/upload-artifact@v4
54+
if: always()
55+
with:
56+
name: atlas-test-results
57+
path: coverage/lcov.info
58+
59+
coverage:
60+
name: Report Coverage
61+
if: always() && github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.head.repo.full_name != github.repository
62+
runs-on: ubuntu-latest
63+
needs: [run-tests, run-atlas-tests]
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-node@v4
67+
with:
68+
node-version-file: package.json
69+
cache: "npm"
70+
- name: Install dependencies
71+
run: npm ci
72+
- name: Download test results
73+
uses: actions/download-artifact@v4
74+
with:
75+
name: test-results
76+
path: coverage/mongodb
77+
- name: Download atlas test results
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: atlas-test-results
81+
path: coverage/atlas
82+
- name: Merge coverage reports
83+
run: |
84+
npx -y [email protected] "coverage/*/lcov.info" "coverage/lcov.info"
85+
- name: Coveralls GitHub Action
86+
uses: coverallsapp/[email protected]
87+
with:
88+
file: coverage/lcov.info
89+
git-branch: ${{ github.head_ref || github.ref_name }}
90+
git-commit: ${{ github.event.pull_request.head.sha || github.sha }}
91+
92+
merge-dependabot-pr:
93+
name: Merge Dependabot PR
94+
if: github.event.pull_request.user.login == 'dependabot[bot]'
95+
runs-on: ubuntu-latest
96+
permissions:
97+
pull-requests: write
98+
contents: write
99+
needs:
100+
- coverage
101+
steps:
102+
- name: Enable auto-merge for Dependabot PRs
103+
run: gh pr merge --auto --squash "$PR_URL"
104+
env:
105+
PR_URL: ${{github.event.pull_request.html_url}}
106+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/codeql.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "CodeQL Advanced"
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
schedule:
9+
- cron: "35 4 * * 4"
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (${{ matrix.language }})
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
language:
22+
- actions
23+
- javascript-typescript
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v3
29+
with:
30+
languages: ${{ matrix.language }}
31+
- name: Perform CodeQL Analysis
32+
uses: github/codeql-action/analyze@v3
33+
with:
34+
category: "/language:${{matrix.language}}"

.github/workflows/lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Lint
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions: {}
10+
11+
jobs:
12+
check-style:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version-file: package.json
20+
cache: "npm"
21+
- name: Install dependencies
22+
run: npm ci
23+
- name: Run style check
24+
run: npm run check
25+
26+
check-generate:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version-file: package.json
34+
cache: "npm"
35+
- name: Install dependencies
36+
run: npm ci
37+
- run: npm run generate

.github/workflows/prepare_release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ on:
1010
required: true
1111
default: "patch"
1212

13+
permissions: {}
14+
1315
jobs:
1416
create-pr:
1517
runs-on: ubuntu-latest

.github/workflows/publish.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
push:
55
branches:
66
- main
7-
permissions:
8-
contents: write
7+
98
jobs:
109
check:
1110
runs-on: ubuntu-latest
11+
permissions: {}
1212
outputs:
1313
VERSION_EXISTS: ${{ steps.check-version.outputs.VERSION_EXISTS }}
1414
VERSION: ${{ steps.get-version.outputs.VERSION }}
@@ -45,7 +45,10 @@ jobs:
4545
publish:
4646
runs-on: ubuntu-latest
4747
environment: Production
48-
needs: check
48+
permissions:
49+
contents: write
50+
needs:
51+
- check
4952
if: needs.check.outputs.VERSION_EXISTS == 'false'
5053
steps:
5154
- uses: GitHubSecurityLab/actions-permissions/monitor@v1

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828
},
2929
{
30-
"files": "*.yaml",
30+
"files": ["*.yaml", "*.yml"],
3131
"options": {
3232
"tabWidth": 2,
3333
"printWidth": 80

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow
150150
| `connectionString` | MongoDB connection string for direct database connections (optional users may choose to inform it on every tool call) |
151151
| `logPath` | Folder to store logs |
152152
| `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled. |
153+
| `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations |
153154

154155
#### `logPath`
155156

@@ -181,6 +182,19 @@ Operation types:
181182
- `read` - Tools that read resources, such as find, aggregate, list clusters, etc.
182183
- `metadata` - Tools that read metadata, such as list databases, list collections, collection schema, etc.
183184

185+
#### Read-Only Mode
186+
187+
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.
188+
189+
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.
190+
191+
You can enable read-only mode using:
192+
193+
- **Environment variable**: `export MDB_MCP_READ_ONLY=true`
194+
- **Command-line argument**: `--readOnly`
195+
196+
When read-only mode is active, you'll see a message in the server logs indicating which tools were prevented from registering due to this restriction.
197+
184198
### Atlas API Access
185199

186200
To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas:
@@ -221,6 +235,7 @@ export MDB_MCP_API_CLIENT_SECRET="your-atlas-client-secret"
221235
export MDB_MCP_CONNECTION_STRING="mongodb+srv://username:[email protected]/myDatabase"
222236

223237
export MDB_MCP_LOG_PATH="/path/to/logs"
238+
224239
```
225240

226241
#### Command-Line Arguments

0 commit comments

Comments
 (0)