Costfluent Docs
  • Pricing
  • Changelog
  • costfluent.com
  • Documentation
  • Guides
  • API Reference
Product
  • Pricing
  • Security
  • Changelog
Developers
  • API reference
  • Terraform
  • llms.txt
Legal
  • Privacy
  • Terms
  • Imprint
Get started
Concepts
Connect a source
Reporting
Allocation
Planning
Optimization
Administration
Developers
    Public API authenticationPublic API versioningPublic API paginationPublic API errorsPublic API rate limitsPublic API data formatsWebhook notificationsTerraformMCP server
Developers

MCP server

Let an AI assistant such as Claude Code or Cursor read your costs, cost reports, budgets and anomalies through the Costfluent MCP server and a read-only API token.

The Costfluent MCP server lets an AI assistant answer questions about your cloud spend without you opening the app. It runs on your machine, speaks the Model Context Protocol to the assistant over stdin and stdout, and calls the Public API with an API token you give it. It only reads: no tool creates, changes or deletes anything.

Before you start

Available on the Starter, Core, Optimize and Scale plans. Compare plans

  • Creating the token needs the Owner, Integration Owner or Editor organization role; see API authentication.
  • The assistant must support local MCP servers that run as a command, as Claude Code, Claude Desktop and Cursor do.

Create a token

  1. Open Settings, then API tokens, and select Create API token.
  2. Enter a Name that says which assistant uses the token, such as Claude Code on my laptop.
  3. Under Access, choose the workspace the assistant works in, so the token reaches nothing else. Keep Whole organization only when the assistant compares workspaces.
  4. Under Start from, choose Read only. Clear any capability the assistant does not need: the tools need View workspaces, View costs, View cost reports, View budgets and View anomalies.
  5. Choose an Expiration, such as 90 days, and select Create API token.
  6. Copy the token from Your API token. It is shown only once.

The token is stored in your assistant's configuration file, in plain text. Give it only read capabilities and an expiration, and revoke it under API tokens when you stop using the assistant.

Install the server

Download the archive for your platform from the latest release and put costfluent-mcp on your PATH, or build it with Go:

TerminalCode
go install github.com/costfluent/costfluent-mcp/cmd/costfluent-mcp@latest

Each release carries a build provenance attestation, which gh attestation verify <archive> --repo costfluent/costfluent-mcp checks.

Connect your assistant

The server reads COSTFLUENT_API_TOKEN, the token, and optionally COSTFLUENT_BASE_URL, which defaults to https://api.costfluent.com and must use https.

  1. In Claude Code, run claude mcp add costfluent --env COSTFLUENT_API_TOKEN=<token> -- costfluent-mcp.
  2. In Claude Desktop, Cursor or another client with an mcpServers file, add the server as below.
  3. Restart the assistant and ask it a question, such as "What did we spend on AWS last month, by service?".
Code
{ "mcpServers": { "costfluent": { "command": "costfluent-mcp", "env": { "COSTFLUENT_API_TOKEN": "<token>" } } } }

Tools

ToolWhat it readsCapability
list_workspacesThe workspaces the token can readView workspaces
query_costsCost, usage or resource count over a date range, per day, week, month or quarter, grouped by up to three dimensions and narrowed by a cost filterView costs
list_cost_reportsA workspace's saved cost reportsView cost reports
get_cost_report_dataThe numbers a saved report shows nowView costs
list_budgetsBudgets with their current spend and stateView budgets
list_anomaliesDetected cost anomalies, newest firstView anomalies

How it behaves

  • At start the server asks the API which capabilities its token carries, and offers the assistant only the tools those capabilities allow. A token the API refuses stops the server with the API's error.
  • Workspace tools need a workspace_id with an organization token; the assistant finds the IDs with list_workspaces. A workspace token reads its own workspace unless told otherwise, and the API refuses any other.
  • When the API refuses a call, the assistant receives the API's error with its status, code and detail, and can explain it or adjust the question.
  • Every call counts against the token's request limit. The server waits out a short limit and returns a longer one to the assistant.
  • The server never writes the token to its log or to a tool result; it travels only in the request header.

Related

  • API authentication
  • Terraform
  • API reference
Terraform
On this page
  • Before you start
  • Create a token
  • Install the server
  • Connect your assistant
  • Tools
  • How it behaves
  • Related
JSON