openai-usage-mcp
Provides tools for querying OpenAI platform usage and cost data through the OpenAI Admin API, enabling cost analysis, month-over-month comparisons, and usage tracking for various services like completions and embeddings.
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., "@openai-usage-mcpshow me March cost summary"
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.
OpenAI Usage and Cost Management MCP Server
MCP server for accessing OpenAI platform usage and cost data through the OpenAI Admin API.
Note: This server accesses cost and usage data from the OpenAI Admin API. All API calls are performed using the caller's admin key and are subject to OpenAI's rate limits.
Features
Cost Analysis
Spend summaries: Total and per-line-item cost breakdowns with top-N ranking
Daily breakdowns: Per-day cost tracking by model or project
Projected spend: Automatic month-end projection based on current daily average
Anomaly detection: Flags daily spending spikes (>2σ from mean)
Month-over-Month Comparison
Cost variance analysis: Compare any two months side by side
Delta tracking: Per-line-item changes with dollar and percentage deltas
Biggest movers: Highlights the largest cost increases and decreases
Usage Tracking
Token consumption: Input, output, and cached token counts by model
Request volumes: API request counts over time
Multi-service support: Completions, embeddings, images, audio, moderations, vector stores, and more
Model-level breakdown: Usage aggregated by model with compact summary tables
Related MCP server: cloudscope-mcp
Prerequisites
Python 3.11 or newer
uv package manager
An OpenAI Admin API key (create one here)
Installation
Add to your MCP client configuration (e.g., Claude Desktop, Claude Code):
Using uv
{
"mcpServers": {
"openai-usage-mcp": {
"command": "uv",
"args": ["run", "--directory", "/path/to/openai-usage-mcp", "openai-usage-mcp"],
"env": {
"OPENAI_ADMIN_KEY": "sk-admin-..."
}
}
}
}Using uvx (from PyPI)
{
"mcpServers": {
"openai-usage-mcp": {
"command": "uvx",
"args": ["openai-usage-mcp"],
"env": {
"OPENAI_ADMIN_KEY": "sk-admin-..."
}
}
}
}Tools
costs
Query OpenAI dollar-amount spend data.
Parameter | Type | Default | Description |
| string | (required) | Start date (YYYY-MM-DD) |
| string | today | End date (YYYY-MM-DD) |
| string |
|
|
| string |
|
|
| int | 10 | Number of top items to show |
| int | 180 | Max daily buckets to fetch (1-180) |
Detail levels:
summary (default): Compact total + top-N breakdown table (~20 lines). Includes projected month-end spend and anomaly detection when applicable.
daily: Per-day breakdown with per-item amounts.
raw: Full unprocessed data, every line item every day.
Examples:
# This month's spend
costs(start_time="2026-03-01")
# Last 7 days by project
costs(start_time="2026-03-23", group_by="project_id")
# Daily breakdown for February
costs(start_time="2026-02-01", end_time="2026-03-01", detail_level="daily")cost-comparison
Compare OpenAI costs between two calendar months.
Parameter | Type | Default | Description |
| string | (required) | Earlier month (YYYY-MM) |
| string | (required) | Later month (YYYY-MM) |
| string |
|
|
| int | 10 | Number of top items to show |
Output includes:
Total spend for each month with overall delta and percentage change
Per-line-item comparison table sorted by largest absolute change
Biggest movers section highlighting the largest increase and decrease
Examples:
# February vs March
cost-comparison(baseline_month="2026-02", comparison_month="2026-03")
# By project
cost-comparison(baseline_month="2026-02", comparison_month="2026-03", group_by="project_id")usage
Query OpenAI token and request usage data by service type.
Parameter | Type | Default | Description |
| string | (required) | See supported types below |
| string | (required) | Start date (YYYY-MM-DD) |
| string | today | End date (YYYY-MM-DD) |
| string |
|
|
| string |
|
|
| string | — |
|
| string | — | Filter by model name(s) |
| string | — | Filter by project ID(s) |
| int | 10 | Number of top models to show |
| int | 180 | Max buckets to fetch |
Supported service types: completions, embeddings, images, audio_speeches, audio_transcriptions, moderations, vector_stores, code_interpreter_sessions
Examples:
# GPT-4o usage this month
usage(service_type="completions", start_time="2026-03-01", models="gpt-4o")
# All completions last week
usage(service_type="completions", start_time="2026-03-23")
# Embeddings by project
usage(service_type="embeddings", start_time="2026-03-01", group_by="project_id")Authentication
This server requires an OpenAI Admin API key set via the OPENAI_ADMIN_KEY environment variable.
Admin keys can be created at platform.openai.com/settings/organization/admin-keys.
The key needs the Usage read permission to access cost and usage data.
Development
# Clone and install
git clone https://github.com/dlaporte/openai-usage-mcp.git
cd openai-usage-mcp
uv sync --dev
# Run tests
uv run pytest -v
# Run the server locally
OPENAI_ADMIN_KEY=sk-admin-... uv run openai-usage-mcpLicense
MIT
Available Tools
3 toolscost-comparisonA
Compare OpenAI costs between two months to identify spending changes.
USE THIS TOOL FOR:
Month-over-month cost variance analysis (e.g., February vs March)
Identifying which line items increased or decreased the most
Executive-level cost change summaries
DO NOT USE THIS TOOL FOR:
Single-month cost analysis (use 'costs' tool instead)
Token or request usage data (use 'usage' tool instead)
Arbitrary date range comparisons (this tool compares full calendar months only)
PARAMETERS:
baseline_month: Earlier month in YYYY-MM format (e.g., "2026-02")
comparison_month: Later month in YYYY-MM format (e.g., "2026-03")
group_by: "line_item" (default), "project_id", or both
top_n: Number of items to show (default 10)
OUTPUT includes:
Total spend for each month with overall delta and % change
Per-line-item comparison table with delta and % change
Biggest movers section highlighting largest increase and decrease
EXAMPLES:
February vs March: baseline_month="2026-02", comparison_month="2026-03"
By project: baseline_month="2026-02", comparison_month="2026-03", group_by="project_id"
| Name | Required | Description | Default |
|---|---|---|---|
| top_n | No | ||
| group_by | No | ||
| baseline_month | Yes | ||
| comparison_month | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It transparently explains what the tool returns (total spend, per-line-item comparison, biggest movers), the constraint that it compares full calendar months, and includes examples. This is comprehensive behavioral coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized for a tool with 4 parameters and multiple usage scenarios. It is well-structured with clear sections (USE, DO NOT USE, PARAMETERS, OUTPUT, EXAMPLES), front-loaded with the main purpose, and every section earns its place without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has 4 parameters, no schema descriptions, and no annotations, but the description compensates fully. It includes parameter details, output structure, examples, and distinctions from sibling tools. This is a complete and self-sufficient description for an agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 0%, so the description must compensate. It does so thoroughly by explaining each parameter's format (YYYY-MM), default values, allowed options for group_by ('line_item', 'project_id', or both), and top_n semantics. The description adds substantial meaning beyond the bare schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Compare OpenAI costs between two months to identify spending changes.' It uses a specific verb and resource, and explicitly distinguishes itself from sibling tools 'costs' and 'usage' by naming them in the DO NOT USE section.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit USE THIS TOOL FOR and DO NOT USE THIS TOOL FOR sections, including specific alternative tools ('costs' for single-month analysis, 'usage' for token/request data). This gives clear when-to-use and when-not-to-use guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
costsA
Query OpenAI dollar-amount spend data.
USE THIS TOOL FOR:
Total spend over a date range (summary mode, default)
Daily cost breakdown by line item or project
Month-to-date spend with projected month-end forecast
Identifying cost anomalies (spike days highlighted in summary)
DO NOT USE THIS TOOL FOR:
Token or request counts (use 'usage' tool instead)
Comparing two different months side by side (use 'cost-comparison' tool)
DETAIL LEVELS:
summary (default): Compact total + top-N breakdown table (~20 lines). Includes projected month-end spend and anomaly detection when applicable.
daily: Per-day breakdown with per-item amounts.
raw: Full unprocessed data, every line item every day.
DEFAULTS: detail_level='summary', group_by='line_item', top_n=10, end_time=today
EXAMPLES:
This month's spend: start_time="2026-03-01"
Last 7 days by project: start_time="2026-03-23", group_by="project_id"
Daily breakdown for February: start_time="2026-02-01", end_time="2026-03-01", detail_level="daily"
Dates in YYYY-MM-DD format.
| Name | Required | Description | Default |
|---|---|---|---|
| top_n | No | ||
| end_time | No | ||
| group_by | No | ||
| start_time | Yes | ||
| detail_level | No | summary |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full transparency burden. It discloses detail levels with output characteristics (e.g., 'Compact total + top-N breakdown table (~20 lines)'), default parameter values, anomaly detection behavior, and date formatting requirements. It does not mention error handling or access permissions, but for a read-only query tool the disclosed behavioral traits are substantial.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with bolded section headers, uses imperative bullet lists, and packs information efficiently into about one screen. No filler—every section addresses a distinct concern (purpose, usage, detail levels, defaults, examples, date format).
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has a moderate complexity level with 5 parameters and an output schema. The description covers use cases, alternatives, detail-level semantics, defaults, and examples, which is sufficient for an agent to select and invoke correctly. The presence of an output schema offsets the need to enumerate return fields, and the examples give concrete invocation patterns.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It resolves ambiguity by specifying defaults for all optional parameters (detail_level, group_by, top_n, end_time) and providing concrete examples that illustrate parameter use. The statement that 'summary (default)' and 'top-N' clarify top_n's role. The allowed group_by values are only partially specified (line_item and project_id), but examples cover typical usage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with 'Query OpenAI dollar-amount spend data,' clearly identifying the verb and resource. It distinguishes from siblings by explicitly naming the 'usage' and 'cost-comparison' tools in the DO NOT USE section, making its purpose unmistakable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description has dedicated 'USE THIS TOOL FOR' and 'DO NOT USE THIS TOOL FOR' sections. It lists specific use cases (total spend, daily breakdown, month-to-date forecast, anomaly detection) and explicitly directs users to alternative tools for token counts and month-over-month comparison, satisfying both when and when-not guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
usageA
Query OpenAI token and request usage data by service type.
USE THIS TOOL FOR:
Token consumption (input, output, cached) by model
Request counts over time
Usage breakdown by model, project, or API key
Image generation counts, audio seconds, etc.
DO NOT USE THIS TOOL FOR:
Dollar-amount costs (use 'costs' tool instead)
Month-over-month cost comparisons (use 'cost-comparison' tool)
SERVICE TYPES: completions, embeddings, images, audio_speeches, audio_transcriptions, moderations, vector_stores, code_interpreter_sessions
DETAIL LEVELS:
summary (default): Compact table aggregated by model with totals.
daily: Per-day breakdown.
raw: Full unprocessed data.
DEFAULTS: detail_level='summary', bucket_width='1d', top_n=10, end_time=today
EXAMPLES:
GPT-4o usage this month: service_type="completions", start_time="2026-03-01", models="gpt-4o"
All completions last week: service_type="completions", start_time="2026-03-23"
Embeddings by project: service_type="embeddings", start_time="2026-03-01", group_by="project_id"
Dates in YYYY-MM-DD format.
| Name | Required | Description | Default |
|---|---|---|---|
| top_n | No | ||
| models | No | ||
| end_time | No | ||
| group_by | No | ||
| start_time | Yes | ||
| project_ids | No | ||
| bucket_width | No | 1d | |
| detail_level | No | summary | |
| service_type | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It discloses defaults (detail_level='summary', bucket_width='1d', top_n=10, end_time=today), service types, detail levels, and date format. However, it does not explicitly state that the operation is read-only or mention potential limitations like pagination, though the word 'Query' strongly implies a non-mutating operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with headers, bullet lists, and example calls. It front-loads the purpose, then logically presents usage instructions, service types, detail levels, defaults, and examples. Every sentence contributes value, and the format is scannable without unnecessary padding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 9-parameter tool with no schema descriptions and no annotations, this description covers all key aspects: when to use, when not to use, service types, detail levels, defaults, examples, and date formatting. The output schema exists (per context signals), so return-value details are not required in the description. This is a comprehensive and self-contained guide.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has 0% description coverage, so the description must compensate. It does so by listing service types, detailing detail levels, explaining defaults, and providing examples that illustrate parameter usage (e.g., 'group_by="project_id"' for project breakdown). However, not every parameter (e.g., project_ids, top_n) receives an explicit definition, though their meanings are inferable from context and examples.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Query OpenAI token and request usage data by service type' with a specific verb and resource. It also distinguishes itself from sibling tools by explicitly saying 'DO NOT USE THIS TOOL FOR: Dollar-amount costs (use 'costs' tool instead)'. This makes the purpose unambiguous and differentiates it from alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides explicit 'USE THIS TOOL FOR' and 'DO NOT USE THIS TOOL FOR' sections, listing alternative tools ('costs' and 'cost-comparison') for excluded use cases. It also includes concrete examples of when to call the tool (e.g., 'GPT-4o usage this month'), making the usage context crystal clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
3 tool updates
v0.1.0- First observed
cost-comparison - First observed
costs - First observed
usage
TDQS
Each tool has a clearly distinct purpose: costs for dollar spend, usage for token/request counts, and cost-comparison for month-over-month variance. The descriptions explicitly cross-reference 'DO NOT USE THIS TOOL FOR' statements, eliminating ambiguity.
Tool names are primarily single-word nouns (costs, usage) with one hyphenated compound (cost-comparison). While not following a verb_noun pattern, the names are short and readable, though the hyphen introduces a minor inconsistency.
Three tools is a well-scoped count for an OpenAI usage/cost tracking server. Each tool covers a distinct aspect of the domain (cost, usage, comparison) and fits within the ideal 3-15 tool range.
The surface covers the core domain of cost and usage tracking, including summary, daily, and raw detail levels, plus month-over-month cost comparison. Missing a dedicated usage-comparison tool or project/service listing, but these are minor and can be worked around via parameters.
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 Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
OpenAI organization usage and cost reporting through an admin API key connected by the user.
Hosted MCP server for AWS cloud spend: service breakdowns, anomalies, savings and forecasts.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Related MCP Servers
- AlicenseBqualityCmaintenanceAn MCP server for unified cost tracking and analysis across AWS, OpenAI, and Anthropic. It enables users to query expenditures, compare costs across providers, and analyze usage trends through natural language.10MIT
- AlicenseAqualityBmaintenanceCloud cost management MCP server for Azure. Ask your AI about your cloud bill.15801MIT
- AlicenseAqualityAmaintenanceA read-only MCP server for querying AI provider administration APIs, providing normalized usage, cost, and dashboard data for OpenAI and Anthropic.419MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that reads local OpenClaw session files to provide token usage and cost data without any network calls or authentication.MIT
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/dlaporte/openai-usage-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server