Skip to content

Commit 9d49948

Browse files
committed
Merge branch 'main' of github.com:mongodb-js/mongodb-mcp-server into gagik/use-machine-id
2 parents 8575d9a + d585baa commit 9d49948

File tree

5 files changed

+80
-38
lines changed

5 files changed

+80
-38
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
---
22
name: "Bug Report"
33
description: "Report a bug to help us improve."
4-
title: "[Bug]: <title>"
4+
title: "[Bug]: "
55
type: "Bug"
66
body:
77
- type: markdown
88
attributes:
99
value: "Please fill out the following details to help us address the issue."
10-
- type: input
11-
id: title
12-
attributes:
13-
label: "Bug Title"
14-
description: "Provide a short and descriptive title for the bug."
15-
placeholder: "e.g., can't run an aggregation"
16-
validations:
17-
required: true
1810
- type: checkboxes
1911
id: app
2012
attributes:

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ The MongoDB MCP Server can be configured using multiple methods, with the follow
150150
| `apiClientSecret` | Atlas API client secret for authentication |
151151
| `connectionString` | MongoDB connection string for direct database connections (optional users may choose to inform it on every tool call) |
152152
| `logPath` | Folder to store logs |
153-
| `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled. |
153+
| `disabledTools` | An array of tool names, operation types, and/or categories of tools that will be disabled |
154154
| `readOnly` | When set to true, only allows read and metadata operation types, disabling create/update/delete operations |
155+
| `telemetry` | When set to disabled, disables telemetry collection |
155156

156157
#### `logPath`
157158

@@ -196,6 +197,16 @@ You can enable read-only mode using:
196197

197198
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.
198199

200+
#### Telemetry
201+
202+
The `telemetry` configuration option allows you to disable telemetry collection. When enabled, the MCP server will collect usage data and send it to MongoDB.
203+
204+
You can disable telemetry using:
205+
206+
- **Environment variable**: `export MDB_MCP_TELEMETRY=disabled`
207+
- **Command-line argument**: `--telemetry disabled`
208+
- **DO_NOT_TRACK environment variable**: `export DO_NOT_TRACK=1`
209+
199210
### Atlas API Access
200211

201212
To use the Atlas API tools, you'll need to create a service account in MongoDB Atlas:

src/server.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,39 +152,25 @@ export class Server {
152152
telemetry: this.userConfig.telemetry,
153153
logPath: this.userConfig.logPath,
154154
connectionString: this.userConfig.connectionString
155-
? "set; no explicit connect needed, use switch-connection tool to connect to a different connection if necessary"
156-
: "not set; before using any mongodb tool, you need to call the connect tool with a connection string",
155+
? "set; access to MongoDB tools are currently available to use"
156+
: "not set; before using any MongoDB tool, you need to configure a connection string, alternatively you can setup MongoDB Atlas access, more info at 'https://github.com/mongodb-js/mongodb-mcp-server'.",
157157
connectOptions: this.userConfig.connectOptions,
158+
atlas:
159+
this.userConfig.apiClientId && this.userConfig.apiClientSecret
160+
? "set; MongoDB Atlas tools are currently available to use"
161+
: "not set; MongoDB Atlas tools are currently unavailable, to have access to MongoDB Atlas tools like creating clusters or connecting to clusters make sure to setup credentials, more info at 'https://github.com/mongodb-js/mongodb-mcp-server'.",
158162
};
159163
return {
160164
contents: [
161165
{
162166
text: JSON.stringify(result),
167+
mimeType: "application/json",
163168
uri: uri.href,
164169
},
165170
],
166171
};
167172
}
168173
);
169-
if (this.userConfig.connectionString) {
170-
this.mcpServer.resource(
171-
"connection-string",
172-
"config://connection-string",
173-
{
174-
description: "Preconfigured connection string that will be used as a default in the `connect` tool",
175-
},
176-
(uri) => {
177-
return {
178-
contents: [
179-
{
180-
text: `Preconfigured connection string: ${this.userConfig.connectionString}`,
181-
uri: uri.href,
182-
},
183-
],
184-
};
185-
}
186-
);
187-
}
188174
}
189175

190176
private async validateConfig(): Promise<void> {

src/tools/atlas/read/inspectCluster.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,38 @@ export class InspectClusterTool extends AtlasToolBase {
3131
throw new Error("Cluster not found");
3232
}
3333

34+
const regionConfigs = (cluster.replicationSpecs || [])
35+
.map(
36+
(replicationSpec) =>
37+
(replicationSpec.regionConfigs || []) as {
38+
providerName: string;
39+
electableSpecs?: {
40+
instanceSize: string;
41+
};
42+
readOnlySpecs?: {
43+
instanceSize: string;
44+
};
45+
}[]
46+
)
47+
.flat()
48+
.map((regionConfig) => {
49+
return {
50+
providerName: regionConfig.providerName,
51+
instanceSize: regionConfig.electableSpecs?.instanceSize || regionConfig.readOnlySpecs?.instanceSize,
52+
};
53+
});
54+
55+
const instanceSize = (regionConfigs.length <= 0 ? undefined : regionConfigs[0].instanceSize) || "UNKNOWN";
56+
57+
const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
58+
3459
return {
3560
content: [
3661
{
3762
type: "text",
38-
text: `Cluster Name | State | MongoDB Version | Connection String
39-
----------------|----------------|----------------|----------------|----------------
40-
${cluster.name} | ${cluster.stateName} | ${cluster.mongoDBVersion || "N/A"} | ${cluster.connectionStrings?.standard || "N/A"}`,
63+
text: `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
64+
----------------|----------------|----------------|----------------|----------------|----------------
65+
${cluster.name} | ${clusterInstanceType} | ${clusterInstanceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${cluster.mongoDBVersion || "N/A"} | ${cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard || "N/A"}`,
4166
},
4267
],
4368
};

src/tools/atlas/read/listClusters.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,37 @@ ${rows}`,
7979
}
8080
const rows = clusters.results
8181
.map((cluster) => {
82-
const connectionString = cluster.connectionStrings?.standard || "N/A";
82+
const connectionString =
83+
cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard || "N/A";
8384
const mongoDBVersion = cluster.mongoDBVersion || "N/A";
84-
return `${cluster.name} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
85+
const regionConfigs = (cluster.replicationSpecs || [])
86+
.map(
87+
(replicationSpec) =>
88+
(replicationSpec.regionConfigs || []) as {
89+
providerName: string;
90+
electableSpecs?: {
91+
instanceSize: string;
92+
};
93+
readOnlySpecs?: {
94+
instanceSize: string;
95+
};
96+
}[]
97+
)
98+
.flat()
99+
.map((regionConfig) => {
100+
return {
101+
providerName: regionConfig.providerName,
102+
instanceSize:
103+
regionConfig.electableSpecs?.instanceSize || regionConfig.readOnlySpecs?.instanceSize,
104+
};
105+
});
106+
107+
const instanceSize =
108+
(regionConfigs.length <= 0 ? undefined : regionConfigs[0].instanceSize) || "UNKNOWN";
109+
110+
const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
111+
112+
return `${cluster.name} | ${clusterInstanceType} | ${clusterInstanceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
85113
})
86114
.join("\n");
87115
return {
@@ -92,8 +120,8 @@ ${rows}`,
92120
},
93121
{
94122
type: "text",
95-
text: `Cluster Name | State | MongoDB Version | Connection String
96-
----------------|----------------|----------------|----------------|----------------
123+
text: `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
124+
----------------|----------------|----------------|----------------|----------------|----------------
97125
${rows}`,
98126
},
99127
],

0 commit comments

Comments
 (0)