Skip to content

Commit c0f3e49

Browse files
Merge branch 'main' into feat-MCP-40
1 parent 8efb029 commit c0f3e49

File tree

133 files changed

+8472
-4218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+8472
-4218
lines changed

.github/copilot-instructions.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Project Overview
2+
3+
This project is a server implementing the MCP (Model Context Protocol) that allows users to interact with their MongoDB clusters
4+
and MongoDB Atlas accounts. It is built using TypeScript, Node.js and the official Anthropic
5+
@modelcontextprotocol/sdk SDK.
6+
7+
## Folder Structure
8+
9+
- `/src`: Contains the source code of the MCP Server.
10+
- `/src/tools`: Contains the implementation of MCP tools.
11+
- `/src/tools/atlas/`: Contains the implementation of MCP tools that are specific to MongoDB Atlas.
12+
- `/src/tools/mongodb/`: Contains the implementation of MCP tools that are specific to MongoDB clusters.
13+
- `/src/resources`: Contains the implementation of MCP Resources.
14+
- `/tests`: Contains the test code for the MCP Server.
15+
- `/tests/accuracy`: Contains the test code for the accuracy tests, that use different models to ensure that tools have reliable descriptions.
16+
- `/tests/integration`: Contains tests that start the MCP Server and interact with it to ensure that functionality is correct.
17+
- `/tests/unit`: Contains simple unit tests to cover specific functionality of the MCP Server.
18+
19+
## Libraries and Frameworks
20+
21+
- Zod for message and schema validation.
22+
- Express for the HTTP Transport implementation.
23+
- mongosh NodeDriverServiceProvider for connecting to MongoDB.
24+
- vitest for testing.
25+
- @modelcontextprotocol/sdk for the protocol implementation.
26+
27+
## Coding Standards
28+
29+
- For declarations, use types. For usage, rely on type inference unless it is not clear enough.
30+
- Always follow the eslint and prettier rule formats specified in `.eslint.config.js` and `.prettierrc.json`.
31+
- Use classes for stateful components and functions for stateless pure logic.
32+
- Use dependency injection to provide dependencies between components.
33+
- Avoid using global variables as much as possible.
34+
- New functionality MUST be under test.
35+
- Tools MUST HAVE integration tests.
36+
- Tools MUST HAVE unit tests.
37+
- Tools MAY HAVE accuracy tests.
38+
39+
## Architectural Guidelines and Best Practices
40+
41+
Every agent connected to the MCP Server has a Session object attached to it. The Session is the main entrypoint for
42+
dependencies to other components. Any component that MUST be used by either a tool or a resource MUST be provided
43+
through the Session.
44+
45+
### Guidelines for All Tools
46+
47+
- The name of the tool should describe an action: `create-collection`, `insert-many`.
48+
- The description MUST be a simple and accurate prompt that defines what the tool does in an unambiguous way.
49+
- All tools MUST provide a Zod schema that clearly specifies the API of the tool.
50+
- The Operation type MUST be clear:
51+
- `metadata`: Reads metadata for an entity (for example, a cluster). Example: CollectionSchema.
52+
- `read`: Reads information from a cluster or Atlas.
53+
- `create`: Creates resources, like a collection or a cluster.
54+
- `delete`: Deletes resources or documents, like collections, documents or clusters.
55+
- `update`: Modifies resources or documents, like collections, documents or clusters.
56+
- `connects`: Connects to a MongoDB cluster.
57+
- If a new tool is added, or the tool description is modified, the accuracy tests MUST be updated too.
58+
59+
### Guidelines for MongoDB Tools
60+
61+
- The tool category MUST be `mongodb`.
62+
- They MUST call `this.ensureConnected()` before attempting to query MongoDB.
63+
- They MUST return content sanitized using `formatUntrustedData`.
64+
- Documents should be serialized with `EJSON.stringify`.
65+
- Ensure there are proper timeout mechanisms to avoid long-running queries that can affect the server.
66+
- Tools that require elicitation MUST implement `getConfirmationMessage` and provide an easy-to-understand message for a human running the operation.
67+
- If a tool requires elicitation, it must be added to `src/common/config.ts` in the `confirmationRequiredTools` list in the defaultUserConfig.
68+
69+
### Guidelines for Atlas Tools
70+
71+
- The tool category MUST be `atlas`.

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "weekly"
7+
ignore:
8+
# We are ignoring major updates on yargs-parser because yargs-parser@22
9+
# does not play nicely when bundled using webpack. Our VSCode extension
10+
# bundles MCP server with the extension code and yargs-parser from MCP
11+
# server ends up on the final bundle which leads to issues such as -
12+
# https://github.com/mongodb-js/vscode/issues/1149.
13+
#
14+
# This was reported to yargs-parser as well -
15+
# https://github.com/yargs/yargs-parser/issues/517 and we already tried
16+
# their suggestion about disabling the meta resolution in webpack,
17+
# alongside others (dependency overrides, disabling the bundling of
18+
# yargs-parser), and none of the solutions yield a working extension. So
19+
# until we figure out a fix for this we need to keep mongodb-mcp-server
20+
# working with v21 of yargs-parser.
21+
- dependency-name: "yargs-parser"
22+
update-types: ["version-update:semver-major"]
723
- package-ecosystem: "github-actions"
824
directory: "/"
925
schedule:

.github/workflows/accuracy-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
3131
- uses: actions/checkout@v5
32-
- uses: actions/setup-node@v4
32+
- uses: actions/setup-node@v5
3333
with:
3434
node-version-file: package.json
3535
cache: "npm"

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
1919
- uses: actions/checkout@v5
20-
- uses: actions/setup-node@v4
20+
- uses: actions/setup-node@v5
2121
with:
2222
node-version-file: package.json
2323
cache: "npm"
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
3333
- uses: actions/checkout@v5
34-
- uses: actions/setup-node@v4
34+
- uses: actions/setup-node@v5
3535
with:
3636
node-version-file: package.json
3737
cache: "npm"
@@ -45,7 +45,7 @@ jobs:
4545
steps:
4646
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4747
- uses: actions/checkout@v5
48-
- uses: actions/setup-node@v4
48+
- uses: actions/setup-node@v5
4949
with:
5050
node-version-file: package.json
5151
cache: "npm"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: "Cleanup stale Atlas test environments"
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
permissions: {}
9+
10+
jobs:
11+
cleanup-envs:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
15+
- uses: actions/checkout@v5
16+
- uses: actions/setup-node@v5
17+
with:
18+
node-version-file: package.json
19+
cache: "npm"
20+
- name: Install dependencies
21+
run: npm ci
22+
- name: Run cleanup script
23+
env:
24+
MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }}
25+
MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }}
26+
MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }}
27+
run: npm run atlas:cleanup

.github/workflows/code_health_fork.yaml renamed to .github/workflows/code-health-fork.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ jobs:
2020
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2121
if: matrix.os == 'ubuntu-latest'
2222
- uses: actions/checkout@v5
23-
- uses: actions/setup-node@v4
23+
- uses: docker/setup-docker-action@v4
24+
if: matrix.os == 'ubuntu-latest'
25+
name: Setup Docker Environment
26+
with:
27+
set-host: true
28+
- uses: actions/setup-node@v5
2429
with:
2530
node-version-file: package.json
2631
cache: "npm"

.github/workflows/code_health.yaml renamed to .github/workflows/code-health.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ jobs:
2121
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
2222
if: matrix.os == 'ubuntu-latest'
2323
- uses: actions/checkout@v5
24-
- uses: actions/setup-node@v4
24+
- uses: docker/setup-docker-action@v4
25+
if: matrix.os == 'ubuntu-latest'
26+
name: Setup Docker Environment
27+
with:
28+
set-host: true
29+
- uses: actions/setup-node@v5
2530
with:
2631
node-version-file: package.json
2732
cache: "npm"
@@ -45,7 +50,7 @@ jobs:
4550
steps:
4651
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
4752
- uses: actions/checkout@v5
48-
- uses: actions/setup-node@v4
53+
- uses: actions/setup-node@v5
4954
with:
5055
node-version-file: package.json
5156
cache: "npm"
@@ -93,7 +98,7 @@ jobs:
9398
needs: [run-tests, run-atlas-tests, run-atlas-local-tests]
9499
steps:
95100
- uses: actions/checkout@v5
96-
- uses: actions/setup-node@v4
101+
- uses: actions/setup-node@v5
97102
with:
98103
node-version-file: package.json
99104
cache: "npm"
File renamed without changes.

.github/workflows/docker.yaml renamed to .github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Docker Buildx
1919
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
2020
- name: Login to Docker Hub
21-
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
21+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
2222
with:
2323
username: "${{ secrets.DOCKERHUB_USERNAME }}"
2424
password: "${{ secrets.DOCKERHUB_PASSWORD }}"

.github/workflows/jira-issue.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ jobs:
5454
5555
- name: Add comment
5656
if: steps.create.outputs.issue-key
57-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
57+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
5858
with:
5959
issue-number: ${{ github.event.issue.number }}
6060
body: |
6161
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.
6262
6363
- name: Remove create-jira label
6464
if: github.event.action == 'labeled' && github.event.label.name == 'create-jira'
65-
uses: actions/github-script@v7
65+
uses: actions/github-script@v8
6666
with:
6767
script: |
6868
try {
@@ -104,7 +104,7 @@ jobs:
104104
transition-id: 61
105105
- name: Add closure comment
106106
if: steps.close_jira_ticket.outcome == 'success'
107-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
107+
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
108108
with:
109109
issue-number: ${{ github.event.issue.number }}
110110
body: |

0 commit comments

Comments
 (0)