Repository navigation
feat: chart usage reads in Claude Code - #205
Merged
Merged
Conversation
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.
Code review
Adds usage-chart support by converting Appwrite usage event, gauge, and Latest changes: The newest commits add a mocked Walkthrough (5)
Reviewed the commits since Tip Comment |
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.
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.

What
Claude Code now draws a chart under Appwrite usage reads. It already charts tool results whose
structuredContentis a Prometheus matrix (that is how the labs MCP'sprometheus_querycharts), but it does not recognise Appwrite's own usage shapes.appwrite_call_toolnow 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:
structuredContent(with or withoutoutputSchema, unix or ISO times)usage_list_eventsJSON*_get_usageJSON (text or structured)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.
After (this branch):
usage_list_events, hourly requests and executions over two days.After:
users_get_usageover 30 days.Tests
test_usage_view_charts_a_rangealso reads the same usage throughappwrite_call_tooland checks the matrix (labels, values, time order), and checks that a plain read carries nostructuredContent.Related: appwrite-labs/cloud#6667