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
package/dist/server.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AtlasTools } from "./tools/atlas/tools.js";
|
|
2
|
+
import { MongoDbTools } from "./tools/mongodb/tools.js";
|
|
3
|
+
import logger, { initializeLogger } from "./logger.js";
|
|
4
|
+
import { mongoLogId } from "mongodb-log-writer";
|
|
5
|
+
import config from "./config.js";
|
|
6
|
+
export class Server {
|
|
7
|
+
constructor({ mcpServer, session }) {
|
|
8
|
+
this.mcpServer = mcpServer;
|
|
9
|
+
this.session = session;
|
|
10
|
+
}
|
|
11
|
+
async connect(transport) {
|
|
12
|
+
this.mcpServer.server.registerCapabilities({ logging: {} });
|
|
13
|
+
this.registerTools();
|
|
14
|
+
this.registerResources();
|
|
15
|
+
await initializeLogger(this.mcpServer);
|
|
16
|
+
await this.mcpServer.connect(transport);
|
|
17
|
+
logger.info(mongoLogId(1000004), "server", `Server started with transport ${transport.constructor.name}`);
|
|
18
|
+
}
|
|
19
|
+
async close() {
|
|
20
|
+
await this.session.close();
|
|
21
|
+
await this.mcpServer.close();
|
|
22
|
+
}
|
|
23
|
+
registerTools() {
|
|
24
|
+
for (const tool of [...AtlasTools, ...MongoDbTools]) {
|
|
25
|
+
new tool(this.session).register(this.mcpServer);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
registerResources() {
|
|
29
|
+
if (config.connectionString) {
|
|
30
|
+
this.mcpServer.resource("connection-string", "config://connection-string", {
|
|
31
|
+
description: "Preconfigured connection string that will be used as a default in the `connect` tool",
|
|
32
|
+
}, (uri) => {
|
|
33
|
+
return {
|
|
34
|
+
contents: [
|
|
35
|
+
{
|
|
36
|
+
text: `Preconfigured connection string: ${config.connectionString}`,
|
|
37
|
+
uri: uri.href,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,OAAO,MAAM;IAIf,YAAY,EAAE,SAAS,EAAE,OAAO,EAA8C;QAC1E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,SAAoB;QAC9B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,MAAM,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAExC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAS,CAAC,EAAE,QAAQ,EAAE,iCAAiC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IAChH,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAEO,aAAa;QACjB,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,UAAU,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC;YAClD,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpD,CAAC;IACL,CAAC;IAEO,iBAAiB;QACrB,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC1B,IAAI,CAAC,SAAS,CAAC,QAAQ,CACnB,mBAAmB,EACnB,4BAA4B,EAC5B;gBACI,WAAW,EAAE,sFAAsF;aACtG,EACD,CAAC,GAAG,EAAE,EAAE;gBACJ,OAAO;oBACH,QAAQ,EAAE;wBACN;4BACI,IAAI,EAAE,oCAAoC,MAAM,CAAC,gBAAgB,EAAE;4BACnE,GAAG,EAAE,GAAG,CAAC,IAAI;yBAChB;qBACJ;iBACJ,CAAC;YACN,CAAC,CACJ,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ApiClient } from "./common/atlas/apiClient.js";
|
|
2
|
+
import config from "./config.js";
|
|
3
|
+
export class Session {
|
|
4
|
+
ensureAuthenticated() {
|
|
5
|
+
if (!this.apiClient) {
|
|
6
|
+
if (!config.apiClientId || !config.apiClientSecret) {
|
|
7
|
+
throw new Error("Not authenticated make sure to configure MCP server with MDB_MCP_API_CLIENT_ID and MDB_MCP_API_CLIENT_SECRET environment variables.");
|
|
8
|
+
}
|
|
9
|
+
this.apiClient = new ApiClient({
|
|
10
|
+
baseUrl: config.apiBaseUrl,
|
|
11
|
+
credentials: {
|
|
12
|
+
clientId: config.apiClientId,
|
|
13
|
+
clientSecret: config.apiClientSecret,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async close() {
|
|
19
|
+
if (this.serviceProvider) {
|
|
20
|
+
try {
|
|
21
|
+
await this.serviceProvider.close(true);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error("Error closing service provider:", error);
|
|
25
|
+
}
|
|
26
|
+
this.serviceProvider = undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,OAAO,OAAO;IAIhB,mBAAmB;QACf,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;gBACjD,MAAM,IAAI,KAAK,CACX,qIAAqI,CACxI,CAAC;YACN,CAAC;YAED,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC;gBAC3B,OAAO,EAAE,MAAM,CAAC,UAAU;gBAC1B,WAAW,EAAE;oBACT,QAAQ,EAAE,MAAM,CAAC,WAAW;oBAC5B,YAAY,EAAE,MAAM,CAAC,eAAe;iBACvC;aACJ,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACvB,IAAI,CAAC;gBACD,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YAC5D,CAAC;YACD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACrC,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atlasTool.js","sourceRoot":"","sources":["../../../src/tools/atlas/atlasTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAGpD,MAAM,OAAgB,aAAc,SAAQ,QAAQ;IAChD,YAA+B,OAAgB;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QADY,YAAO,GAAP,OAAO,CAAS;QAIrC,aAAQ,GAAiB,OAAO,CAAC;IAF3C,CAAC;CAGJ"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
const DEFAULT_COMMENT = "Added by Atlas MCP";
|
|
4
|
+
export class CreateAccessListTool extends AtlasToolBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.name = "atlas-create-access-list";
|
|
8
|
+
this.description = "Allow Ip/CIDR ranges to access your MongoDB Atlas clusters.";
|
|
9
|
+
this.operationType = "create";
|
|
10
|
+
this.argsShape = {
|
|
11
|
+
projectId: z.string().describe("Atlas project ID"),
|
|
12
|
+
ipAddresses: z
|
|
13
|
+
.array(z.string().ip({ version: "v4" }))
|
|
14
|
+
.describe("IP addresses to allow access from")
|
|
15
|
+
.optional(),
|
|
16
|
+
cidrBlocks: z.array(z.string().cidr()).describe("CIDR blocks to allow access from").optional(),
|
|
17
|
+
currentIpAddress: z.boolean().describe("Add the current IP address").default(false),
|
|
18
|
+
comment: z.string().describe("Comment for the access list entries").default(DEFAULT_COMMENT).optional(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async execute({ projectId, ipAddresses, cidrBlocks, comment, currentIpAddress, }) {
|
|
22
|
+
this.session.ensureAuthenticated();
|
|
23
|
+
if (!ipAddresses?.length && !cidrBlocks?.length && !currentIpAddress) {
|
|
24
|
+
throw new Error("One of ipAddresses, cidrBlocks, currentIpAddress must be provided.");
|
|
25
|
+
}
|
|
26
|
+
const ipInputs = (ipAddresses || []).map((ipAddress) => ({
|
|
27
|
+
groupId: projectId,
|
|
28
|
+
ipAddress,
|
|
29
|
+
comment: comment || DEFAULT_COMMENT,
|
|
30
|
+
}));
|
|
31
|
+
if (currentIpAddress) {
|
|
32
|
+
const currentIp = await this.session.apiClient.getIpInfo();
|
|
33
|
+
const input = {
|
|
34
|
+
groupId: projectId,
|
|
35
|
+
ipAddress: currentIp.currentIpv4Address,
|
|
36
|
+
comment: comment || DEFAULT_COMMENT,
|
|
37
|
+
};
|
|
38
|
+
ipInputs.push(input);
|
|
39
|
+
}
|
|
40
|
+
const cidrInputs = (cidrBlocks || []).map((cidrBlock) => ({
|
|
41
|
+
groupId: projectId,
|
|
42
|
+
cidrBlock,
|
|
43
|
+
comment: comment || DEFAULT_COMMENT,
|
|
44
|
+
}));
|
|
45
|
+
const inputs = [...ipInputs, ...cidrInputs];
|
|
46
|
+
await this.session.apiClient.createProjectIpAccessList({
|
|
47
|
+
params: {
|
|
48
|
+
path: {
|
|
49
|
+
groupId: projectId,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
body: inputs,
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: "text",
|
|
58
|
+
text: `IP/CIDR ranges added to access list for project ${projectId}.`,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=createAccessList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAccessList.js","sourceRoot":"","sources":["../../../src/tools/atlas/createAccessList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC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|
3
|
+
export class CreateDBUserTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-create-db-user";
|
|
7
|
+
this.description = "Create an MongoDB Atlas database user";
|
|
8
|
+
this.operationType = "create";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectId: z.string().describe("Atlas project ID"),
|
|
11
|
+
username: z.string().describe("Username for the new user"),
|
|
12
|
+
password: z.string().describe("Password for the new user"),
|
|
13
|
+
roles: z
|
|
14
|
+
.array(z.object({
|
|
15
|
+
roleName: z.string().describe("Role name"),
|
|
16
|
+
databaseName: z.string().describe("Database name").default("admin"),
|
|
17
|
+
collectionName: z.string().describe("Collection name").optional(),
|
|
18
|
+
}))
|
|
19
|
+
.describe("Roles for the new user"),
|
|
20
|
+
clusters: z
|
|
21
|
+
.array(z.string())
|
|
22
|
+
.describe("Clusters to assign the user to, leave empty for access to all clusters")
|
|
23
|
+
.optional(),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async execute({ projectId, username, password, roles, clusters, }) {
|
|
27
|
+
this.session.ensureAuthenticated();
|
|
28
|
+
const input = {
|
|
29
|
+
groupId: projectId,
|
|
30
|
+
awsIAMType: "NONE",
|
|
31
|
+
databaseName: "admin",
|
|
32
|
+
ldapAuthType: "NONE",
|
|
33
|
+
oidcAuthType: "NONE",
|
|
34
|
+
x509Type: "NONE",
|
|
35
|
+
username,
|
|
36
|
+
password,
|
|
37
|
+
roles: roles,
|
|
38
|
+
scopes: clusters?.length
|
|
39
|
+
? clusters.map((cluster) => ({
|
|
40
|
+
type: "CLUSTER",
|
|
41
|
+
name: cluster,
|
|
42
|
+
}))
|
|
43
|
+
: undefined,
|
|
44
|
+
};
|
|
45
|
+
await this.session.apiClient.createDatabaseUser({
|
|
46
|
+
params: {
|
|
47
|
+
path: {
|
|
48
|
+
groupId: projectId,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
body: input,
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
content: [{ type: "text", text: `User "${username}" created sucessfully.` }],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=createDBUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDBUser.js","sourceRoot":"","sources":["../../../src/tools/atlas/createDBUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAAnD;;QACc,SAAI,GAAG,sBAAsB,CAAC;QAC9B,gBAAW,GAAG,uCAAuC,CAAC;QACtD,kBAAa,GAAkB,QAAQ,CAAC;QACxC,cAAS,GAAG;YAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAClD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YAC1D,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YAC1D,KAAK,EAAE,CAAC;iBACH,KAAK,CACF,CAAC,CAAC,MAAM,CAAC;gBACL,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;gBAC1C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;gBACnE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE;aACpE,CAAC,CACL;iBACA,QAAQ,CAAC,wBAAwB,CAAC;YACvC,QAAQ,EAAE,CAAC;iBACN,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;iBACjB,QAAQ,CAAC,wEAAwE,CAAC;iBAClF,QAAQ,EAAE;SAClB,CAAC;IA0CN,CAAC;IAxCa,KAAK,CAAC,OAAO,CAAC,EACpB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,QAAQ,GACsB;QAC9B,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEnC,MAAM,KAAK,GAAG;YACV,OAAO,EAAE,SAAS;YAClB,UAAU,EAAE,MAAM;YAClB,YAAY,EAAE,OAAO;YACrB,YAAY,EAAE,MAAM;YACpB,YAAY,EAAE,MAAM;YACpB,QAAQ,EAAE,MAAM;YAChB,QAAQ;YACR,QAAQ;YACR,KAAK,EAAE,KAAsC;YAC7C,MAAM,EAAE,QAAQ,EAAE,MAAM;gBACpB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;oBACvB,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,OAAO;iBAChB,CAAC,CAAC;gBACL,CAAC,CAAC,SAAS;SACG,CAAC;QAEvB,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC;YAC5C,MAAM,EAAE;gBACJ,IAAI,EAAE;oBACF,OAAO,EAAE,SAAS;iBACrB;aACJ;YACD,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;QAEH,OAAO;YACH,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,QAAQ,wBAAwB,EAAE,CAAC;SAC/E,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
export class CreateFreeClusterTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-create-free-cluster";
|
|
7
|
+
this.description = "Create a free MongoDB Atlas cluster";
|
|
8
|
+
this.operationType = "create";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectId: z.string().describe("Atlas project ID to create the cluster in"),
|
|
11
|
+
name: z.string().describe("Name of the cluster"),
|
|
12
|
+
region: z.string().describe("Region of the cluster").default("US_EAST_1"),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async execute({ projectId, name, region }) {
|
|
16
|
+
this.session.ensureAuthenticated();
|
|
17
|
+
const input = {
|
|
18
|
+
groupId: projectId,
|
|
19
|
+
name,
|
|
20
|
+
clusterType: "REPLICASET",
|
|
21
|
+
replicationSpecs: [
|
|
22
|
+
{
|
|
23
|
+
zoneName: "Zone 1",
|
|
24
|
+
regionConfigs: [
|
|
25
|
+
{
|
|
26
|
+
providerName: "TENANT",
|
|
27
|
+
backingProviderName: "AWS",
|
|
28
|
+
regionName: region,
|
|
29
|
+
electableSpecs: {
|
|
30
|
+
instanceSize: "M0",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
terminationProtectionEnabled: false,
|
|
37
|
+
};
|
|
38
|
+
await this.session.apiClient.createCluster({
|
|
39
|
+
params: {
|
|
40
|
+
path: {
|
|
41
|
+
groupId: projectId,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
body: input,
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
content: [{ type: "text", text: `Cluster "${name}" has been created in region "${region}".` }],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=createFreeCluster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFreeCluster.js","sourceRoot":"","sources":["../../../src/tools/atlas/createFreeCluster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,OAAO,qBAAs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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
export class CreateProjectTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-create-project";
|
|
7
|
+
this.description = "Create a MongoDB Atlas project";
|
|
8
|
+
this.operationType = "create";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectName: z.string().optional().describe("Name for the new project"),
|
|
11
|
+
organizationId: z.string().optional().describe("Organization ID for the new project"),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async execute({ projectName, organizationId }) {
|
|
15
|
+
this.session.ensureAuthenticated();
|
|
16
|
+
let assumedOrg = false;
|
|
17
|
+
if (!projectName) {
|
|
18
|
+
projectName = "Atlas Project";
|
|
19
|
+
}
|
|
20
|
+
if (!organizationId) {
|
|
21
|
+
try {
|
|
22
|
+
const organizations = await this.session.apiClient.listOrganizations();
|
|
23
|
+
if (!organizations?.results?.length) {
|
|
24
|
+
throw new Error("No organizations were found in your MongoDB Atlas account. Please create an organization first.");
|
|
25
|
+
}
|
|
26
|
+
organizationId = organizations.results[0].id;
|
|
27
|
+
assumedOrg = true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error("Could not search for organizations in your MongoDB Atlas account, please provide an organization ID or create one first.");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const input = {
|
|
34
|
+
name: projectName,
|
|
35
|
+
orgId: organizationId,
|
|
36
|
+
};
|
|
37
|
+
const group = await this.session.apiClient.createProject({
|
|
38
|
+
body: input,
|
|
39
|
+
});
|
|
40
|
+
if (!group?.id) {
|
|
41
|
+
throw new Error("Failed to create project");
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
content: [
|
|
45
|
+
{
|
|
46
|
+
type: "text",
|
|
47
|
+
text: `Project "${projectName}" created successfully${assumedOrg ? ` (using organizationId ${organizationId}).` : ""}.`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=createProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProject.js","sourceRoot":"","sources":["../../../src/tools/atlas/createProject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,OAAO,iBAAkB,SAAQ,aAAa;IAApD;;QACc,SAAI,GAAG,sBAAsB,CAAC;QAC9B,gBAAW,GAAG,gCAAgC,CAAC;QAC/C,kBAAa,GAAkB,QAAQ,CAAC;QACxC,cAAS,GAAG;YAClB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;YACvE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;SACxF,CAAC;IAiDN,CAAC;IA/Ca,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,cAAc,EAAmC;QACpF,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QACnC,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,WAAW,GAAG,eAAe,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,IAAI,CAAC;gBACD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC;gBACvE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACX,iGAAiG,CACpG,CAAC;gBACN,CAAC;gBACD,cAAc,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7C,UAAU,GAAG,IAAI,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,IAAI,KAAK,CACX,0HAA0H,CAC7H,CAAC;YACN,CAAC;QACL,CAAC;QAED,MAAM,KAAK,GAAG;YACV,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,cAAc;SACf,CAAC;QAEX,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC;YACrD,IAAI,EAAE,KAAK;SACd,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAChD,CAAC;QAED,OAAO;YACH,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY,WAAW,yBAAyB,UAAU,CAAC,CAAC,CAAC,0BAA0B,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG;iBAC1H;aACJ;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
export class InspectAccessListTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-inspect-access-list";
|
|
7
|
+
this.description = "Inspect Ip/CIDR ranges with access to your MongoDB Atlas clusters.";
|
|
8
|
+
this.operationType = "read";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectId: z.string().describe("Atlas project ID"),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
async execute({ projectId }) {
|
|
14
|
+
this.session.ensureAuthenticated();
|
|
15
|
+
const accessList = await this.session.apiClient.listProjectIpAccessLists({
|
|
16
|
+
params: {
|
|
17
|
+
path: {
|
|
18
|
+
groupId: projectId,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (!accessList?.results?.length) {
|
|
23
|
+
throw new Error("No access list entries found.");
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
text: `IP ADDRESS | CIDR | COMMENT
|
|
30
|
+
------|------|------
|
|
31
|
+
${(accessList.results || [])
|
|
32
|
+
.map((entry) => {
|
|
33
|
+
return `${entry.ipAddress} | ${entry.cidrBlock} | ${entry.comment}`;
|
|
34
|
+
})
|
|
35
|
+
.join("\n")}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=inspectAccessList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectAccessList.js","sourceRoot":"","sources":["../../../src/tools/atlas/inspectAccessList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IAAxD;;QACc,SAAI,GAAG,2BAA2B,CAAC;QACnC,gBAAW,GAAG,oEAAoE,CAAC;QACnF,kBAAa,GAAkB,MAAM,CAAC;QACtC,cAAS,GAAG;YAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;SACrD,CAAC;IAgCN,CAAC;IA9Ba,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAmC;QAClE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEnC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,wBAAwB,CAAC;YACrE,MAAM,EAAE;gBACJ,IAAI,EAAE;oBACF,OAAO,EAAE,SAAS;iBACrB;aACJ;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACrD,CAAC;QAED,OAAO;YACH,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;EAExB,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;yBACvB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;wBACX,OAAO,GAAG,KAAK,CAAC,SAAS,MAAM,KAAK,CAAC,SAAS,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;oBACxE,CAAC,CAAC;yBACD,IAAI,CAAC,IAAI,CAAC,EAAE;iBACA;aACJ;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
export class InspectClusterTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-inspect-cluster";
|
|
7
|
+
this.description = "Inspect MongoDB Atlas cluster";
|
|
8
|
+
this.operationType = "read";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectId: z.string().describe("Atlas project ID"),
|
|
11
|
+
clusterName: z.string().describe("Atlas cluster name"),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async execute({ projectId, clusterName }) {
|
|
15
|
+
this.session.ensureAuthenticated();
|
|
16
|
+
const cluster = await this.session.apiClient.getCluster({
|
|
17
|
+
params: {
|
|
18
|
+
path: {
|
|
19
|
+
groupId: projectId,
|
|
20
|
+
clusterName,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return this.formatOutput(cluster);
|
|
25
|
+
}
|
|
26
|
+
formatOutput(cluster) {
|
|
27
|
+
if (!cluster) {
|
|
28
|
+
throw new Error("Cluster not found");
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: `Cluster Name | State | MongoDB Version | Connection String
|
|
35
|
+
----------------|----------------|----------------|----------------|----------------
|
|
36
|
+
${cluster.name} | ${cluster.stateName} | ${cluster.mongoDBVersion || "N/A"} | ${cluster.connectionStrings?.standard || "N/A"}`,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=inspectCluster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectCluster.js","sourceRoot":"","sources":["../../../src/tools/atlas/inspectCluster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,OAAO,kBAAmB,SAAQ,aAAa;IAArD;;QACc,SAAI,GAAG,uBAAuB,CAAC;QAC/B,gBAAW,GAAG,+BAA+B,CAAC;QAC9C,kBAAa,GAAkB,MAAM,CAAC;QACtC,cAAS,GAAG;YAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YAClD,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;SACzD,CAAC;IAiCN,CAAC;IA/Ba,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,WAAW,EAAmC;QAC/E,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEnC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC;YACpD,MAAM,EAAE;gBACJ,IAAI,EAAE;oBACF,OAAO,EAAE,SAAS;oBAClB,WAAW;iBACd;aACJ;SACJ,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAEO,YAAY,CAAC,OAAoC;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACzC,CAAC;QAED,OAAO;YACH,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;EAExB,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,SAAS,MAAM,OAAO,CAAC,cAAc,IAAI,KAAK,MAAM,OAAO,CAAC,iBAAiB,EAAE,QAAQ,IAAI,KAAK,EAAE;iBAC7G;aACJ;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
export class ListClustersTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-list-clusters";
|
|
7
|
+
this.description = "List MongoDB Atlas clusters";
|
|
8
|
+
this.operationType = "read";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectId: z.string().describe("Atlas project ID to filter clusters").optional(),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
async execute({ projectId }) {
|
|
14
|
+
this.session.ensureAuthenticated();
|
|
15
|
+
if (!projectId) {
|
|
16
|
+
const data = await this.session.apiClient.listClustersForAllProjects();
|
|
17
|
+
return this.formatAllClustersTable(data);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const project = await this.session.apiClient.getProject({
|
|
21
|
+
params: {
|
|
22
|
+
path: {
|
|
23
|
+
groupId: projectId,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (!project?.id) {
|
|
28
|
+
throw new Error(`Project with ID "${projectId}" not found.`);
|
|
29
|
+
}
|
|
30
|
+
const data = await this.session.apiClient.listClusters({
|
|
31
|
+
params: {
|
|
32
|
+
path: {
|
|
33
|
+
groupId: project.id || "",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return this.formatClustersTable(project, data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
formatAllClustersTable(clusters) {
|
|
41
|
+
if (!clusters?.results?.length) {
|
|
42
|
+
throw new Error("No clusters found.");
|
|
43
|
+
}
|
|
44
|
+
const formattedClusters = clusters.results
|
|
45
|
+
.map((result) => {
|
|
46
|
+
return (result.clusters || []).map((cluster) => {
|
|
47
|
+
return { ...result, ...cluster, clusters: undefined };
|
|
48
|
+
});
|
|
49
|
+
})
|
|
50
|
+
.flat();
|
|
51
|
+
if (!formattedClusters.length) {
|
|
52
|
+
throw new Error("No clusters found.");
|
|
53
|
+
}
|
|
54
|
+
const rows = formattedClusters
|
|
55
|
+
.map((cluster) => {
|
|
56
|
+
return `${cluster.groupName} (${cluster.groupId}) | ${cluster.name}`;
|
|
57
|
+
})
|
|
58
|
+
.join("\n");
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
text: `Project | Cluster Name
|
|
64
|
+
----------------|----------------
|
|
65
|
+
${rows}`,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
formatClustersTable(project, clusters) {
|
|
71
|
+
if (!clusters?.results?.length) {
|
|
72
|
+
throw new Error("No clusters found.");
|
|
73
|
+
}
|
|
74
|
+
const rows = clusters.results
|
|
75
|
+
.map((cluster) => {
|
|
76
|
+
const connectionString = cluster.connectionStrings?.standard || "N/A";
|
|
77
|
+
const mongoDBVersion = cluster.mongoDBVersion || "N/A";
|
|
78
|
+
return `${cluster.name} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
|
|
79
|
+
})
|
|
80
|
+
.join("\n");
|
|
81
|
+
return {
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: `Here are your MongoDB Atlas clusters in project "${project.name}" (${project.id}):`,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: "text",
|
|
89
|
+
text: `Cluster Name | State | MongoDB Version | Connection String
|
|
90
|
+
----------------|----------------|----------------|----------------|----------------
|
|
91
|
+
${rows}`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=listClusters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listClusters.js","sourceRoot":"","sources":["../../../src/tools/atlas/listClusters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAAnD;;QACc,SAAI,GAAG,qBAAqB,CAAC;QAC7B,gBAAW,GAAG,6BAA6B,CAAC;QAC5C,kBAAa,GAAkB,MAAM,CAAC;QACtC,cAAS,GAAG;YAClB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC,CAAC,QAAQ,EAAE;SACnF,CAAC;IA2FN,CAAC;IAzFa,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAmC;QAClE,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEnC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,0BAA0B,EAAE,CAAC;YAEvE,OAAO,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,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C,SAAS,KAAK,OAAO,CAAC,OAAO,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;QACzE,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO;YACH,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;EAExB,IAAI,EAAE;iBACS;aACJ;SACJ,CAAC;IACN,CAAC;IAEO,mBAAmB,CAAC,OAAc,EAAE,QAA8C;QACtF,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC1C,CAAC;QACD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO;aACxB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACb,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,EAAE,QAAQ,IAAI,KAAK,CAAC;YACtE,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC;YACvD,OAAO,GAAG,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,SAAS,MAAM,cAAc,MAAM,gBAAgB,EAAE,CAAC;QAC9F,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO;YACH,OAAO,EAAE;gBACL;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,oDAAoD,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,EAAE,IAAI;iBAC7F;gBACD;oBACI,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;EAExB,IAAI,EAAE;iBACS;aACJ;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
3
|
+
export class ListDBUsersTool extends AtlasToolBase {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.name = "atlas-list-db-users";
|
|
7
|
+
this.description = "List MongoDB Atlas database users";
|
|
8
|
+
this.operationType = "read";
|
|
9
|
+
this.argsShape = {
|
|
10
|
+
projectId: z.string().describe("Atlas project ID to filter DB users"),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
async execute({ projectId }) {
|
|
14
|
+
this.session.ensureAuthenticated();
|
|
15
|
+
const data = await this.session.apiClient.listDatabaseUsers({
|
|
16
|
+
params: {
|
|
17
|
+
path: {
|
|
18
|
+
groupId: projectId,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (!data?.results?.length) {
|
|
23
|
+
throw new Error("No database users found.");
|
|
24
|
+
}
|
|
25
|
+
const output = `Username | Roles | Scopes
|
|
26
|
+
----------------|----------------|----------------
|
|
27
|
+
` +
|
|
28
|
+
data.results
|
|
29
|
+
.map((user) => {
|
|
30
|
+
return `${user.username} | ${formatRoles(user.roles)} | ${formatScopes(user.scopes)}`;
|
|
31
|
+
})
|
|
32
|
+
.join("\n");
|
|
33
|
+
return {
|
|
34
|
+
content: [{ type: "text", text: output }],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function formatRoles(roles) {
|
|
39
|
+
if (!roles?.length) {
|
|
40
|
+
return "N/A";
|
|
41
|
+
}
|
|
42
|
+
return roles
|
|
43
|
+
.map((role) => `${role.roleName}${role.databaseName ? `@${role.databaseName}${role.collectionName ? `:${role.collectionName}` : ""}` : ""}`)
|
|
44
|
+
.join(", ");
|
|
45
|
+
}
|
|
46
|
+
function formatScopes(scopes) {
|
|
47
|
+
if (!scopes?.length) {
|
|
48
|
+
return "All";
|
|
49
|
+
}
|
|
50
|
+
return scopes.map((scope) => `${scope.type}:${scope.name}`).join(", ");
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=listDBUsers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listDBUsers.js","sourceRoot":"","sources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CAAC,KAA0B;IAC3C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,KAAK;SACP,GAAG,CACA,CAAC,IAAI,EAAE,EAAE,CACL,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACnI;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,YAAY,CAAC,MAAoB;IACtC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AtlasToolBase } from "./atlasTool.js";
|
|
2
|
+
export class ListOrganizationsTool extends AtlasToolBase {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.name = "atlas-list-orgs";
|
|
6
|
+
this.description = "List MongoDB Atlas organizations";
|
|
7
|
+
this.operationType = "read";
|
|
8
|
+
this.argsShape = {};
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
this.session.ensureAuthenticated();
|
|
12
|
+
const data = await this.session.apiClient.listOrganizations();
|
|
13
|
+
if (!data?.results?.length) {
|
|
14
|
+
throw new Error("No projects found in your MongoDB Atlas account.");
|
|
15
|
+
}
|
|
16
|
+
// Format projects as a table
|
|
17
|
+
const output = `Organization Name | Organization ID
|
|
18
|
+
----------------| ----------------
|
|
19
|
+
` +
|
|
20
|
+
data.results
|
|
21
|
+
.map((org) => {
|
|
22
|
+
return `${org.name} | ${org.id}`;
|
|
23
|
+
})
|
|
24
|
+
.join("\n");
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: output }],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=listOrgs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listOrgs.js","sourceRoot":"","sources":["../../../src/tools/atlas/listOrgs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IAAxD;;QACc,SAAI,GAAG,iBAAiB,CAAC;QACzB,gBAAW,GAAG,kCAAkC,CAAC;QACjD,kBAAa,GAAkB,MAAM,CAAC;QACtC,cAAS,GAAG,EAAE,CAAC;IAyB7B,CAAC;IAvBa,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAEnC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC;QAE9D,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACxE,CAAC;QAED,6BAA6B;QAC7B,MAAM,MAAM,GACR;;CAEX;YACW,IAAI,CAAC,OAAO;iBACP,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBACT,OAAO,GAAG,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC;YACrC,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO;YACH,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SAC5C,CAAC;IACN,CAAC;CACJ"}
|