feat: implement debugger tool logic COMPASS-10826 - #8340
Conversation
There was a problem hiding this comment.
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 byAtlasAdminApiService(cluster state + project access list retrieval). - Wires
atlasServiceintoToolsControllerand the React provider so the debugger tool can use Atlas service capabilities. - Updates the assistant eval harness to construct
ToolsControllerwith 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()trimsuserIpintouserIP, but then comparesipAddressagainst the untrimmeduserIp. This will incorrectly return false whenuserIphas leading/trailing whitespace.
const userIP = userIp.trim();
return ipAccessList.some(
({ ipAddress }) => ipAddress && ipAddress === userIp
);
packages/compass-generative-ai/src/tools/debug-connection.ts:72
ipAccessListis fetched and then only used forconsole.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
ipAccessAllowedis currently hard-coded totrue, and the return path wraps a plain object inawait 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.
68bbcc7 to
199c060
Compare
2b8a0b5 to
1c3cd3e
Compare
| clusterState: 'ready' | 'paused' | 'provisioning' | 'deleted' | 'notFound'; | ||
| ipAccessAllowed: boolean; | ||
| clusterName: string; | ||
| clusterState: string; |
There was a problem hiding this comment.
Would we not be able to calculate the state from the previous states?
There was a problem hiding this comment.
I was confused what you mean by previous states, but I think you mean to specify the type, not derive the value, right?
There was a problem hiding this comment.
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
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
this is never reached right? the not found is returned in the debugConnection directly with if ('clusterNotFound' in clusterInfo)
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
I believe if the cluster is DELETING it also can't accept connections (but not too sure)
| preferences, | ||
| atlasAdminApi, | ||
| authService, | ||
| atlasService, |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
I believe you forgot to update the tests: debugConnection after your changes only has 3 params, you can remove atlasService:
| 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 { |
There was a problem hiding this comment.
nit: the names are slightly confusing here
| function isAddressEqual(ipAddress: string, address: string): boolean { | |
| function isAddressEqual(allowedIp: string, userIp: string): boolean { |
or if you prefer more generic
| function isAddressEqual(ipAddress: string, address: string): boolean { | |
| function isAddressEqual(expected: string, actual: string): boolean { |
There was a problem hiding this comment.
thanks, I knew they were confusing but I was too tired to come up with something better 😅
| }); | ||
| } | ||
|
|
||
| function isAddressInCidrRange(cidrNotation: string, address: string): boolean { |
There was a problem hiding this comment.
nit: I'd change these params as well:
| function isAddressInCidrRange(cidrNotation: string, address: string): boolean { | |
| function isAddressInCidrRange(allowedCidr: string, userIp: string): boolean { |
| }; | ||
| } | ||
| const { projectId, clusterName, clusterState } = clusterInfo; | ||
| console.log({ projectId, clusterName, clusterState }); |
There was a problem hiding this comment.
| console.log({ projectId, clusterName, clusterState }); |
| projectId, | ||
| atlasAdminApi, | ||
| }); | ||
| console.log({ ipAccessAllowed, networkAccessDetails }); |
There was a problem hiding this comment.
| console.log({ ipAccessAllowed, networkAccessDetails }); |
Description
Integrating the debugger tool with the atlas admin api calls.
Known gaps (to be added as follow ups):
Note:
ipaddr.jswas chosen because mms uses the same one AND it was already included in Compass as a subdependencyScreenshots
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes