-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Alerts Listing #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Alerts Listing #230
Conversation
b5f652a
to
f1b1de8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error("No alerts found in your MongoDB Atlas project."); | ||
} | ||
|
||
// Format alerts as a table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] I know that this is how we've returned results in Atlas, but in my experience, the models rarely render the response 1:1, so the extra effort we're going through to get a markdown table is not really useful for users. This was not something we wanted to spend too much time on, but now that we're post-public-preview, we can explore if alternative response shapes perform similarly and if so - perhaps, choose a more natural way to represent things (e.g. json).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We should support output types like atlas CLI does.
Specifically for non chatbot use cases like copilot everyone wants output to consume least tokens possible - JSON/YAML
src/tools/atlas/read/listAlerts.ts
Outdated
}); | ||
|
||
if (!data?.results?.length) { | ||
throw new Error("No alerts found in your MongoDB Atlas project."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like a real error though - if a user legitimately may end up in a situation with no Atlas alerts, we should return a graceful response informing them rather than an error (the model will sometimes treat errors as an indication that something is wrong and attempt to correct itself).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a broad issue in our Atlas tools, we follow this pattern and probably should change everywhere. Agree it's not an error unless I'm missing something @fmenezes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be your preference? Empty table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to present useful information to user.
There was a problem hiding this comment.
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 a new tool to list MongoDB Atlas alerts in a tabular format with API integration and corresponding integration tests.
- Implements the ListAlertsTool and its API call for retrieving alerts.
- Updates integration tests to verify tool metadata and output table structure.
- Adjusts tool registry and OpenAPI filtering to include alerts.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/integration/tools/atlas/alerts.test.ts | Adds integration tests for verifying alerts tool metadata and output format |
src/tools/atlas/tools.ts | Updates the list of available Atlas tools to include ListAlertsTool |
src/tools/atlas/read/listAlerts.ts | Implements the new ListAlertsTool and table formatting logic for alerts |
src/common/atlas/apiClient.ts | Introduces the listAlerts API client method |
scripts/filter.ts | Adds "listAlerts" to the OpenAPI filter list |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add MongoDB Atlas Alerts List Tool
This PR adds a new tool to list alerts from MongoDB Atlas projects. The tool provides a tabular view of alerts with their status, creation time, and other relevant details.
Changes
ListAlertsTool
class to handle listing alerts from Atlas projectslistAlerts
method to the Atlas API clientTesting
The changes include integration tests that verify:
Example Usage
The tool returns alerts in a table format with the following columns:
API Reference
The tool uses the MongoDB Atlas API endpoint:
https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/alerts
Docs:
https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Access-Tracking/operation/listAccessLogsByHostname
Related Issues
#216
Checklist
Tests
Test Suites: 6 skipped, 26 passed, 26 of 32 total
Tests: 26 skipped, 284 passed, 310 total
Snapshots: 0 total
Time: 12.155 s
Ran all test suites.