Skip to content

Add maintenance windows and backups tools#22

Open
minuteman3 wants to merge 4 commits intoplanetscale:mainfrom
minuteman3:miles/add-maintenance-and-backups-tools
Open

Add maintenance windows and backups tools#22
minuteman3 wants to merge 4 commits intoplanetscale:mainfrom
minuteman3:miles/add-maintenance-and-backups-tools

Conversation

@minuteman3
Copy link
Copy Markdown
Contributor

Summary

Adds two new tools for operational visibility:

list_maintenance_windows — Lists maintenance schedules for Vitess databases with human-readable formatting (e.g., "every week, Tuesday at 09:00 UTC, 4h window") and optionally fetches recent window history with start/finish times. Flags pending Vitess version updates. Returns a clear error when called against Postgres databases.

list_backups — Lists backup policies (schedule, retention, next run) and optionally fetches recent backup history for a branch with size, duration, and state. Formats sizes as human-readable (e.g., "360.8 TB") and computes backup duration from start/completion timestamps.

Both tools follow the existing inline-fetch pattern with PlanetScaleAPIError for error handling.

API endpoints used

  • GET /v1/organizations/{org}/databases/{db}/maintenance-schedules (docs)
  • GET /v1/organizations/{org}/databases/{db}/maintenance-schedules/{id}/windows (docs)
  • GET /v1/organizations/{org}/databases/{db}/backup-policies (docs)
  • GET /v1/organizations/{org}/databases/{db}/branches/{branch}/backups (docs)

- list_maintenance_windows: Lists maintenance schedules for Vitess databases
  with human-readable formatting (day, time, frequency, duration) and optional
  window history showing start/finish times of past runs
- list_backups: Lists backup policies (schedule, retention, next run) and
  optionally fetches recent backup history with size, duration, and state

Both tools follow the existing inline-fetch pattern and use PlanetScaleAPIError
for error handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
minuteman3 and others added 2 commits April 1, 2026 17:15
- Export apiRequest from planetscale-api.ts and use it in both tools
  instead of duplicated fetchJson helpers
- Export formatBytes from list-cluster-sizes.ts and reuse it in
  list-backups.ts instead of a divergent copy
- Fix inconsistent frequency formatting in list-backups ("every 1 hour"
  → "every hour") to match list-maintenance-windows

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Avoids cross-tool imports — both list-cluster-sizes and list-backups now
import from lib/format.ts instead of one tool importing from the other.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

id: p.id,
name: p.display_name,
target: p.target,
schedule: `${freq} at ${p.schedule_time} UTC`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Backup schedule formatting drops day-of-week information

Medium Severity

formatPolicy builds the schedule string as `${freq} at ${p.schedule_time} UTC` but never uses schedule_day or schedule_week from the BackupPolicy interface. For weekly or monthly policies, this produces incomplete descriptions like "every week at 03:00 UTC" with no indication of which day. The sibling formatSchedule in list-maintenance-windows.ts correctly includes the day name in its schedule string, suggesting this is an oversight.

Additional Locations (1)
Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant