Skip to content

feat: chart usage reads in Claude Code - #205

Merged
ChiragAgg5k merged 2 commits into
mainfrom
feat/usage-charts
Dec 3, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
feat/usage-charts

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What

Claude Code now draws a chart under Appwrite usage reads. It already charts tool results whose structuredContent is a Prometheus matrix (that is how the labs MCP's prometheus_query charts), but it does not recognise Appwrite's own usage shapes. appwrite_call_tool now also returns a read's time series as a matrix:

  • usage_list_events / usage_list_gauges: one series per metric and set of dimension values;
  • *_get_usage (users_get_usage, functions_get_usage, ...): one series per [{date, value}] list.

The text the model reads is unchanged. The matrix is built before a long result is cut to a preview, so stdio charts every point. Writes and reads without a time series are untouched.

How it was verified

Before building it, a stub MCP server returned the same series in seven shapes inside real Claude Code 2.1.336 sessions:

Shape Charted
Prometheus matrix as JSON text yes
Prometheus matrix in structuredContent (with or without outputSchema, unix or ISO times) yes
Appwrite usage_list_events JSON no
Appwrite *_get_usage JSON (text or structured) no
Matrix keys merged into the Appwrite payload no

Then this branch ran as the hosted server against production Appwrite, with a real Claude Code session signed in with my account, on a production project with traffic.

Before (mcp.appwrite.io today): no chart, and the model reads the long result with shell commands.

usage_list_events on production MCP: no chart

After (this branch): usage_list_events, hourly requests and executions over two days.

usage_list_events on this branch: chart

After: users_get_usage over 30 days.

users_get_usage on this branch: chart

Tests

  • e2e: test_usage_view_charts_a_range also reads the same usage through appwrite_call_tool and checks the matrix (labels, values, time order), and checks that a plain read carries no structuredContent.
  • ruff, black, pyright, unit (326) and e2e (66) pass locally.

Related: appwrite-labs/cloud#6667

Claude Code draws a chart under a tool result whose structuredContent is a Prometheus matrix, as the labs MCP's Prometheus queries show. Appwrite's own usage shapes are not recognised, so appwrite_call_tool now also returns those points as a matrix when a read holds a time series. The text the model reads is unchanged, and the matrix is built before a long result is cut to a preview.
@appwrite

appwrite Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
55030a5 Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

The full change set, including the new users usage fixture and chart assertion, is ready to merge without actionable issues.

Adds usage-chart support by converting Appwrite usage event, gauge, and get_usage time series into Prometheus matrix structured content on eligible read results while leaving their text unchanged. The e2e Appwrite stub and usage flow cover both event and users_get_usage matrices, and the project guide documents the charts module.

Latest changes: The newest commits add a mocked /v1/users/usage response and extend the e2e flow to verify that users_get_usage points are returned as a matrix.

Walkthrough (5)
File Change
AGENTS.md Documents the usage-chart conversion module.
src/mcp_server_appwrite/charts.py Parses Appwrite usage responses into Prometheus matrix series.
src/mcp_server_appwrite/operator.py Adds matrix structured content to eligible read-tool results before text previewing.
tests/e2e/support.py Provides a mock /v1/users/usage response for the hosted e2e flow.
tests/e2e/test_apps.py Checks event and users usage matrices and confirms ordinary reads have no structured content.

Reviewed the commits since 38ff825

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Tier A · Looks good to merge. Summary

Comment thread src/mcp_server_appwrite/charts.py Resolved
The *_get_usage shape has its own conversion path, so the usage flow now reads users_get_usage through appwrite_call_tool and checks its matrix. The fake Cloud serves /v1/users/usage from the project's usage points.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit 21dbcb5 into main Dec 3, 2026
6 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat/usage-charts branch December 3, 2026 23:55
@ChiragAgg5k ChiragAgg5k self-assigned this Dec 4, 2026
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