Skip to content

Commit 904d598

Browse files
committed
add create project tool
1 parent 4c92c52 commit 904d598

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/tools/atlas/createProject.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { z } from "zod";
2+
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3+
import { AtlasToolBase } from "./atlasTool.js";
4+
import { ToolArgs, OperationType } from "../tool.js";
5+
import { Group } from "../../common/atlas/openapi.js";
6+
7+
export class CreateProjectTool extends AtlasToolBase {
8+
protected name = "atlas-create-project";
9+
protected description = "Create a MongoDB Atlas project";
10+
protected operationType: OperationType = "create";
11+
protected argsShape = {
12+
projectName: z.string().describe("Name for the new project"),
13+
organizationId: z.string().describe("Organization ID for the new project"),
14+
};
15+
16+
protected async execute({
17+
projectName,
18+
organizationId,
19+
}: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
20+
this.session.ensureAuthenticated();
21+
22+
const input = {
23+
name: projectName,
24+
orgId: organizationId,
25+
} as Group;
26+
27+
await this.session.apiClient.createProject({
28+
body: input,
29+
});
30+
31+
return {
32+
content: [{ type: "text", text: `Project "${projectName}" created successfully.` }],
33+
};
34+
}
35+
}

src/tools/atlas/tools.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { CreateAccessListTool } from "./createAccessList.js";
66
import { InspectAccessListTool } from "./inspectAccessList.js";
77
import { ListDBUsersTool } from "./listDBUsers.js";
88
import { CreateDBUserTool } from "./createDBUser.js";
9+
import { CreateProjectTool } from "./createProject.js";
910

1011
export const AtlasTools = [
1112
ListClustersTool,
@@ -16,4 +17,5 @@ export const AtlasTools = [
1617
InspectAccessListTool,
1718
ListDBUsersTool,
1819
CreateDBUserTool,
20+
CreateProjectTool,
1921
];

0 commit comments

Comments
 (0)