Update dbtools-mcp-server.py #14
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Original Issue:
The functions utilize the OCI SDK's list_compartments method without pagination, which by default returns only the first 100 results. In tenancies with thousands of compartments, the current implementation may return an error:
This occurs because the user’s compartment is not included in the initial 100 results retrieved (due to lack of pagination). Note: the list is sorted alphabetically by name.
Proposed Fix 1:
Implement pagination in the
list_compartmentscall by incorporating thepageandlimitparameters and handling thenext_pagetoken to fetch all pages of results. This ensures all compartments are retrieved while preserving the current behavior oflist_all_compartments. The existingget_compartment_by_namefunction remains in use, but now validates results only after retrieving all compartments. This maintains backward compatibility while ensuring accuracy.Proposed Fix 2:
Introduce an alternative implementation for
get_compartment_by_name(seeget_compartment_by_name_v2). The existing function remains in use, but this new version provides a new approach for retrieving compartments by name.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
To reproduce this issue, ensure the tenancy contains more than 100 compartments. Alternatively, simulate the scenario using the
limitparameter and settingonly_one_pageto restrict results to a single page.I have tested using MCP Inspector
For V2:
I updated the get_compartment_by_name_tool function in the test environment to use the new
get_compartment_by_name_v2.Checklist: