Token Tracker

Token usage tracker for OpenAI and Claude APIs with MCP support. Pass accurate API costs to your users.
  • typescript

3

GitHub Stars

typescript

Language

4 months ago

First Indexed

3 weeks ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs

You can monitor and bill for your AI API usage in real time by wrapping your API client with a Model Context Protocol (MCP) server. This enables per-user usage tracking, automatic token counting, and up-to-date pricing across providers, all accessible through your MCP client or Claude Desktop.

How to use

Set up the MCP server in your environment and connect your MCP client to it. You can either wrap your existing API client to enable automatic tracking or run the server locally for real-time session monitoring. Use the tracked data to show current session usage, per-user costs, and model-specific token breakdowns in your application.

How to install

Prerequisites: you need Node.js and npm installed on your system.

Install the MCP server package from npm.

npm install llm-token-tracker

Configuration and usage with MCP client

Add the MCP server to Claude Desktop settings to enable real-time session tracking and cost calculations. Use the following configuration snippet to run the server via MCP.

{
  "mcpServers": {
    "token_tracker": {
      "command": "npx",
      "args": ["llm-token-tracker"]
    }
  }
}

Examples of MCP usage in the client

Once wrapped, you can start and end manual tracking sessions, or rely on automatic tracking when making API calls. Retrieve per-user usage data and costs at any time, and compare costs across models.

Development and build

Install dependencies, build, and run examples to explore MCP capabilities.

# Install dependencies
npm install

# Build TypeScript
npm run build

# Watch mode
npm run dev

# Run examples
npm run example

Available tools

get_current_session

Get current session usage with a progress bar, including Used/Remaining tokens, Input/Output breakdown, Cost, and a model breakdown.

track_usage

Track token usage for an API call by providing provider, model, input_tokens, output_tokens, and user_id.

get_usage

Get usage summary for a specific user or all users.

compare_costs

Compare costs between different models.

clear_usage

Clear usage data for a user.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational