Skip to content

feat: implement debugger tool logic COMPASS-10826 - #8340

Open
paula-stacho wants to merge 7 commits into
mainfrom
COMPASS-10826
Open

feat: implement debugger tool logic COMPASS-10826#8340
paula-stacho wants to merge 7 commits into
mainfrom
COMPASS-10826

Conversation

@paula-stacho

@paula-stacho paula-stacho commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Description

Integrating the debugger tool with the atlas admin api calls.

Known gaps (to be added as follow ups):

  • telemetry
  • user's IP address fetching - hardcoded for now, waiting for COMPASS-10994

Note: ipaddr.js was chosen because mms uses the same one AND it was already included in Compass as a subdependency

Screenshots

Screenshot 2026-08-18 at 17 35 57 Screenshot 2026-08-18 at 17 42 10

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

Copilot AI lite review requested due to automatic review settings August 11, 2026 14:59
@github-actions github-actions Bot added the feat label Aug 11, 2026

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

This PR adds initial wiring for an “Atlas connection error debugger” tool in Compass Generative AI, introducing Atlas Admin API calls to derive cluster state diagnostics and plumbing atlasService through the controller/provider layers.

Changes:

  • Implements initial debugConnection() logic backed by AtlasAdminApiService (cluster state + project access list retrieval).
  • Wires atlasService into ToolsController and the React provider so the debugger tool can use Atlas service capabilities.
  • Updates the assistant eval harness to construct ToolsController with the new dependency shape.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/compass-generative-ai/src/tools/debug-connection.ts Adds the connection-debugging tool logic and result mapping.
packages/compass-generative-ai/src/tools-controller.ts Wires atlasService into the tool execution path and tool config.
packages/compass-generative-ai/src/provider.tsx Passes atlasService to ToolsController via provider memoization.
packages/compass-assistant/test/tool-calls.eval.ts Updates eval harness construction of ToolsController.
Suppressed comments (3)

packages/compass-generative-ai/src/tools/debug-connection.ts:47

  • isUserIPIncluded() trims userIp into userIP, but then compares ipAddress against the untrimmed userIp. This will incorrectly return false when userIp has leading/trailing whitespace.
  const userIP = userIp.trim();
  return ipAccessList.some(
    ({ ipAddress }) => ipAddress && ipAddress === userIp
  );

packages/compass-generative-ai/src/tools/debug-connection.ts:72

  • ipAccessList is fetched and then only used for console.log(). This creates unnecessary network load and leaves debug logging in production code.
  const ipAccessList = await atlasAdminApi.getProjectIPAccessList(projectId);
  console.log({ clusterDetails, ipAccessList });
  // TODO: we can't authenticate for this endpoint yet

packages/compass-generative-ai/src/tools/debug-connection.ts:85

  • ipAccessAllowed is currently hard-coded to true, and the return path wraps a plain object in await Promise.resolve(...). This makes the tool report misleading diagnostics and adds unnecessary async noise; until the user IP check is implemented, it should return 'unknown' and return the object directly.
    }),
    ipAccessAllowed: true,
    // ipAccessAllowed: isUserIPIncluded(ipAccessList, userIp),
  });

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/compass-generative-ai/src/tools/debug-connection.ts Outdated
Comment thread packages/compass-generative-ai/src/provider.tsx Outdated
Comment thread packages/compass-generative-ai/src/tools-controller.ts
Comment thread packages/compass-generative-ai/src/tools-controller.ts
Comment thread packages/compass-assistant/test/tool-calls.eval.ts
@paula-stacho paula-stacho added the feature flagged PRs labeled with this label will not be included in the release notes of the next release label Aug 11, 2026
@paula-stacho
paula-stacho marked this pull request as ready for review August 18, 2026 15:46
@paula-stacho
paula-stacho requested a review from a team as a code owner August 18, 2026 15:46
clusterState: 'ready' | 'paused' | 'provisioning' | 'deleted' | 'notFound';
ipAccessAllowed: boolean;
clusterName: string;
clusterState: string;

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.

Would we not be able to calculate the state from the previous states?

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.

I was confused what you mean by previous states, but I think you mean to specify the type, not derive the value, right?

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.

If that's the case - I've thought about this but in the end I chose to not type it strictly as we don't care about most states, and the assistant might be able to interpret even new states that we didn't account for originally. Let me know if you disagree, I'm not feeling too strongly about this

Comment thread packages/compass-generative-ai/src/tools/debug-connection.ts
Comment thread packages/compass-generative-ai/src/tools/debug-connection.ts
Comment on lines +295 to +297
Use to debug a Compass connection failure to an Atlas cluster.
Returns Atlas-side diagnostics (cluster state, IP access list) as well as targeted advice.
Provide the advice to the user

@dudaschar dudaschar Aug 18, 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.

You can make the description more specific if you want to force the agent to provide the url. For example:

This tool provides a debugger helper to identify issues and provide assistance when connecting Compass to an Atlas cluster.

You will have access to Atlas-side diagnostics (cluster state, IP access list) and targeted advice as result when running this tool. 

When advice is provided:
1. Check if that's any url as part of the advice content which the user should follow.
2. Provide the url as part of your response, and a 1-line explanation about what they should to when visiting the url. 

If we have structured output, usually is not necessary to add details about the response, but I don't think would hurt in this case.

@paula-stacho paula-stacho Aug 19, 2026

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.

Good idea, I'll add it. Actually I was surprised that the advice wasn't mentioned until I called it out explicitly, - the assistant only mentioned the fields that were in the tool description. Apparently this model needs more hand-holding.

projectId: string;
clusterName: string;
}): string {
if (clusterState === 'notFound') {

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.

this is never reached right? the not found is returned in the debugConnection directly with if ('clusterNotFound' in clusterInfo)

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.

ah right, I forgot to clean this up after refactor, thanks for noticing!

advice.push(`You can resume it in the Atlas UI: ${clusterOverviewUrl}.`);
}
}
if (clusterState === 'CREATING') {

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 believe if the cluster is DELETING it also can't accept connections (but not too sure)

preferences,
atlasAdminApi,
authService,
atlasService,

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.

you'll need to add atlasService in the ToolsController constructor. I believe you can replace the authService in there as it's not being used

it('returns unknown values when the cluster does not exist or the user has no access to it', async function () {
const api = mockAtlasAdminApi({ projectIdAndClusterName: undefined });

const result = await debugConnection(CONNECTION_STRING, api, atlasService);

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 believe you forgot to update the tests: debugConnection after your changes only has 3 params, you can remove atlasService:

Suggested change
const result = await debugConnection(CONNECTION_STRING, api, atlasService);
const result = await debugConnection(CONNECTION_STRING, api);

in all the tests below as well

}
}

function isAddressEqual(ipAddress: string, address: string): boolean {

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.

nit: the names are slightly confusing here

Suggested change
function isAddressEqual(ipAddress: string, address: string): boolean {
function isAddressEqual(allowedIp: string, userIp: string): boolean {

or if you prefer more generic

Suggested change
function isAddressEqual(ipAddress: string, address: string): boolean {
function isAddressEqual(expected: string, actual: string): boolean {

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.

thanks, I knew they were confusing but I was too tired to come up with something better 😅

});
}

function isAddressInCidrRange(cidrNotation: string, address: string): boolean {

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.

nit: I'd change these params as well:

Suggested change
function isAddressInCidrRange(cidrNotation: string, address: string): boolean {
function isAddressInCidrRange(allowedCidr: string, userIp: string): boolean {

};
}
const { projectId, clusterName, clusterState } = clusterInfo;
console.log({ projectId, clusterName, clusterState });

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.

Suggested change
console.log({ projectId, clusterName, clusterState });

projectId,
atlasAdminApi,
});
console.log({ ipAccessAllowed, networkAccessDetails });

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.

Suggested change
console.log({ ipAccessAllowed, networkAccessDetails });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat feature flagged PRs labeled with this label will not be included in the release notes of the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants