chatgpt-daily-token-tracker
Provides a Chrome/Edge browser extension that automatically captures visible ChatGPT messages from chatgpt.com and sends them to the local server for daily token estimation and deduplication.
Allows recording exact OpenAI API token usage and estimating token counts for ChatGPT visible text, with daily and date-range usage summaries.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@chatgpt-daily-token-trackerhow many tokens did I use today?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ChatGPT Daily Token Tracker
A daily token tracking tool for ChatGPT web usage, featuring:
MCP Server: Ask directly in ChatGPT, "How many tokens did I use today";
Edge / Chrome browser extension: Automatically captures visible user messages and assistant replies on
chatgpt.compages and estimates tokens locally;Windows auto-run: Can use a fixed ngrok development domain to provide a long-lived MCP address, and auto-start on boot via a scheduled task;
Local data storage: Statistics are stored locally; full chat text is not written to the statistics files;
Deduplication mechanism: Page refreshes and repeated scans won't accumulate the same message more than once.
[!IMPORTANT] What is counted here is the estimated token count of text visible on the web page, not the official OpenAI / ChatGPT account-level token bill. Hidden system prompts, internal reasoning, invisible context, etc. cannot be obtained from an ordinary web extension or MCP.
Features
MCP Tools
Tool | Purpose |
| View token usage for today or a specified date |
| View cumulative usage over a date range |
| Record an exact API usage that has already been obtained |
| Estimate specified input/output text and record it |
| Only estimate text tokens without saving |
| View capabilities, version, and limitations |
Browser Auto-Tracking
After installing the extension, newly generated visible ChatGPT messages are automatically sent to:
http://127.0.0.1:8787/api/track-messageThe local service uses the o200k_base tokenizer to estimate tokens, and only saves statistics such as token count, role, time, and message deduplication ID.
The extension also provides a "Backfill current conversation" feature, which can add the currently loaded conversation to the day's totals on demand; identical messages are automatically deduplicated.
Related MCP server: mcpstat
Requirements
Recommended environment:
Windows 10 / 11
Node.js 22+
Microsoft Edge or Google Chrome
A free ngrok account (needed only for a fixed public MCP address)
A ChatGPT account that supports custom MCP / App
Quick Start
1. Install Dependencies
npm install2. Start the Local Service
On Windows, double-click:
启动Token统计插件.batYou can also run:
npm startDefault addresses:
MCP:
http://127.0.0.1:8787/mcpHealth check:
http://127.0.0.1:8787/healthLocal dashboard:
http://127.0.0.1:8787/dashboard
3. Install the Edge / Chrome Auto-Tracking Extension
On Windows, double-click:
安装浏览器自动统计扩展.batOr do it manually:
Open
edge://extensionsin Edge, orchrome://extensionsin Chrome;Enable "Developer mode";
Click "Load unpacked";
Select the
browser-extensionfolder in the repository;Go back to
chatgpt.comand refresh the page.
The extension popup shows today's input, output, total tokens, and record count.
Fixed MCP Address + Windows Auto-Start on Boot
If you want ChatGPT to maintain a long-term connection to the local MCP, you need a public HTTPS address. The project provides a Windows auto-configuration script based on a fixed ngrok development domain.
Double-click:
安装长期固定地址并开机自启.batThe script will:
Check Node.js and ngrok;
Open the ngrok authtoken page in the browser;
Ask you to enter the authtoken in local PowerShell;
Retrieve the fixed ngrok development domain assigned to your account;
Generate local
config/ngrok.yml;Place an executable ngrok copy in local
bin/;Create the Windows scheduled task
ChatGPT-Token-Tracker-Fixed;Automatically start and supervise Node MCP + ngrok;
Output the final fixed MCP URL.
If an existing configuration needs repair, run:
修复固定地址自启动.batAdding MCP in ChatGPT
In ChatGPT's custom App / MCP page:
Server URL: Enter the
https://xxxxx.ngrok-free.dev/mcpoutput by the script at the end;Authentication: Select None / No authentication;
Scan tools and save.
After that, you can call today_usage in chat to query.
Data and Privacy
The following items will not be pushed to GitHub:
data/: local token statistics, logs, runtime URLs;config/: ngrok authtoken and runtime configuration;bin/: local ngrok executable;.env;node_modules/.
The browser extension will not send full chat text to the project's public ngrok address; the auto-tracking write endpoint is limited to local 127.0.0.1.
[!WARNING] The current MCP connection example uses "no authentication". The fixed public URL should not be actively shared publicly. Any public service should add authentication, access control, and auditing according to your risk needs.
Token Counting Method
exact: actualusagenumbers returned by the OpenAI API;estimated: tokenizer-based estimate for visible text;Browser auto-tracking records are marked as
chatgpt-browser-auto+estimated.
The project does not pass off estimated values as official billing data.
Testing
npm testCurrent tests cover:
Chinese and English token estimation;
Exact and estimated values aggregated separately;
Daily segmentation in Asia/Shanghai;
Deduplication by the same
eventId;HTTP API writes and deduplication for browser auto-recording.
Project Structure
browser-extension/ Edge / Chrome Manifest V3 扩展
src/server.js MCP + HTTP 服务
src/store.js 本地统计存储与去重
src/tokenizer.js Token 估算
setup-fixed-ngrok.ps1 固定 ngrok 地址与开机任务安装
run-fixed-supervisor.ps1 Windows 后台守护
repair-fixed-autostart.ps1 固定地址/自启动修复
test/ 自动测试Development and Upgrades
Recommended after each upgrade:
npm install
npm testIf you modified src/server.js, Windows fixed-deployment users can run:
修复固定地址自启动.batto make the background SYSTEM service reload the new code.
License
MIT License. See LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
Analytics for MCP servers. Query your tool calls, first-call success, retries and schema cost.
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Multiple MCP tools, persistent graph memory, token-saving data pointers, and more.
Analytics for MCP servers. Find out which of your tools agents get wrong. MCPulse shows you which tools AI agents retry, which come back empty, and which they never call at all. Two lines inside your own server. It never sees your arguments or your results. getmcpulse.com
Related MCP Servers
- AlicenseBqualityDmaintenanceToken usage tracker for OpenAI and Claude APIs with MCP (Model Context Protocol) support.6182 npm5MIT
- AlicenseNot gradedqualityCmaintenanceA Python utility for adding usage tracking, analytics, and audit trails to MCP servers using SQLite-backed persistence. It enables developers to monitor tool, prompt, and resource activity and expose these statistics directly to LLM clients.4MIT
- AlicenseBqualityFmaintenanceTrack LLM token costs across Claude, GPT and Gemini. MCP server + CLI with optimization hints and $ savings estimates.83 npm1MIT
- AlicenseNot gradedqualityAmaintenanceEnables token counting, usage tracking, and cost calculation for LLM APIs, with a proxy server mode to automatically intercept and monitor API requests from clients like Cursor and Windsurf.6 npm1MIT