Repository navigation
tokenmeter mcp: read-only MCP server for AI assistants - #24
Merged
Merged
Conversation
stdio by default, streamable HTTP with a bearer token on --listen. usage_summary, top_spenders, cost_per_action, usage_by_meta and health, with exact USD and nano-USD, UTC windows and truncated results marked; a usage_report prompt. A token that can write events is refused, found by an empty batch that fails after the scope check. The end-to-end job checks the stdio server against GET /v1/usage/summary.
The HTTP server drains running calls before the connection closes, and a signal ends a stdio server cleanly. The bearer scheme is matched without case; the MCP token is checked before any call to the service. A token that can write exits 4. Ranking, sorting and totals are shared with the CLI, top_spenders keeps all rows with limit 0 and formats only those it returns, and the server takes its client as a parameter.
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.
Closes ai-process/docs#133 (epic ai-process/docs#137).
tokenmeter mcponmodelcontextprotocol/go-sdkv1.8.0: stdio by default,--listenserves streamable HTTP at/mcpwith a required bearer token (TOKENMETER_MCP_TOKEN/--mcp-token-file), DNS-rebinding and cross-origin protection; warns on non-loopback.readOnlyHint:usage_summary,top_spenders,cost_per_action(per action: cost and tokens per request, latency, failed share and cost),usage_by_meta,health. Amounts as exactcost_usd(no float) andcost_nanousd; UTC half-open windows; capped windows fetched in parts viapkg/client;truncatedresults carry a note that they are not totals; an empty window says "no traffic".RecordUsageEventsbatch fails with PERMISSION_DENIED without the write scope and INVALID_ARGUMENT with it, so nothing is recorded. No token is allowed with a warning (service without auth).usage_report. Health probing shared withtokenmeter health; one gRPC connection and one HTTP client for the server's life.scripts/cli-e2e.shdrives the built binary over stdio and comparesusage_summarywithGET /v1/usage/summary, on Postgres alone and with ClickHouse.