Tokenomics MCP
Provides exact token counting and API cost estimation for OpenAI models such as gpt-4o, gpt-4.1, gpt-5, and o3.
Click on "Install 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., "@Tokenomics MCPHow many tokens is this prompt for gpt-4o?"
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.
Tokenomics MCP
An MCP server for counting LLM prompt tokens and estimating API costs across OpenAI and Anthropic models — right inside your chat client, no browser-based token counter needed.
Tools
Tool | What it does |
| Exact/approximate token count for a piece of text |
| $ cost estimate for input + optional expected output |
| Side-by-side cost table across several models |
| See every model this server has pricing data for |
Related MCP server: nikhilnt
How token counting works
OpenAI models (
gpt-4o,gpt-4.1,gpt-5,o3, etc.): exact, via tiktoken.Claude models: exact via Anthropic's
count_tokensAPI ifANTHROPIC_API_KEYis set; otherwise falls back to atiktoken-based approximation, and says so explicitly in the output.
Pricing data lives in src/tokenomics_mcp/pricing.py as a plain dict —
PRICING_LAST_VERIFIED marks the date it was checked. LLM pricing changes
often; update that dict directly when it does.
Project layout
tokenomics-mcp/
├── src/tokenomics_mcp/
│ ├── server.py # MCP tool wiring (thin layer)
│ ├── pricing.py # pricing table + token-counting logic (unit-tested)
│ └── __init__.py
├── tests/
│ └── test_pricing.py # pure-logic tests, no network/API calls needed
├── Dockerfile # multi-stage build, non-root runtime user
├── docker-compose.yml
├── .github/workflows/
│ ├── ci.yml # lint + test on every PR/push to main
│ └── docker-publish.yml # build + push image to GHCR on version tags
├── pyproject.toml
└── .env.exampleLocal development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
cp .env.example .env # optional: add ANTHROPIC_API_KEY for exact Claude counts
ruff check . # lint
pytest -v # test
python -m tokenomics_mcp.server # run the server standalone (stdio)Running with Docker
docker build -t tokenomics-mcp .
docker run -i --rm --env-file .env tokenomics-mcpMCP servers communicate over stdio, not a network port — that's why the
Dockerfile has no EXPOSE and the run command uses -i (keep stdin open)
rather than -p (publish a port). docker-compose.yml wraps the same
invocation if you prefer docker compose run tokenomics-mcp.
Connect it to Claude Desktop
Local (no Docker):
{
"mcpServers": {
"tokenomics": {
"command": "python",
"args": ["-m", "tokenomics_mcp.server"],
"env": { "ANTHROPIC_API_KEY": "your_key_here" }
}
}
}Via Docker:
{
"mcpServers": {
"tokenomics": {
"command": "docker",
"args": ["run", "-i", "--rm", "--env-file", "/absolute/path/to/.env", "tokenomics-mcp"]
}
}
}Restart Claude Desktop, then try: "How many tokens is this prompt for gpt-4o?" or "Compare the cost of this prompt across all supported models."
CI/CD
ci.ymlruns on every PR and push tomain: installs the package, lints withruff, runs thepytestsuite. All logic inpricing.pyis unit-tested with stubbed tokenizers, so tests run fast with no network calls or API keys required.docker-publish.ymlruns when you push a version tag (git tag v0.1.0 && git push origin v0.1.0): builds the Docker image and pushes it to GitHub Container Registry (ghcr.io/<your-username>/tokenomics-mcp), tagged both with the version andlatest. No registry account setup needed — it authenticates with theGITHUB_TOKENGitHub Actions already provides.
Releasing a new version
Bump
versioninpyproject.tomland__version__in__init__.py.Commit, merge to
main.Tag and push:
git tag v0.2.0 && git push origin v0.2.0.Watch the Publish Docker image workflow run in the Actions tab — once green, the image is live at
ghcr.io/<your-username>/tokenomics-mcp:v0.2.0.
Notes
The pricing table needs periodic manual updates; there's no live pricing feed to scrape reliably, so this is intentionally a plain, editable dict rather than something auto-fetched.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceToken usage tracker for OpenAI and Claude APIs with MCP (Model Context Protocol) support.61354MIT
- AlicenseBqualityDmaintenanceTrack LLM token costs across Claude, GPT and Gemini. MCP server + CLI with optimization hints and $ savings estimates.891MIT
- Alicense-qualityDmaintenanceLive LLM pricing as an MCP server. Ask Claude or any MCP client 'how much does this prompt cost?' and get real numbers from a hand-checked pricing table for every major LLM.MIT
- Flicense-qualityDmaintenanceEnables AI cost calculation, comparison, and optimization across major providers like Anthropic, OpenAI, Google, Meta, and Mistral. Supports cost estimation, budget-aware model finding, and token estimation through a simple API and MCP integration.
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
MCP server for GLM chat completions using Zhipu AI models via AceDataCloud
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JonThads/tokenomics'
If you have feedback or need assistance with the MCP directory API, please join our Discord server