mongodb-mcp-server 0.0.4
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.
- package/.github/workflows/code_health.yaml +65 -0
- package/.github/workflows/prepare_release.yaml +45 -0
- package/.github/workflows/publish.yaml +70 -0
- package/.prettierignore +5 -0
- package/.prettierrc.json +37 -0
- package/.vscode/launch.json +17 -0
- package/CONTRIBUTING.md +185 -0
- package/LICENSE +202 -0
- package/README.md +234 -0
- package/dist/common/atlas/apiClient.js +147 -0
- package/dist/common/atlas/apiClient.js.map +1 -0
- package/dist/common/atlas/apiClientError.js +17 -0
- package/dist/common/atlas/apiClientError.js.map +1 -0
- package/dist/config.js +85 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.js +12 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.js +97 -0
- package/dist/logger.js.map +1 -0
- package/dist/server.js +45 -0
- package/dist/server.js.map +1 -0
- package/dist/session.js +30 -0
- package/dist/session.js.map +1 -0
- package/dist/tools/atlas/atlasTool.js +9 -0
- package/dist/tools/atlas/atlasTool.js.map +1 -0
- package/dist/tools/atlas/createAccessList.js +64 -0
- package/dist/tools/atlas/createAccessList.js.map +1 -0
- package/dist/tools/atlas/createDBUser.js +58 -0
- package/dist/tools/atlas/createDBUser.js.map +1 -0
- package/dist/tools/atlas/createFreeCluster.js +51 -0
- package/dist/tools/atlas/createFreeCluster.js.map +1 -0
- package/dist/tools/atlas/createProject.js +53 -0
- package/dist/tools/atlas/createProject.js.map +1 -0
- package/dist/tools/atlas/inspectAccessList.js +41 -0
- package/dist/tools/atlas/inspectAccessList.js.map +1 -0
- package/dist/tools/atlas/inspectCluster.js +42 -0
- package/dist/tools/atlas/inspectCluster.js.map +1 -0
- package/dist/tools/atlas/listClusters.js +97 -0
- package/dist/tools/atlas/listClusters.js.map +1 -0
- package/dist/tools/atlas/listDBUsers.js +52 -0
- package/dist/tools/atlas/listDBUsers.js.map +1 -0
- package/dist/tools/atlas/listOrgs.js +30 -0
- package/dist/tools/atlas/listOrgs.js.map +1 -0
- package/dist/tools/atlas/listProjects.js +42 -0
- package/dist/tools/atlas/listProjects.js.map +1 -0
- package/dist/tools/atlas/tools.js +23 -0
- package/dist/tools/atlas/tools.js.map +1 -0
- package/dist/tools/mongodb/create/createCollection.js +23 -0
- package/dist/tools/mongodb/create/createCollection.js.map +1 -0
- package/dist/tools/mongodb/create/createIndex.js +33 -0
- package/dist/tools/mongodb/create/createIndex.js.map +1 -0
- package/dist/tools/mongodb/create/insertMany.js +33 -0
- package/dist/tools/mongodb/create/insertMany.js.map +1 -0
- package/dist/tools/mongodb/delete/deleteMany.js +31 -0
- package/dist/tools/mongodb/delete/deleteMany.js.map +1 -0
- package/dist/tools/mongodb/delete/dropCollection.js +25 -0
- package/dist/tools/mongodb/delete/dropCollection.js.map +1 -0
- package/dist/tools/mongodb/delete/dropDatabase.js +25 -0
- package/dist/tools/mongodb/delete/dropDatabase.js.map +1 -0
- package/dist/tools/mongodb/metadata/collectionSchema.js +38 -0
- package/dist/tools/mongodb/metadata/collectionSchema.js.map +1 -0
- package/dist/tools/mongodb/metadata/collectionStorageSize.js +28 -0
- package/dist/tools/mongodb/metadata/collectionStorageSize.js.map +1 -0
- package/dist/tools/mongodb/metadata/connect.js +86 -0
- package/dist/tools/mongodb/metadata/connect.js.map +1 -0
- package/dist/tools/mongodb/metadata/dbStats.js +28 -0
- package/dist/tools/mongodb/metadata/dbStats.js.map +1 -0
- package/dist/tools/mongodb/metadata/explain.js +77 -0
- package/dist/tools/mongodb/metadata/explain.js.map +1 -0
- package/dist/tools/mongodb/metadata/listCollections.js +35 -0
- package/dist/tools/mongodb/metadata/listCollections.js.map +1 -0
- package/dist/tools/mongodb/metadata/listDatabases.js +23 -0
- package/dist/tools/mongodb/metadata/listDatabases.js.map +1 -0
- package/dist/tools/mongodb/mongodbTool.js +58 -0
- package/dist/tools/mongodb/mongodbTool.js.map +1 -0
- package/dist/tools/mongodb/read/aggregate.js +38 -0
- package/dist/tools/mongodb/read/aggregate.js.map +1 -0
- package/dist/tools/mongodb/read/collectionIndexes.js +23 -0
- package/dist/tools/mongodb/read/collectionIndexes.js.map +1 -0
- package/dist/tools/mongodb/read/count.js +34 -0
- package/dist/tools/mongodb/read/count.js.map +1 -0
- package/dist/tools/mongodb/read/find.js +51 -0
- package/dist/tools/mongodb/read/find.js.map +1 -0
- package/dist/tools/mongodb/tools.js +41 -0
- package/dist/tools/mongodb/tools.js.map +1 -0
- package/dist/tools/mongodb/update/renameCollection.js +31 -0
- package/dist/tools/mongodb/update/renameCollection.js.map +1 -0
- package/dist/tools/mongodb/update/updateMany.js +56 -0
- package/dist/tools/mongodb/update/updateMany.js.map +1 -0
- package/dist/tools/tool.js +56 -0
- package/dist/tools/tool.js.map +1 -0
- package/eslint.config.js +35 -0
- package/jest.config.js +22 -0
- package/package.json +76 -0
- package/scripts/apply.ts +129 -0
- package/scripts/filter.ts +67 -0
- package/scripts/generate.sh +11 -0
- package/src/common/atlas/apiClient.ts +202 -0
- package/src/common/atlas/apiClientError.ts +21 -0
- package/src/common/atlas/openapi.d.ts +5849 -0
- package/src/config.ts +124 -0
- package/src/errors.ts +13 -0
- package/src/index.ts +30 -0
- package/src/logger.ts +117 -0
- package/src/server.ts +64 -0
- package/src/session.ts +37 -0
- package/src/tools/atlas/atlasTool.ts +10 -0
- package/src/tools/atlas/createAccessList.ts +78 -0
- package/src/tools/atlas/createDBUser.ts +70 -0
- package/src/tools/atlas/createFreeCluster.ts +55 -0
- package/src/tools/atlas/createProject.ts +63 -0
- package/src/tools/atlas/inspectAccessList.ts +44 -0
- package/src/tools/atlas/inspectCluster.ts +47 -0
- package/src/tools/atlas/listClusters.ts +104 -0
- package/src/tools/atlas/listDBUsers.ts +62 -0
- package/src/tools/atlas/listOrgs.ts +34 -0
- package/src/tools/atlas/listProjects.ts +46 -0
- package/src/tools/atlas/tools.ts +23 -0
- package/src/tools/mongodb/create/createCollection.ts +26 -0
- package/src/tools/mongodb/create/createIndex.ts +41 -0
- package/src/tools/mongodb/create/insertMany.ts +40 -0
- package/src/tools/mongodb/delete/deleteMany.ts +38 -0
- package/src/tools/mongodb/delete/dropCollection.ts +27 -0
- package/src/tools/mongodb/delete/dropDatabase.ts +26 -0
- package/src/tools/mongodb/metadata/collectionSchema.ts +41 -0
- package/src/tools/mongodb/metadata/collectionStorageSize.ts +30 -0
- package/src/tools/mongodb/metadata/connect.ts +94 -0
- package/src/tools/mongodb/metadata/dbStats.ts +30 -0
- package/src/tools/mongodb/metadata/explain.ts +90 -0
- package/src/tools/mongodb/metadata/listCollections.ts +38 -0
- package/src/tools/mongodb/metadata/listDatabases.ts +26 -0
- package/src/tools/mongodb/mongodbTool.ts +69 -0
- package/src/tools/mongodb/read/aggregate.ts +45 -0
- package/src/tools/mongodb/read/collectionIndexes.ts +24 -0
- package/src/tools/mongodb/read/count.ts +39 -0
- package/src/tools/mongodb/read/find.ts +62 -0
- package/src/tools/mongodb/tools.ts +41 -0
- package/src/tools/mongodb/update/renameCollection.ts +37 -0
- package/src/tools/mongodb/update/updateMany.ts +65 -0
- package/src/tools/tool.ts +90 -0
- package/src/types/mongodb-redact.d.ts +4 -0
- package/tests/integration/helpers.ts +241 -0
- package/tests/integration/inMemoryTransport.ts +58 -0
- package/tests/integration/server.test.ts +35 -0
- package/tests/integration/tools/atlas/accessLists.test.ts +100 -0
- package/tests/integration/tools/atlas/atlasHelpers.ts +110 -0
- package/tests/integration/tools/atlas/clusters.test.ts +122 -0
- package/tests/integration/tools/atlas/dbUsers.test.ts +80 -0
- package/tests/integration/tools/atlas/orgs.test.ts +24 -0
- package/tests/integration/tools/atlas/projects.test.ts +80 -0
- package/tests/integration/tools/mongodb/create/createCollection.test.ts +138 -0
- package/tests/integration/tools/mongodb/create/createIndex.test.ts +249 -0
- package/tests/integration/tools/mongodb/create/insertMany.test.ts +141 -0
- package/tests/integration/tools/mongodb/delete/deleteMany.test.ts +191 -0
- package/tests/integration/tools/mongodb/delete/dropCollection.test.ts +118 -0
- package/tests/integration/tools/mongodb/delete/dropDatabase.test.ts +114 -0
- package/tests/integration/tools/mongodb/metadata/connect.test.ts +137 -0
- package/tests/integration/tools/mongodb/metadata/listCollections.test.ts +104 -0
- package/tests/integration/tools/mongodb/metadata/listDatabases.test.ts +67 -0
- package/tests/integration/tools/mongodb/read/count.test.ts +138 -0
- package/tsconfig.jest.json +10 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Code Health
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
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
|
|
22
|
+
|
|
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
|
+
- name: Run style check
|
|
35
|
+
run: npm run generate
|
|
36
|
+
|
|
37
|
+
run-tests:
|
|
38
|
+
strategy:
|
|
39
|
+
matrix:
|
|
40
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
41
|
+
fail-fast: false
|
|
42
|
+
runs-on: ${{ matrix.os }}
|
|
43
|
+
steps:
|
|
44
|
+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
|
|
45
|
+
if: matrix.os != 'windows-latest'
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- uses: actions/setup-node@v4
|
|
48
|
+
with:
|
|
49
|
+
node-version-file: package.json
|
|
50
|
+
cache: "npm"
|
|
51
|
+
- name: Install dependencies
|
|
52
|
+
run: npm ci
|
|
53
|
+
- name: Run tests
|
|
54
|
+
env:
|
|
55
|
+
MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }}
|
|
56
|
+
MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }}
|
|
57
|
+
MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }}
|
|
58
|
+
run: npm test
|
|
59
|
+
- name: Coveralls GitHub Action
|
|
60
|
+
uses: coverallsapp/github-action@v2.3.6
|
|
61
|
+
if: matrix.os == 'ubuntu-latest'
|
|
62
|
+
with:
|
|
63
|
+
file: coverage/lcov.info
|
|
64
|
+
git-branch: ${{ github.head_ref || github.ref_name }}
|
|
65
|
+
git-commit: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Prepare release
|
|
2
|
+
description: |
|
|
3
|
+
Bumps the version in package.json and creates a release PR. Once merged, the new
|
|
4
|
+
version will be published to npm.
|
|
5
|
+
on:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
version:
|
|
9
|
+
description: "Exact version to bump to or one of major, minor, patch"
|
|
10
|
+
required: true
|
|
11
|
+
default: "patch"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
create-pr:
|
|
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
|
+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version-file: package.json
|
|
27
|
+
registry-url: "https://registry.npmjs.org"
|
|
28
|
+
cache: "npm"
|
|
29
|
+
- name: Bump version
|
|
30
|
+
id: bump-version
|
|
31
|
+
run: |
|
|
32
|
+
echo "NEW_VERSION=$(npm version ${{ inputs.version }} --no-git-tag-version)" >> $GITHUB_OUTPUT
|
|
33
|
+
- name: Create release PR
|
|
34
|
+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # 7.0.8
|
|
35
|
+
with:
|
|
36
|
+
title: "Release v${{ steps.bump-version.outputs.NEW_VERSION }}"
|
|
37
|
+
token: ${{ steps.app-token.outputs.token }}
|
|
38
|
+
commit-message: "Bump version to v${{ steps.bump-version.outputs.NEW_VERSION }}"
|
|
39
|
+
body: |
|
|
40
|
+
This PR bumps the package version to v${{ steps.bump-version.outputs.NEW_VERSION }}.
|
|
41
|
+
Once merged, the new version will be published to npm.
|
|
42
|
+
base: main
|
|
43
|
+
branch: release/v${{ steps.bump-version.outputs.NEW_VERSION }}
|
|
44
|
+
author: "${{ steps.app-token.outputs.app-slug}}[bot] <${{ steps.app-token.outputs.app-email }}>"
|
|
45
|
+
committer: "${{ steps.app-token.outputs.app-slug}}[bot] <${{ steps.app-token.outputs.app-email }}>"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Publish
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
jobs:
|
|
10
|
+
check:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
outputs:
|
|
13
|
+
VERSION_EXISTS: ${{ steps.check-version.outputs.VERSION_EXISTS }}
|
|
14
|
+
VERSION: ${{ steps.get-version.outputs.VERSION }}
|
|
15
|
+
steps:
|
|
16
|
+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
- uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version-file: package.json
|
|
23
|
+
registry-url: "https://registry.npmjs.org"
|
|
24
|
+
cache: "npm"
|
|
25
|
+
- name: Get version
|
|
26
|
+
id: get-version
|
|
27
|
+
shell: bash
|
|
28
|
+
run: |
|
|
29
|
+
set +e
|
|
30
|
+
|
|
31
|
+
VERSION=v$(jq -r '.version' < package.json)
|
|
32
|
+
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
33
|
+
- name: Check if version already exists
|
|
34
|
+
id: check-version
|
|
35
|
+
shell: bash
|
|
36
|
+
run: |
|
|
37
|
+
set +e
|
|
38
|
+
|
|
39
|
+
git rev-parse "${{ steps.get-version.outputs.VERSION }}" >/dev/null 2>&1
|
|
40
|
+
if [[ $? -eq 0 ]]; then
|
|
41
|
+
echo "VERSION_EXISTS=true" >> "$GITHUB_OUTPUT"
|
|
42
|
+
else
|
|
43
|
+
echo "VERSION_EXISTS=false" >> "$GITHUB_OUTPUT"
|
|
44
|
+
fi
|
|
45
|
+
publish:
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
environment: Production
|
|
48
|
+
needs: check
|
|
49
|
+
if: needs.check.outputs.VERSION_EXISTS == 'false'
|
|
50
|
+
steps:
|
|
51
|
+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
- uses: actions/setup-node@v4
|
|
54
|
+
with:
|
|
55
|
+
node-version-file: package.json
|
|
56
|
+
registry-url: "https://registry.npmjs.org"
|
|
57
|
+
cache: "npm"
|
|
58
|
+
- name: Build package
|
|
59
|
+
run: |
|
|
60
|
+
npm ci
|
|
61
|
+
npm run build
|
|
62
|
+
- name: Publish to NPM
|
|
63
|
+
run: npm publish
|
|
64
|
+
env:
|
|
65
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
66
|
+
- name: Publish git release
|
|
67
|
+
env:
|
|
68
|
+
GH_TOKEN: ${{ github.token }}
|
|
69
|
+
run: |
|
|
70
|
+
gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }}
|
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"trailingComma": "es5",
|
|
3
|
+
"tabWidth": 4,
|
|
4
|
+
"semi": true,
|
|
5
|
+
"singleQuote": false,
|
|
6
|
+
"printWidth": 120,
|
|
7
|
+
"overrides": [
|
|
8
|
+
{
|
|
9
|
+
"files": "*.ts",
|
|
10
|
+
"options": {
|
|
11
|
+
"insertPragma": false,
|
|
12
|
+
"proseWrap": "preserve"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"files": "*.json",
|
|
17
|
+
"options": {
|
|
18
|
+
"tabWidth": 2,
|
|
19
|
+
"printWidth": 80
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"files": "*.md",
|
|
24
|
+
"options": {
|
|
25
|
+
"tabWidth": 2,
|
|
26
|
+
"printWidth": 80
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"files": "*.yaml",
|
|
31
|
+
"options": {
|
|
32
|
+
"tabWidth": 2,
|
|
33
|
+
"printWidth": 80
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Launch Program",
|
|
11
|
+
"skipFiles": ["<node_internals>/**"],
|
|
12
|
+
"program": "${workspaceFolder}/dist/index.js",
|
|
13
|
+
"preLaunchTask": "tsc: build - tsconfig.json",
|
|
14
|
+
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Contributing to MongoDB MCP Server
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to the MongoDB MCP Server project! This document provides guidelines and instructions for contributing.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This project implements a Model Context Protocol (MCP) server for MongoDB and MongoDB Atlas, enabling AI assistants to interact with MongoDB Atlas resources through natural language.
|
|
8
|
+
|
|
9
|
+
## Development Setup
|
|
10
|
+
|
|
11
|
+
### Prerequisites
|
|
12
|
+
|
|
13
|
+
- Node.js (v20 or later)
|
|
14
|
+
- npm
|
|
15
|
+
|
|
16
|
+
### Getting Started
|
|
17
|
+
|
|
18
|
+
1. Clone the repository:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
git clone https://github.com/mongodb-labs/mongodb-mcp-server.git
|
|
22
|
+
cd mongodb-mcp-server
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. Install dependencies:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npm install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
3. Add the mcp server to your IDE of choice (see the [README](README.md) for detailed client integration instructions)
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"MongoDB": {
|
|
36
|
+
"command": "/path/to/mongodb-mcp-server/dist/index.js"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Code Contribution Workflow
|
|
43
|
+
|
|
44
|
+
1. Create a new branch for your feature or bugfix:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
git checkout -b feature/your-feature-name
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
2. Make your changes, following the code style of the project
|
|
51
|
+
|
|
52
|
+
3. Run the inspector and double check your changes:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
npm run inspect
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
4. Commit your changes with a descriptive commit message
|
|
59
|
+
|
|
60
|
+
## Adding tests to the MCP Server
|
|
61
|
+
|
|
62
|
+
When adding new features or fixing bugs, please ensure that you also add tests to cover your changes. This helps maintain the quality and reliability of the codebase.
|
|
63
|
+
|
|
64
|
+
## Running Tests
|
|
65
|
+
|
|
66
|
+
The tests can be found in the `tests` directory.
|
|
67
|
+
|
|
68
|
+
You can run tests using the following npm scripts:
|
|
69
|
+
|
|
70
|
+
- `npm test`: Run all tests
|
|
71
|
+
|
|
72
|
+
To run a specific test file or directory:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm test -- path/to/test/file.test.ts
|
|
76
|
+
npm test -- path/to/directory
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Troubleshooting
|
|
80
|
+
|
|
81
|
+
### Restart Server
|
|
82
|
+
|
|
83
|
+
- Run `npm run build` to re-build the server if you made changes to the code
|
|
84
|
+
- Press `Cmd + Shift + P` and type List MCP Servers
|
|
85
|
+
- Select the MCP server you want to restart
|
|
86
|
+
- Select the option to restart the server
|
|
87
|
+
|
|
88
|
+
### View Logs
|
|
89
|
+
|
|
90
|
+
To see MCP logs, check https://code.visualstudio.com/docs/copilot/chat/mcp-servers.
|
|
91
|
+
|
|
92
|
+
- Press `Cmd + Shift + P` and type List MCP Servers
|
|
93
|
+
- Select the MCP server you want to see logs for
|
|
94
|
+
- Select the option to view logs in the output panel
|
|
95
|
+
|
|
96
|
+
### Debugging
|
|
97
|
+
|
|
98
|
+
For debugging, we use the MCP inspector tool. From the root of this repository, run:
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
npm run inspect
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This is equivalent to:
|
|
105
|
+
|
|
106
|
+
```shell
|
|
107
|
+
npx @modelcontextprotocol/inspector -- node dist/index.js
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Pull Request Guidelines
|
|
111
|
+
|
|
112
|
+
1. Update documentation if necessary
|
|
113
|
+
2. Ensure your PR includes only relevant changes
|
|
114
|
+
3. Link any related issues in your PR description
|
|
115
|
+
4. Keep PRs focused on a single topic
|
|
116
|
+
|
|
117
|
+
## Code Standards
|
|
118
|
+
|
|
119
|
+
- Use TypeScript for all new code
|
|
120
|
+
- Follow the existing code style (indentation, naming conventions, etc.)
|
|
121
|
+
- Comment your code when necessary, especially for complex logic
|
|
122
|
+
- Use meaningful variable and function names
|
|
123
|
+
|
|
124
|
+
## Reporting Issues
|
|
125
|
+
|
|
126
|
+
When reporting issues, please include:
|
|
127
|
+
|
|
128
|
+
- A clear description of the problem
|
|
129
|
+
- Steps to reproduce
|
|
130
|
+
- Expected vs. actual behavior
|
|
131
|
+
- Version information
|
|
132
|
+
- Environment details
|
|
133
|
+
|
|
134
|
+
## Adding New Tools
|
|
135
|
+
|
|
136
|
+
When adding new tools to the MCP server:
|
|
137
|
+
|
|
138
|
+
1. Follow the existing pattern in `server.ts`
|
|
139
|
+
2. Define clear parameter schemas using Zod
|
|
140
|
+
3. Implement thorough error handling
|
|
141
|
+
4. Add proper documentation for the tool
|
|
142
|
+
5. Include examples of how to use the tool
|
|
143
|
+
|
|
144
|
+
## Release Process
|
|
145
|
+
|
|
146
|
+
Our release process is automated using GitHub Actions workflows:
|
|
147
|
+
|
|
148
|
+
### Version Bumping
|
|
149
|
+
|
|
150
|
+
1. To create a new version, go to the GitHub repository Actions tab
|
|
151
|
+
2. Select the "Version Bump" workflow
|
|
152
|
+
3. Click "Run workflow" and choose one of the following options:
|
|
153
|
+
- `patch` (e.g., 1.0.0 → 1.0.1) for backward-compatible bug fixes
|
|
154
|
+
- `minor` (e.g., 1.0.0 → 1.1.0) for backward-compatible new features
|
|
155
|
+
- `major` (e.g., 1.0.0 → 2.0.0) for breaking changes
|
|
156
|
+
- A specific version number (e.g., `1.2.3`)
|
|
157
|
+
4. This creates a pull request with the version change
|
|
158
|
+
5. Once approved and merged, the version is updated
|
|
159
|
+
|
|
160
|
+
### Automatic Publishing
|
|
161
|
+
|
|
162
|
+
When a version bump is merged to the main branch:
|
|
163
|
+
|
|
164
|
+
1. The "Publish" workflow automatically runs
|
|
165
|
+
2. It checks if the version already exists as a git tag
|
|
166
|
+
3. If the version is new, it:
|
|
167
|
+
- Builds the package
|
|
168
|
+
- Publishes to NPM
|
|
169
|
+
- Creates a git tag for the version
|
|
170
|
+
- Creates a GitHub release with auto-generated release notes
|
|
171
|
+
|
|
172
|
+
### Code Quality
|
|
173
|
+
|
|
174
|
+
All pull requests automatically run through the "Code Health" workflow, which:
|
|
175
|
+
|
|
176
|
+
- Verifies code style and formatting
|
|
177
|
+
- Runs tests on multiple platforms (Ubuntu, macOS, Windows)
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
By contributing to this project, you agree that your contributions will be licensed under the project's license.
|
|
182
|
+
|
|
183
|
+
## Questions?
|
|
184
|
+
|
|
185
|
+
If you have any questions or need help, please open an issue or reach out to the maintainers.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|