API keys & AI assistants (MCP)

Create API keys and connect Claude Desktop, Cursor or Claude Code to your cost data.

API keys & AI assistants (MCP)

Create a key so an AI assistant such as Claude Desktop, Cursor, Claude Code or Windsurf can ask CostGlass questions about your cloud costs.

Where in CostGlassSettings → API Keys
PlanAll plans
Who can do thisOwner and Admin create and revoke keys
Time needed10 minutes
In short
  • An API key is a secret that lets a program act as the person who created it. It starts with cg_live_.
  • The full key is shown once, when you create it. CostGlass stores only a fingerprint, so a lost key cannot be recovered; revoke it and make a new one.
  • The page offers one scope, read, but see the warning below: a key acts with its creator's role.
  • The MCP (Model Context Protocol) connection gives an AI assistant seven read-only tools, two resources and two ready-made prompts.
Before you begin
  • You are an Owner or Admin.
  • Some cost data is already connected, otherwise the assistant has nothing to answer from.
  • An AI assistant that supports MCP servers.

Create a key

1
Open the page
Choose Settings, then API Keys. The page is titled API Keys & MCP Access and lists existing keys with Name / Label, Key Prefix, Scopes, Created, Last Used and Expires.
2
Start
Click Generate New API Key.
3
Name it
Give it a label that says where it will be used, for example Cursor IDE, Claude Desktop or CI/CD.
4
Choose an expiry
Pick 30 days, 90 days (Recommended), 180 days, 1 year or No expiration.
5
Copy the key now
The key appears once with the warning Save this key now!. Copy it into your password manager. A ready-made configuration snippet is shown alongside it.
Important
If you lose the key you cannot see it again. Revoke it and create a new one.

Revoke a key

In the key's row use the revoke action and confirm. The key stops working immediately for everything that uses it, and it disappears from the list. Revoke a key when a laptop is lost, a person leaves, or you are unsure who has seen it. Only Owners and Admins can revoke.

What a key can do (read this)

A key is as powerful as the person who made it
  • The scope field is stored, but today it is not enforced by the server. A key acts with the role of the person who created it, on the whole CostGlass API, not only on the assistant tools. If an Owner creates it, it has Owner rights.
  • A key is not narrowed by hierarchy scope. The assistant tools read the whole organisation even if the creator is limited to one node.
  • If the creator is removed or disabled, the key stops working.

Good practice

  • Create keys for a dedicated, least-privileged person where possible (a Member who is not scoped), not an Owner.
  • Use short expiries and one key per tool or machine, so you can revoke one without affecting the rest.
  • Never paste a key into chat, tickets or source control. Keep it in the assistant's environment settings.
  • Check Last Used regularly and revoke keys you do not recognise.
  • Remember that what the assistant reads is sent to the AI provider that runs the assistant. Only connect assistants your company has approved.
Note
Creating and revoking keys is not currently written to the audit log.

Connect your assistant

Replace the key placeholder with your key. The API address below is the UK region's. If your organisation is in another region, use your region's API address instead; ask support if you are unsure.

Claude Desktop and Cursor (local server)

Add this to claude_desktop_config.json (Claude Desktop) or .cursor/mcp.json (Cursor). The path points at the CostGlass MCP server script you have installed.

MCP configuration

Claude Code

Terminal

Remote connection (no local install)

For assistants that can talk to a remote MCP server over HTTP:

Remote MCP

Restart the assistant. Ask it "What were our top five cloud spenders this month?" to test.

What the assistant can use

ToolWhat it does
costglass_query_costsSpend grouped by service, region or account, over a time range (for example current month, last 30 days, year to date), daily or monthly, with optional filters and cost basis (unblended or amortized). The provider filter accepts aws, azure and gcp.
costglass_get_anomaliesCost anomalies, filterable by status, severity and provider.
costglass_get_savings_recommendationsSavings opportunities, optionally above a minimum monthly saving.
costglass_get_kubernetes_costsKubernetes cluster spend, namespace allocation, idle capacity and pod rightsizing.
costglass_get_budgetsBudgets, limits and current spend.
costglass_get_connected_accountsConnected accounts and their sync status.
costglass_get_cost_filtersThe services, regions, accounts and tag dimensions that exist, so the assistant uses valid names.

Two resources are available, costglass://summary/current-month and costglass://anomalies/active, and two prompts: /finops_audit (a broad review of spend, anomalies and waste) and /investigate_cost_spike (step-by-step triage of a sudden rise). All of these only read data. They do not change anything in CostGlass or in your clouds.

Frequently asked questions

I get "Invalid API key" or "API key has expired".
The key was revoked, mistyped or has passed its expiry. Create a new one.
Can a Member create a key?
No. Only Owners and Admins can create and revoke keys.
Can I limit a key to certain accounts?
Not today. Keys read the whole organisation.
Does the assistant change my cloud?
No. CostGlass tools are read-only and CostGlass does not modify your clouds through them.

Related guides