Skip to content

Commit 4ddaebb

Browse files
authored
Merge branch 'main' into ni/http-tweaks
2 parents 8b2e7c7 + b5e2204 commit 4ddaebb

File tree

9 files changed

+166
-141
lines changed

9 files changed

+166
-141
lines changed

package-lock.json

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

src/tools/atlas/connect/connectCluster.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export class ConnectClusterTool extends AtlasToolBase {
9393
oidcAuthType: "NONE",
9494
x509Type: "NONE",
9595
deleteAfterDate: expiryDate.toISOString(),
96-
description: "This temporary user is created by the MongoDB MCP Server to connect to the cluster.",
96+
description:
97+
"MDB MCP Temporary user, see https://dochub.mongodb.org/core/mongodb-mcp-server-tools-considerations",
9798
},
9899
});
99100

tests/accuracy/export.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describeAccuracyTests([
1010
parameters: {
1111
database: "mflix",
1212
collection: "movies",
13+
exportTitle: Matcher.string(),
1314
exportTarget: [
1415
{
1516
name: "find",
@@ -28,6 +29,7 @@ describeAccuracyTests([
2829
parameters: {
2930
database: "mflix",
3031
collection: "movies",
32+
exportTitle: Matcher.string(),
3133
exportTarget: [
3234
{
3335
name: "find",
@@ -50,6 +52,7 @@ describeAccuracyTests([
5052
parameters: {
5153
database: "mflix",
5254
collection: "movies",
55+
exportTitle: Matcher.string(),
5356
exportTarget: [
5457
{
5558
name: "find",
@@ -77,6 +80,7 @@ describeAccuracyTests([
7780
parameters: {
7881
database: "mflix",
7982
collection: "movies",
83+
exportTitle: Matcher.string(),
8084
exportTarget: [
8185
{
8286
name: "find",

tests/integration/common/connectionManager.oidc.test.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,28 @@ describe.skipIf(process.platform !== "linux")("ConnectionManager OIDC Tests", as
168168
};
169169
};
170170

171-
const status: ConnectionStatus = await vi.waitFor(async () => {
172-
const result: ConnectionStatus = (await state.serviceProvider.runCommand("admin", {
173-
connectionStatus: 1,
174-
})) as unknown as ConnectionStatus;
175-
176-
if (!result) {
177-
throw new Error("Status can not be undefined. Retrying.");
178-
}
179-
180-
return result;
181-
});
171+
const status: ConnectionStatus = await vi.waitFor(
172+
async () => {
173+
const result = (await state.serviceProvider.runCommand("admin", {
174+
connectionStatus: 1,
175+
})) as unknown as ConnectionStatus | undefined;
176+
177+
if (!result) {
178+
throw new Error("Status can not be undefined. Retrying.");
179+
}
180+
181+
if (!result.authInfo.authenticatedUsers.length) {
182+
throw new Error("No authenticated users found. Retrying.");
183+
}
184+
185+
if (!result.authInfo.authenticatedUserRoles.length) {
186+
throw new Error("No authenticated user roles found. Retrying.");
187+
}
188+
189+
return result;
190+
},
191+
{ timeout: 5000 }
192+
);
182193

183194
expect(status.authInfo.authenticatedUsers[0]).toEqual({
184195
user: "dev/testuser",

tests/integration/tools/atlas/accessLists.test.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,18 @@ describeWithAtlas("ip access lists", (integration) => {
2727
const apiClient = integration.mcpServer().session.apiClient;
2828

2929
const projectId = getProjectId();
30-
31-
for (const value of values) {
32-
await apiClient.deleteProjectIpAccessList({
33-
params: {
34-
path: {
35-
groupId: projectId,
36-
entryValue: value,
30+
if (projectId) {
31+
// projectId may be empty if beforeAll failed.
32+
for (const value of values) {
33+
await apiClient.deleteProjectIpAccessList({
34+
params: {
35+
path: {
36+
groupId: projectId,
37+
entryValue: value,
38+
},
3739
},
38-
},
39-
});
40+
});
41+
}
4042
}
4143
});
4244

tests/integration/tools/atlas/atlasHelpers.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio
4141

4242
try {
4343
const group = await createProject(apiClient);
44-
projectId = group.id || "";
44+
projectId = group.id;
4545
} catch (error) {
4646
console.error("Failed to create project:", error);
4747
throw error;
@@ -50,14 +50,16 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio
5050

5151
afterAll(async () => {
5252
const apiClient = integration.mcpServer().session.apiClient;
53-
54-
await apiClient.deleteProject({
55-
params: {
56-
path: {
57-
groupId: projectId,
53+
if (projectId) {
54+
// projectId may be empty if beforeAll failed.
55+
await apiClient.deleteProject({
56+
params: {
57+
path: {
58+
groupId: projectId,
59+
},
5860
},
59-
},
60-
});
61+
});
62+
}
6163
});
6264

6365
const args = {
@@ -90,7 +92,7 @@ export function parseTable(text: string): Record<string, string>[] {
9092

9193
export const randomId = new ObjectId().toString();
9294

93-
async function createProject(apiClient: ApiClient): Promise<Group> {
95+
async function createProject(apiClient: ApiClient): Promise<Group & Required<Pick<Group, "id">>> {
9496
const projectName: string = `testProj-` + randomId;
9597

9698
const orgs = await apiClient.listOrganizations();
@@ -109,5 +111,5 @@ async function createProject(apiClient: ApiClient): Promise<Group> {
109111
throw new Error("Failed to create project");
110112
}
111113

112-
return group;
114+
return group as Group & Required<Pick<Group, "id">>;
113115
}

tests/integration/tools/atlas/clusters.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ describeWithAtlas("clusters", (integration) => {
6262

6363
afterAll(async () => {
6464
const projectId = getProjectId();
65-
66-
const session: Session = integration.mcpServer().session;
67-
68-
await deleteAndWaitCluster(session, projectId, clusterName);
65+
if (projectId) {
66+
const session: Session = integration.mcpServer().session;
67+
await deleteAndWaitCluster(session, projectId, clusterName);
68+
}
6969
});
7070

7171
describe("atlas-create-free-cluster", () => {

tests/integration/tools/atlas/dbUsers.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ describeWithAtlas("db users", (integration) => {
2828
};
2929

3030
afterEach(async () => {
31+
const projectId = getProjectId();
32+
if (!projectId) {
33+
// projectId may be empty if beforeAll failed
34+
return;
35+
}
36+
3137
try {
3238
await integration.mcpServer().session.apiClient.deleteDatabaseUser({
3339
params: {
3440
path: {
35-
groupId: getProjectId(),
41+
groupId: projectId,
3642
username: userName,
3743
databaseName: "admin",
3844
},

tests/integration/tools/atlas/orgs.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ describeWithAtlas("orgs", (integration) => {
1313
it("returns org names", async () => {
1414
const response = await integration.mcpClient().callTool({ name: "atlas-list-orgs", arguments: {} });
1515
const elements = getResponseElements(response);
16-
expect(elements).toHaveLength(2);
1716
expect(elements[0]?.text).toContain("Found 1 organizations");
1817
expect(elements[1]?.text).toContain("<untrusted-user-data-");
1918
const data = parseTable(getDataFromUntrustedContent(elements[1]?.text ?? ""));

0 commit comments

Comments
 (0)