Open
Conversation
Add a new tool that lists per-shard cluster sizes via the v1 public API
endpoint /v1/.../keyspaces/{ks}/custom-shards, providing a service-token
compatible alternative to get_infrastructure's /internal endpoint.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
edcarvio
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why?
The
get_infrastructuretool is the only tool in this codebase that uses the/internalPlanetScale API. The/internalAPI has a more restrictive authentication mechanism than/v1, and failures present as opaque 404s rather than clear auth errors. As a v1 endpoint,custom-shardsuses the same authentication as every other tool in this codebase.The v1 endpoint also has better ergonomics for the shard-sizing use case:
has_overrideflag explicitly marks shards resized from the keyspace default, rather than inferring this from the most common sizeactive_resizeflag per shard, vs only a keyspace-levelresizingbooleanHow?
Adds a new
list_custom_shardstool that calls the v1 endpoint/v1/.../keyspaces/{ks}/custom-shardsto list per-shard cluster sizes. The tool has two modes: a default summary mode that auto-paginates and returns size distribution, override shards, and active resizes; and a raw paginated mode whenpage/per_pageare provided. Tool descriptions onget_infrastructure,get_branch_keyspaces, andlist_resizesare updated to cross-reference the new tool.Decisions
get_infrastructurefor now: The/internalendpoint returns VTGate info and per-tablet AZ placement that no v1 endpoint currently provides. The old tool is retained until we're certain this data is no longer valuable or we find a v1 replacement. The preference is to retire it.Risks
The v1
/custom-shardsendpoint does not provide:If downstream consumers rely on this data, they must continue using
get_infrastructure. The updated tool descriptions steer callers tolist_custom_shardsfor shard sizing and preserveget_infrastructurefor VTGate/AZ detail.Note: The other
/internal-based tool,get_metrics, does not currently have a v1 equivalent — the/v1/.../metricspath returns 404 with both service tokens and OAuth. Migratingget_metricsaway from/internalwill require PlanetScale to expose a v1 metrics endpoint.Implementation Plan
Implementation
Step 1: Add
CustomShardinterface andlistCustomShards()toplanetscale-api.tsNew interface matching the v1 response shape, and a new function using the existing
apiRequesthelper andPaginatedResponse<T>type.Step 2: Create
src/tools/list-custom-shards.tsNew tool following existing patterns (
get-branch-keyspaces.ts,list-resizes.ts).Input: organization, database, branch, keyspace (all required), page/per_page (optional)
Output — two modes:
Step 3: Register in
gram.tsExisting
get_infrastructuretoolLeft unchanged. It still works when OAuth is available and provides VTGate/AZ info that
list_custom_shardsdoesn't.Verification
Generated with Claude Code