Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mcp): expose provider account usage limits #36478

Closedbrockklein(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/36478/headopened View on GitHub

Note

Written by gpt-6.1-sol on behalf of Brock

Problem

Agents can discover providers with orchestrator_capabilities, but cannot read the account limits already shown by Usage → Limits and /usage-limits. This blocks checking remaining session/weekly allowance and reset times before choosing a provider.

Change

Add the read-only orchestrator_usage_limits MCP tool, including linked-environment routing and clients without a thread. Reuse collectProviderUsageLimits to deduplicate native instances and CLI Proxy accounts. Return used/remaining percentages, reset times, original snapshot timestamps and unavailable reasons; omit disabled instances, credential fingerprints, raw diagnostic messages and reset-credit redemption handles. Signed-out instances cannot expose cached quota windows.

Register Claude's read-only query allowlist and client activity summaries, add a tool-selection eval case, and update the measured tool-list budget from 49,806 to 50,066 bytes (+260). A maintainer must apply agent-context-increase for the intentional context growth.

This reads published snapshots, as the UI does; it adds no poller or synchronous provider refresh. The original checkedAt is preserved so callers can assess reading age, including retained readings after failed refreshes and asynchronous Antigravity updates.

Scope

Closes #28202. Fresh implementation from current main following the maintainer's request to open a replacement.

Credits: @ryoppippi's #28212 supplied the account-aggregation design, privacy projection, eval case and presentation work; @dymoo's #31644 and its subsequent reviews informed signed-out-provider handling, read-only access and snapshot-freshness limits. Both earlier PRs are closed; this is their focused replacement.

Verification

  • vp run check:changed: format, lint, both knip checks, GraphQL generation, typechecks of 37 affected packages, and 513 tests in nine files passed.
  • Focused coverage exercises native/proxy account deduplication, disabled and signed-out instances, preserved timestamps, secret/redemption-handle omission, orchestration scope, forward-compatible window decoding, activity summaries, and Claude's read-only registration.
  • mcp-tool-use --case report-all-provider-usage-limits --dry-run constructs successfully. A one-sample model run was attempted but could not start because ANTHROPIC_API_KEY is absent. Paid model evaluation and real-provider/linked-machine calls remain unverified.
  • git diff --check passed. No installed app or live T3 data was modified.

🤖 Generated with Codex via T3 Code

    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented
      Codex Review Summary: ✅ Completed

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-11-14T01:54:02.026952Z797d907PR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    2. tanstack-source added labelsfeature

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    4. Approvability

      Verdict: Approved at 797d907

      Macroscope's review found this PR approvable — Adds a read-only MCP tool for provider usage percentages and reset times, including linked environments. It uses existing snapshots and capability checks while excluding credential fingerprints, redemption handles and raw provider errors.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Note

      Written by Claude Opus 5.5 on behalf of Brock

      Closing this myself. On rereading CONTRIBUTING.md: outside contributors should not open feature PRs, and this one is a feature. Sorry for the noise. I have added our use case to #15137 instead.

    6. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 797d907293

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -7,3 +7,8 @@
      77 }
      88
      99 describe("summarizeT3ToolCalls", () => {
      10+ it("labels completed and failed provider usage reads", () => {
      11+ expect(summarizeT3ToolCalls("usage-limits", [completed({})])).toEqual({
      12+ label: "Read provider usage limits 1 time",
      13+ failedCount: 0,
      14+ });

      P1 Badge Remove the copy-only usage-summary test

      This case pins the literal wording of the new switch arm rather than exercising new behavior; shared { isError: true } failure accounting is already covered by the existing “excludes failed and unfinished sends” case. The Verifying guidance in AGENTS.md explicitly excludes copy-text and trivial-logic tests. Delete this new it to avoid adding wording-sensitive maintenance without additional behavioral coverage.

      AGENTS.md reference: AGENTS.md:L106-L106

      Useful? React with 👍 / 👎.

      @@ -242,3 +250,10 @@
      242250 return new OrchestratorMcpFailure({ code, message });
      243251 }
      244252
      253+// Keep account fingerprints, provider messages, and redemption handles off the MCP response.
      254+function publicUsageLimits(
      255+ limits: ServerProviderUsageLimits,
      256+): OrchestratorMcpUsageLimitsResult["providers"][number]["limits"] {
      257+ return {
      258+ checkedAt: limits.checkedAt,
      259+ windows: limits.windows.map((window) => ({

      P2 Badge Preserve Claude's zero-dollar cap in the public snapshot

      When Claude reports enabled extra usage with monthly_limit: 0 and no percentage windows, claudeUsageResponseToLimits deliberately emits { windows: [], zeroSpendCap: true }. This projection drops the only cap signal, so the new tool instead reports “no usage limits reported yet.” An agent cannot distinguish a confirmed $0 extra-usage budget from a missing snapshot. Preserve the safe cap flag in the public contract and projection, or expose an equivalent explicit notice.

      AGENTS.md reference: AGENTS.md:L71-L71

      Useful? React with 👍 / 👎.

Sign in to join this conversation.