Skip to content

test: add unit + integration test setup for mongodb-mcp-remote MCP-538#1268

Open
maastha wants to merge 9 commits into
mainfrom
MCP-538
Open

test: add unit + integration test setup for mongodb-mcp-remote MCP-538#1268
maastha wants to merge 9 commits into
mainfrom
MCP-538

Conversation

@maastha

@maastha maastha commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Sets up the test foundation (MCP-538) for the new mongodb-mcp-remote wrapper package, on the repo's existing Vitest setup. The wrapper itself (MCP-536) and the test bodies (MCP-539) come later — this PR adds the structure and a working mock.

Proposed changes

  • Adds unit and integration test scaffolding for the wrapper (placeholder it.todo tests, to be filled in by MCP-539).
  • Adds an in-process mock Remote MCP server so the integration tests run the wrapper logic end-to-end. Mirrors cloud-dev behavior (SSE responses, session header), confirmed via MCP-542.
  • Wires the package into the existing tooling (CI test discovery, lint, build, dependency checks) — no new workflow needed.
  • Documents how to run the wrapper's tests.

Ticket: MCP-538

Out of scope: wrapper implementation (MCP-536), test bodies (MCP-539), cloud-dev e2e + CI secrets (separate PR).

Checklist

@maastha maastha changed the title test: Adds unit + integration test setup test: add unit + integration test setup for mongodb-mcp-remote (MCP-538) Jun 21, 2026
@maastha maastha marked this pull request as ready for review June 21, 2026 22:57
@maastha maastha requested a review from a team as a code owner June 21, 2026 22:57
@maastha maastha requested review from Copilot and himanshusinghs and removed request for a team June 21, 2026 22:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds unit + integration test scaffolding for the upcoming mongodb-mcp-remote wrapper package, aligning it with the repo’s existing Vitest/CI tooling and providing an in-process mock remote MCP server for deterministic end-to-end testing.

Changes:

  • Introduces placeholder unit/integration tests plus an in-process mock remote server (token + /mcp endpoints, SSE/JSON response modes).
  • Wires the new package into repo tooling (compile-on-test, Knip entry points, dependency updates).
  • Documents how to run the wrapper package tests.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-lock.yaml Adds new dev dependencies for the wrapper package test scaffolding.
packages/mongodb-mcp-remote/tsconfig.json Excludes src/testHelpers/** from build output to keep test helpers out of dist.
packages/mongodb-mcp-remote/src/wrapper.integration.test.ts Adds integration-test harness + initial mock-remote healthcheck test and it.todo placeholders.
packages/mongodb-mcp-remote/src/tokenManager.test.ts Adds unit-test skeleton for a future token manager with timer cleanup conventions.
packages/mongodb-mcp-remote/src/testHelpers/mockRemote.ts Implements an in-process mock remote MCP server + token endpoint for deterministic integration tests.
packages/mongodb-mcp-remote/package.json Adds pretest compile step and test-time dependencies used by the scaffolding.
knip.json Adds wrapper workspace entry points so dependency checks include tests + helpers.
CONTRIBUTING.md Documents how to run wrapper package tests and what unit vs integration tests do.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread packages/mongodb-mcp-remote/src/wrapper.integration.test.ts
Comment thread packages/mongodb-mcp-remote/src/testHelpers/mockRemote.ts Outdated

@manupedrozo manupedrozo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Instead of using express for mocking the remote server, I would avoid that dependency (even if just for testing) and use Node's http module which should be more than enough.
I created a branch moving to the http module here: c97c24f
WDYT? Feel free to bring those changes over if aligned.

Besides that, scaffolding looks good. Once the core logic is in place I'll adjust the assumptions accordingly.

Comment thread packages/mongodb-mcp-remote/src/tokenManager.test.ts Outdated
Comment thread packages/mongodb-mcp-remote/src/wrapper.integration.test.ts Outdated
@maastha

maastha commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Done, also scoped Mcp-Session-Id to initialize only while at it.

@maastha maastha changed the title test: add unit + integration test setup for mongodb-mcp-remote (MCP-538) test: add unit + integration test setup for mongodb-mcp-remote MCP-538 Jun 24, 2026
@maastha maastha enabled auto-merge (squash) June 25, 2026 13:08
@maastha maastha disabled auto-merge June 25, 2026 14:05
maastha added 5 commits June 25, 2026 10:05
Stand up the wrapper package's offline test tiers, reusing the repo's Vitest
setup (auto-discovered by the existing run-tests CI job, no workflow change):

- Unit scaffold (tokenManager.test.ts) — network-mocked, it.todo for MCP-539.
- Integration harness: an in-process fake remote MCP server
  (src/testHelpers/fakeRemote.ts, excluded from dist) driven via the MCP SDK
  client over a spawned wrapper (WRAPPER_CLI_PATH override); one live sanity
  test plus it.todo scenarios for MCP-539.
- Add @modelcontextprotocol/sdk, express, @types/express devDeps + pretest
  compile so dist/cli.js exists for the harness.
- Document wrapper unit/integration testing in CONTRIBUTING.md.

Builds and runs green without any wrapper logic (cli.ts is still a stub).
…upport SSE+JSON (MCP-538)

- Rename the test double from 'fake' to 'mock' (file, type, function, literals).
- Rewrite comments in plain language; add a reason to the eslint-disable.
- Mock remote now defaults to SSE (matching cloud-dev per MCP-542) with a
  responseMode: 'json' option; notifications return 202.
Replace the ASCII diagram with a short verbal description of how the
integration tests are wired.
- Replace express with node:http in mockRemote.ts
- Scope Mcp-Session-Id header to initialize response only
- Wire transport.close() into client.close() in connectClientToWrapper
- Remove MDB_MCP_REMOTE_URL from test env (derived from base URL internally)
- Remove oauth4webapi scaffolding from tokenManager.test.ts
},
"scripts": {
"compile": "tsc --project tsconfig.json",
"pretest": "pnpm compile",

@gagik gagik Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's correctly setup but vitest shouldn't need typescript compilation so this should hopefully not be necessary.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integration tests spawn dist/cli.js, so compilation is required

@gagik gagik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup seems okay, not a fan of adding dead/commented out code. Can we defer this to an actual PR for adding tests?

import { describe, it, beforeEach, afterEach, vi } from "vitest";

/**
* TODO: every test here is `it.todo` until the token manager exists in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I see much benefit in committing files like this; can we defer this to when these tests actually should be added?

Documentation for tests we're planning to add can be in Jira; we generally commit ready code and avoid commented out or incomplete functions

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also hard to review a helper function without actually seeing how it's used.

Comment on lines +26 to +27
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- not called yet; the it.todo tests below will use it (remove once MCP-539 enables them)
async function connectClientToWrapper(remote: MockRemote): Promise<Client> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar idea, I don't think we should be adding dead code to the codebase, it's too easy for this to end up lost a couple handovers later

"@mongodb-js/devtools-proxy-support": "^0.7.14"
},
"devDependencies": {
"@modelcontextprotocol/sdk": "^1.29.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the tests to use 2.0?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can migrate when working on tests otherwise.

maastha added 3 commits June 25, 2026 10:36
…mote package (MCP-538)

Package was renamed from mongodb-mcp-remote to mongodb-atlas-mcp-remote in main.
Move test files and test helper to match, update knip.json entry and CONTRIBUTING.md references.
…tion (MCP-538)

The rebase conflict resolution left packages/mongodb-atlas-mcp-remote
referencing @modelcontextprotocol/sdk@1.29.0(zod@4.4.3) in the importer
section, but that snapshot was removed and replaced with the @cfworker/json-schema
peer-dep form. pnpm --frozen-lockfile could not resolve the dangling reference,
causing all CI install steps to fail.
This was unintentionally added during the rebase; removing it so that
failures on stable Node versions block the PR as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants