LiteLLM Lens
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
LiteLLM Lens
A read-only MCP server and a self-contained HTML dashboard for LiteLLM proxy spend: cost, tokens and prompt caching by user, team, API key and model.
It reads LiteLLM's daily spend tables in Postgres. It never writes to the database, never reads prompts or responses, and offers no tool that runs arbitrary SQL.
This project is not affiliated with or endorsed by BerriAI (LiteLLM) or Anthropic.
What the dashboard shows

One page, top to bottom (numbers invented):
LLM spend Data as of 2026-11-29 06:00 UTC
This month: 1 Nov – 30 Nov 2026 (UTC)
[!] 1 of 4 checks need attention: caching off for 1 person
Summary [This month | Last month]
$1,234.56 spent so far in November, on pace for $1,320.00, 8% above ...
Top insights: Trend · Drivers · Savings · Caching · Models
Suggestions: Turn on prompt caching for sam · Use Opus less · ...
Ask about this data (works when the page is opened on claude.ai)
Spend so far | Month-end projection | Requests | Total tokens | Cache-read share | Cost per request
Daily spend by model stacked bars, last month to today [USD | Tokens] [Chart | Table]
Breakdown Users | Teams | Models | Keys | Providers (sortable table)
Prompt caching by model cache read / cache write / fresh input, per modelSee the dashboard for what every section means and the rules behind each flag.
Related MCP server: psql-mcp
Features
MCP tools for Claude Code and other MCP clients: spend by user, team, key, model or provider; daily spend by model; models that used tokens but logged $0.
One-file dashboard that works offline, or a site folder (
index.html+data.json) where a refresh replaces only the data.Health checks for stale data, missing usage, unpriced models and people whose prompt caching is not working.
Fair month comparisons: a partial month is projected before it is compared with last month.
Read-only by design: a role with column-level grants, read-only transactions with a statement timeout, and no free-form SQL.
Standard Postgres connection settings: a URL,
PG*variables,~/.pgpassor a service file.Scheduling files for launchd, systemd, cron and Docker. Hourly by default.
Requirements
Python 3.10 or later.
For your own data: a LiteLLM proxy that logs spend to Postgres, in a version whose schema has the
LiteLLM_DailyUserSpendandLiteLLM_DailyTeamSpendtables with the columns the queries use. Database access lists them and gives a query to check.
Quick start (5 minutes, no database)
Check your Python first. It must be 3.10 or later:
python3 --versionThe python3 that comes with macOS is 3.9. With it, pip install -e . fails with a misleading "setup.py not found" error. Install a newer Python (for example brew install python@3.12) and use it by name, as below.
git clone https://github.com/ykataria/litellm-lens.git
cd litellm-lens
python3.12 -m venv .venv # or python3, if it is 3.10 or later
. .venv/bin/activate
pip install -U pip
pip install -e .
litellm-lens export --sampleOpen the dashboard in your browser:
open out/dashboard.html # macOS
xdg-open out/dashboard.html # LinuxEvery name and number in it is invented.
Connect to your LiteLLM database
Create a read-only login with
sql/readonly_role.sql. It can read the two daily spend tables and the ID and name columns of the user, team and key tables, and nothing else.Configure the connection:
cp .env.example .env chmod 600 .envFill in
PGHOST,PGDATABASEandPGUSER. KeepPGSSLMODE=require(orverify-full) for a remote database. Keep the password in~/.pgpass.PG*variables already set in your shell win over.env. The genericDATABASE_URLis ignored, because it usually belongs to another application; useLITELLM_LENS_DATABASE_URLfor a URL.Check the connection and every tool:
litellm-lens verifyBuild your dashboard:
litellm-lens exportout/dashboard.htmlnow holds your real data, including staff emails.out/is git-ignored.
More detail: getting started and database access.
Use it from Claude Code
The repository's .mcp.json registers the server. It expects the virtual environment at .venv, as in the quick start:
{
"mcpServers": {
"litellm-lens": {
"command": ".venv/bin/litellm-lens",
"args": ["serve"]
}
}
}Start claude in the repository folder and approve the litellm-lens project server. Run /mcp to check it is connected, then ask things like "What did we spend on Claude last month, by team?" or "Which models are missing a price?".
claude mcp list may still show the server as "Pending approval" after you approve it in a session; /mcp inside Claude shows the real status.
To use it from any folder, add it at user scope with absolute paths (the server reads .env from the working folder, so point it at the file):
claude mcp add -s user litellm-lens \
-e LITELLM_LENS_ENV_FILE=/ABSOLUTE/PATH/TO/litellm-lens/.env \
-- /ABSOLUTE/PATH/TO/litellm-lens/.venv/bin/litellm-lens serveThe tools, their arguments and their output: MCP tools.
Choose how to run it
Local only | Server or static hosting | claude.ai artifact (optional) | |
You get |
| A dashboard URL for your team; optionally an MCP server over HTTP | A private claude.ai page with an Ask box |
Command |
|
| The prompts in |
Data leaves your machine | No | To your web server | To claude.ai |
Access control | Whoever has the file | Your SSO or reverse proxy. The HTTP MCP server has no authentication of its own | The artifact's Share menu |
Needs | Python | A web server or bucket | Claude Code signed in with a claude.ai account |
Start with local only. The local file and the server folder refresh on a schedule with scripts/refresh.sh (launchd on a Mac, a systemd timer or cron on Linux) or with the Docker Compose loop. The claude.ai artifact refreshes from a Claude Code /loop, a scheduled task in the Claude desktop app, or (experimental, macOS) a launchd job that opens a Claude session in Terminal, because only a Claude session can publish it. You can try the artifact without a database: add --sample to the export command in the prompt. See refresh and scheduling and deployment.
Publish the artifact every hour on a Mac (experimental)
After the artifact exists (.artifact-url is in the repository root), run the refresh once by hand and accept Claude's folder-trust prompt in the Terminal window it opens:
scripts/claude-refresh.sh
tail -1 logs/claude-refresh.log # ... published (litellm-lens-refresh-...)If the artifact belongs to another Claude profile than your default, name its config folder: LITELLM_LENS_CLAUDE_CONFIG_DIR=~/.claude-other scripts/claude-refresh.sh.
Then install the hourly job from the repository root. Set CLAUDE_DIR to the Claude config folder of the account that owns the artifact (~/.claude unless you use another profile):
CLAUDE_DIR=~/.claude
dst=~/Library/LaunchAgents/io.github.ykataria.litellm-lens.claude-refresh.plist
sed -e "s#/ABSOLUTE/PATH/TO/litellm-lens#$PWD#g" -e "s#/Users/USERNAME#$HOME#g" \
deploy/launchd/io.github.ykataria.litellm-lens.claude-refresh.plist > "$dst"
/usr/libexec/PlistBuddy -c "Add :EnvironmentVariables:LITELLM_LENS_CLAUDE_CONFIG_DIR string $CLAUDE_DIR" "$dst"
mkdir -p logs
launchctl bootstrap gui/$(id -u) "$dst"To | Run |
Check it is scheduled |
|
Run it now |
|
Change how often (seconds; 1800 = 30 min) |
|
Stop and remove it |
|
See results |
|
The job keeps running after you close the terminal you installed it from, and after a restart: launchd starts it, not your shell. It needs you logged in and the Mac awake; a run missed while the Mac sleeps runs once when it wakes.
Configuration
The CLI and the MCP server read environment variables, plus a .env file: LITELLM_LENS_ENV_FILE if set, otherwise .env in the current folder (parent folders are not searched). Real environment variables win over the file. The main ones:
Variable | Default | Purpose |
| not set | Connection URL. Without it, the libpq |
|
| Schema of the LiteLLM tables. |
|
| Keys left out of every number. |
|
| Seconds to wait for a connection. |
|
| Seconds per query. Set |
|
| Dashboard model groups. |
|
| Prices (USD per million tokens) for the savings estimate. |
| localhost only | HTTP transport only: the |
scripts/refresh.sh has three variables of its own (LITELLM_LENS_BIN, LITELLM_LENS_LOG_DIR, LITELLM_LENS_SITE_DIR). The script reads them from its process environment only, not from .env, so set them in the scheduler.
The full list, with formats and examples: configuration.
Security
Use the dedicated read-only role. Every query also runs in a read-only transaction with a statement timeout, and there is no free-form SQL tool.
Use
PGSSLMODE=requireorverify-fullfor any remote database.The HTTP MCP transport has no authentication. Keep it on localhost or a VPN, or behind an authenticating reverse proxy. It always checks the
HostandOriginheaders against DNS rebinding, and by default accepts only localhost.Dashboards contain staff emails and spend. Share them only with people who should see them.
Reporting vulnerabilities and the threat model: SECURITY.md.
Documentation
Page | What it covers |
Install, sample data, connect, verify, Claude Code. | |
Every environment variable. | |
The read-only role, connection options, TLS, passwords, servers, PgBouncer. | |
Each tool's arguments, output and errors. | |
Every section, check and threshold. | |
The JSON behind the dashboard. | |
| |
Static hosting, HTTP MCP behind a proxy, Docker, claude.ai artifact. | |
How the parts fit together, and the module map. | |
Error messages and fixes. | |
Health checks, prompt caching, unpriced models, how the tables count. |
Contributing
See CONTRIBUTING.md for the development setup, linting, tests and how to change the dashboard template. Changes are listed in CHANGELOG.md. Everyone taking part is expected to follow the code of conduct.
Licence
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Read-only analytics for Convex apps, queryable via MCP from Claude, Cursor, and other clients.
Read-only analytics for all your apps: users, AI traffic, revenue, with the SQL behind every number.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceProvides a read-only PostgreSQL SQL surface for LLM agents via MCP, with defense-in-depth security layers for safe database queries.3MIT
- AlicenseNot gradedqualityCmaintenanceA hardened, read-only Postgres MCP server that enables LLMs to safely query databases without write, DDL, shell, or credential exposure.MIT
- AlicenseNot gradedqualityDmaintenanceProvides read-only access to PostgreSQL databases via MCP, enforcing least-privilege roles, row-level security, masked views, and SQL AST guardrails to prevent data leakage and unauthorized operations, enabling AI agents to safely query sensitive production data.MIT

MCP DB Gatewayofficial
AlicenseNot gradedqualityDmaintenanceProvides governed, read-only PostgreSQL access for AI agents via MCP. Enforces schema/table allowlists, query limits, and audit events.1MIT