Skip to content

Commit 37e1537

Browse files
committed
Merge branch 'main' into MCP-280
2 parents ed5ec2f + 2a499f4 commit 37e1537

37 files changed

+568
-344
lines changed

package-lock.json

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"fix": "npm run fix:lint && npm run reformat",
5353
"fix:lint": "eslint . --fix",
5454
"reformat": "prettier --write .",
55-
"generate": "./scripts/generate.sh && npm run generate:arguments",
55+
"generate": "npm run generate:api && npm run generate:arguments",
56+
"generate:api": "./scripts/generate.sh",
5657
"generate:arguments": "tsx scripts/generateArguments.ts",
5758
"test": "vitest --project eslint-rules --project unit-and-integration --coverage",
5859
"pretest:accuracy": "npm run build",

scripts/apply.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async function main(): Promise<void> {
3636
path: string;
3737
method: string;
3838
operationId: string;
39+
methodName: string;
3940
requiredParams: boolean;
4041
tag: string;
4142
hasResponseBody: boolean;
@@ -45,7 +46,9 @@ async function main(): Promise<void> {
4546
for (const path in openapi.paths) {
4647
for (const method in openapi.paths[path]) {
4748
// @ts-expect-error This is a workaround for the OpenAPI types
48-
const operation = openapi.paths[path][method] as OpenAPIV3_1.OperationObject;
49+
const operation = openapi.paths[path][method] as OpenAPIV3_1.OperationObject & {
50+
"x-xgen-operation-id-override": string;
51+
};
4952

5053
if (!operation.operationId || !operation.tags?.length) {
5154
continue;
@@ -81,6 +84,7 @@ async function main(): Promise<void> {
8184
operations.push({
8285
path,
8386
method: method.toUpperCase(),
87+
methodName: operation["x-xgen-operation-id-override"] || operation.operationId || "",
8488
operationId: operation.operationId || "",
8589
requiredParams,
8690
hasResponseBody,
@@ -91,9 +95,9 @@ async function main(): Promise<void> {
9195

9296
const operationOutput = operations
9397
.map((operation) => {
94-
const { operationId, method, path, requiredParams, hasResponseBody } = operation;
98+
const { methodName, operationId, method, path, requiredParams, hasResponseBody } = operation;
9599
return `// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
96-
async ${operationId}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
100+
async ${methodName}(options${requiredParams ? "" : "?"}: FetchOptions<operations["${operationId}"]>) {
97101
const { ${hasResponseBody ? `data, ` : ``}error, response } = await this.client.${method}("${path}", options);
98102
if (error) {
99103
throw ApiClientError.fromError(response, error);

scripts/cleanupAtlasTestLeftovers.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function isOlderThanTwoHours(date: string): boolean {
1212
}
1313

1414
async function findTestOrganization(client: ApiClient): Promise<AtlasOrganization> {
15-
const orgs = await client.listOrganizations();
15+
const orgs = await client.listOrgs();
1616
const testOrg = orgs?.results?.find((org) => org.name === "MongoDB MCP Test");
1717

1818
if (!testOrg) {
@@ -23,7 +23,7 @@ async function findTestOrganization(client: ApiClient): Promise<AtlasOrganizatio
2323
}
2424

2525
async function findAllTestProjects(client: ApiClient, orgId: string): Promise<Group[]> {
26-
const projects = await client.listOrganizationProjects({
26+
const projects = await client.getOrgGroups({
2727
params: {
2828
path: {
2929
orgId,
@@ -101,7 +101,7 @@ async function main(): Promise<void> {
101101

102102
// Try to delete the project
103103
try {
104-
await apiClient.deleteProject({
104+
await apiClient.deleteGroup({
105105
params: {
106106
path: {
107107
groupId: project.id,

scripts/filter.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ async function readStdin(): Promise<string> {
1919

2020
function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
2121
const allowedOperations = [
22-
"listProjects",
23-
"listOrganizations",
24-
"getProject",
25-
"createProject",
26-
"deleteProject",
22+
"listGroups",
23+
"listOrgs",
24+
"getGroup",
25+
"createGroup",
26+
"deleteGroup",
2727
"listClusters",
2828
"listFlexClusters",
2929
"getCluster",
@@ -32,28 +32,35 @@ function filterOpenapi(openapi: OpenAPIV3_1.Document): OpenAPIV3_1.Document {
3232
"createFlexCluster",
3333
"deleteCluster",
3434
"deleteFlexCluster",
35-
"listClustersForAllProjects",
35+
"listClusterDetails",
3636
"createDatabaseUser",
3737
"deleteDatabaseUser",
3838
"listDatabaseUsers",
39-
"listProjectIpAccessLists",
40-
"createProjectIpAccessList",
41-
"deleteProjectIpAccessList",
42-
"listOrganizationProjects",
39+
"listAccessListEntries",
40+
"createAccessListEntry",
41+
"deleteAccessListEntry",
42+
"getOrgGroups",
4343
"listAlerts",
44-
"listDropIndexes",
44+
"listDropIndexSuggestions",
4545
"listClusterSuggestedIndexes",
4646
"listSchemaAdvice",
47-
"listSlowQueries",
47+
"listSlowQueryLogs",
4848
];
4949

5050
const filteredPaths = {};
5151

5252
for (const path in openapi.paths) {
5353
const filteredMethods = {} as OpenAPIV3_1.PathItemObject;
54-
for (const method in openapi.paths[path]) {
55-
// @ts-expect-error This is a workaround for the OpenAPI types
56-
if (allowedOperations.includes((openapi.paths[path][method] as { operationId: string }).operationId)) {
54+
// @ts-expect-error This is a workaround for the OpenAPI types
55+
for (const [method, operation] of Object.entries(openapi.paths[path])) {
56+
const op = operation as OpenAPIV3_1.OperationObject & {
57+
"x-xgen-operation-id-override": string;
58+
};
59+
if (
60+
op.operationId &&
61+
(allowedOperations.includes(op.operationId) ||
62+
allowedOperations.includes(op["x-xgen-operation-id-override"]))
63+
) {
5764
// @ts-expect-error This is a workaround for the OpenAPI types
5865
filteredMethods[method] = openapi.paths[path][method] as OpenAPIV3_1.OperationObject;
5966
}

src/common/atlas/accessListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function makeCurrentIpAccessListEntry(
2727
export async function ensureCurrentIpInAccessList(apiClient: ApiClient, projectId: string): Promise<boolean> {
2828
const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
2929
try {
30-
await apiClient.createProjectIpAccessList({
30+
await apiClient.createAccessListEntry({
3131
params: { path: { groupId: projectId } },
3232
body: [entry],
3333
});

0 commit comments

Comments
 (0)