From 67895cd8d55cde59899964f936c663ce75edb52b Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 29 Aug 2025 16:31:22 +0100 Subject: [PATCH 1/4] fix: add ipAccessList after creating project --- tests/integration/tools/atlas/atlasHelpers.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/integration/tools/atlas/atlasHelpers.ts b/tests/integration/tools/atlas/atlasHelpers.ts index 38a69291d..d3f09c467 100644 --- a/tests/integration/tools/atlas/atlasHelpers.ts +++ b/tests/integration/tools/atlas/atlasHelpers.ts @@ -42,6 +42,23 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio try { const group = await createProject(apiClient); projectId = group.id; + + // add current IP to project access list + const { currentIpv4Address } = await apiClient.getIpInfo(); + await apiClient.createProjectIpAccessList({ + params: { + path: { + groupId: projectId, + }, + }, + body: [ + { + ipAddress: currentIpv4Address, + groupId: projectId, + comment: "Added by MongoDB MCP Server to enable tool access", + }, + ], + }); } catch (error) { console.error("Failed to create project:", error); throw error; From eecdf163a51a8a0232be53a0d8917c164a4fa1d5 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 29 Aug 2025 16:50:52 +0100 Subject: [PATCH 2/4] update --- tests/integration/helpers.ts | 2 +- tests/integration/tools/atlas/atlasHelpers.ts | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/integration/helpers.ts b/tests/integration/helpers.ts index e4913f6de..4ad07c83c 100644 --- a/tests/integration/helpers.ts +++ b/tests/integration/helpers.ts @@ -84,7 +84,7 @@ export function setupIntegrationTest( }); // Mock hasValidAccessToken for tests - if (userConfig.apiClientId && userConfig.apiClientSecret) { + if (!userConfig.apiClientId && !userConfig.apiClientSecret) { const mockFn = vi.fn().mockResolvedValue(true); session.apiClient.validateAccessToken = mockFn; } diff --git a/tests/integration/tools/atlas/atlasHelpers.ts b/tests/integration/tools/atlas/atlasHelpers.ts index d3f09c467..e5e766963 100644 --- a/tests/integration/tools/atlas/atlasHelpers.ts +++ b/tests/integration/tools/atlas/atlasHelpers.ts @@ -42,23 +42,6 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio try { const group = await createProject(apiClient); projectId = group.id; - - // add current IP to project access list - const { currentIpv4Address } = await apiClient.getIpInfo(); - await apiClient.createProjectIpAccessList({ - params: { - path: { - groupId: projectId, - }, - }, - body: [ - { - ipAddress: currentIpv4Address, - groupId: projectId, - comment: "Added by MongoDB MCP Server to enable tool access", - }, - ], - }); } catch (error) { console.error("Failed to create project:", error); throw error; @@ -128,5 +111,22 @@ async function createProject(apiClient: ApiClient): Promise>; } From ba858d088611c8a037fb1c3ef6d97508dabd2f09 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 29 Aug 2025 17:33:22 +0100 Subject: [PATCH 3/4] update to cloud-dev --- tests/integration/tools/atlas/atlasHelpers.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/tools/atlas/atlasHelpers.ts b/tests/integration/tools/atlas/atlasHelpers.ts index e5e766963..7de5966f6 100644 --- a/tests/integration/tools/atlas/atlasHelpers.ts +++ b/tests/integration/tools/atlas/atlasHelpers.ts @@ -19,6 +19,7 @@ export function describeWithAtlas(name: string, fn: IntegrationTestFunction): vo ...defaultTestConfig, apiClientId: process.env.MDB_MCP_API_CLIENT_ID, apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET, + apiBaseUrl: process.env.MDB_MCP_API_BASE_URL ?? "https://cloud-dev.mongodb.com", }), () => defaultDriverOptions ); @@ -39,6 +40,13 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio beforeAll(async () => { const apiClient = integration.mcpServer().session.apiClient; + // check that it has credentials + if (!apiClient.hasCredentials()) { + throw new Error("No credentials available"); + } + + // validate access token + await apiClient.validateAccessToken(); try { const group = await createProject(apiClient); projectId = group.id; From 8119811fd6946d548409f3bee24cec8b84dc0db6 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Fri, 29 Aug 2025 17:44:46 +0100 Subject: [PATCH 4/4] atlas tests run only atlas tests --- .github/workflows/code_health.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_health.yaml b/.github/workflows/code_health.yaml index 9a0b87dd9..9b79cba0d 100644 --- a/.github/workflows/code_health.yaml +++ b/.github/workflows/code_health.yaml @@ -54,7 +54,7 @@ jobs: MDB_MCP_API_CLIENT_ID: ${{ secrets.TEST_ATLAS_CLIENT_ID }} MDB_MCP_API_CLIENT_SECRET: ${{ secrets.TEST_ATLAS_CLIENT_SECRET }} MDB_MCP_API_BASE_URL: ${{ vars.TEST_ATLAS_BASE_URL }} - run: npm test -- --exclude "tests/unit/**" --exclude "tests/integration/tools/mongodb/**" --exclude "tests/integration/*.ts" + run: npm test -- tests/integration/tools/atlas - name: Upload test results uses: actions/upload-artifact@v4 if: always()