Repository navigation
feat(mcp): expose environment usage summary - #8730
juliusmarminge wants to merge 360 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Warning Your free Security trial is over. An organization admin can activate Security or dismiss this notice. Comment |
Thread transfer impact
This comment will update automatically after the next completed run. |
There was a problem hiding this comment.
Effect service conventions review of the new EnvironmentUsageMcpService and its contract/toolkit wiring. Two import/module-shape findings; the service definition (inline Context.Service interface, Foo["Service"] typing, environment-acquired dependencies, no ManagedRuntime/runPromise, structured Schema.TaggedErrorClass failure with a derived message) otherwise matches the conventions.
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds and pre-approves a new authenticated MCP capability that exposes transcript-derived usage aggregates and can trigger scans and cache refreshes. Its new service, contracts, production registration, and agent-facing behavior make it broader than an auto-approvable bounded change. You can add or adjust custom eligibility rules. Learn more. |
1183a77 to
53b66ab
Compare
c01ff20 to
9d2539a
Compare
83bd6a0 to
9114fbc
Compare
877b9de to
b82facd
Compare
Update every deterministic Codex turn/start expectation with the explicit user approvals reviewer emitted by the adapter, restoring exact replay coverage and unblocking the merge lane.
…ojects (#3640) Restore versioned shell-cache hydration, reconcile repository enrichment across multiple environments, and decode non-null settled shell timestamps correctly.
Normalize subagent result disclosure across timeline rendering and collapsed/expanded states. Co-authored-by: codex <codex@users.noreply.github.com>
Expose MCP tools for worktree handoff and status inspection, with focused server and contract coverage. Co-authored-by: codex <codex@users.noreply.github.com>
d2675dc to
9cbaf77
Compare
1bd44f2 to
3b9c885
Compare
Agents could not query the existing environment usage service through the authenticated MCP endpoint without relying on the client Usage page.
This change adds
t3_environment_usage, a current-environment read over the existingUsageService. It validates a maximum 31-day daily window or 24-hour hourly window, returns deterministic bucket pages with Unicode-safe bounded model/pricing text, and preserves token, unpriced-record, source-status, and pricing provenance.The result is deliberately narrower than the shared usage RPC: source fingerprints, host IDs, provider-home paths, volume IDs, transcript contents, credentials, and raw failures are omitted. Costs are labeled API-equivalent estimates, missing or failed sources remain explicit, and live-summary pagination warns that later pages can shift. The explicit read may scan transcripts, refresh cached pricing, and update existing scan caches; it adds no collector or telemetry path.
Focused validation: 76 service/production-registration/adapter/presentation tests, including MCP
tools/listroot-object properties, 31-day and 24-hour boundaries, invalid zones, Unicode astral-character encoding, deterministic pagination, partial/failed source redaction, capability/environment denial, and finite failure mapping. Targeted lint, contracts typecheck, andvp run -F t3 typecheckpass.Dependency: immutable rollout base
agents/mcp-controls/base-490318aat490318afa505d3d033295eca12d7e62b4b922725. This is an independent standalone PR, not a member of native environment stack #8729.Implemented by GPT-5.6-Sol via Codex in T3 Code.
Note
Medium Risk
New authenticated read path can trigger transcript scans and cache refresh; redaction and validation reduce leakage risk but live pagination and usage aggregation behavior affect agent-facing data.
Overview
Adds a read-only MCP tool
t3_environment_usageso agents can query aggregated usage for the authenticated environment through the existingUsageService, without going through the Usage UI.EnvironmentUsageMcpServiceenforces orchestration capability and environment ID match, validates bounded windows (up to 31 calendar days at daily resolution or 24 hours at hourly resolution, IANA timezone, hourly day-label rules), then projects usage into contract types with cursor-paginated, deterministically sorted buckets, Unicode-capped model text, and fixed metadata (costMeaning,paginationConsistency,cacheBehavior). Sensitive internals are stripped: no source fingerprints, paths, raw scan errors, or pricing URLs—generic source messages and a fixedlitellm_public_model_pricesprovenance label instead.The toolkit is wired into
McpHttpServer,t3_environment_usageis added to Claude’s read-only MCP pre-approval list (with tests covering orchestrator + environment usage readonly annotations), and user/orchestrator docs plus UI tool presentation are updated. New contracts live inenvironmentUsageMcp.ts; registration tests asserttools/listincludes the tool and expected input properties.Reviewed by Cursor Bugbot for commit 1cf821a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
t3_environment_usageMCP tool for environment usage summariesUsageServiceand returns sanitized, paginated bucket aggregates with source status, fixed pricing provenance, and cache metadata.t3_environment_usageto the Claude read-only allowlist in ClaudeAdapterV2.ts, and adds its presentation label in t3McpToolPresentation.ts.EnvironmentUsageMcpService.makenow maps allUsageReadErrorfailures to finite public codes and drops underlying causes; any consumer relying on private error detail from the usage path will no longer receive it.Macroscope summarized 1cf821a.