# Cursor

Cursor connects to the hosted [Costfluent MCP server](/developers/mcp) at `https://mcp.costfluent.com` from an entry in its `mcp.json`, and you sign in or send an API token. To run the server on your machine instead, `costfluent mcp install` adds an entry that starts it, reading the token from `COSTFLUENT_API_TOKEN` in Cursor's environment rather than writing it into the file.

## Before you start

- To sign in, a Costfluent account in the organization Cursor should read. To send a token, or to run the server on your machine, an API token from the **Read only** preset; see [Create a token](/developers/mcp#create-a-token).
- To run the server on your machine, `costfluent-mcp` and the [command line](/developers/cli#install), `costfluent`, on your `PATH`; both come in the same [release archive](/developers/mcp#install-the-server).

## Connect and sign in

<Stepper>

1. Add the server to `~/.cursor/mcp.json`, or to `.cursor/mcp.json` in a project to reach it from that project alone:

   ```json
   {
     "mcpServers": {
       "costfluent": {
         "url": "https://mcp.costfluent.com"
       }
     }
   }
   ```

2. Cursor asks you to sign in to the server. Costfluent opens in your browser: sign in, choose the organization Cursor may read and select **Allow**.
3. Ask Cursor's agent a question, such as "What did we spend on AWS last month, by service?".

</Stepper>

## Connect with an API token

For the write tools, send a token instead of signing in. The entry reads it from `COSTFLUENT_API_TOKEN` in Cursor's environment, so the file holds no token:

```json
{
  "mcpServers": {
    "costfluent": {
      "url": "https://mcp.costfluent.com",
      "headers": { "Authorization": "Bearer ${env:COSTFLUENT_API_TOKEN}" }
    }
  }
}
```

## Run it on your machine

<Stepper>

1. Run `costfluent mcp install --client cursor --write`. It adds the server to `~/.cursor/mcp.json`; with `--project` it writes `.cursor/mcp.json` in the current directory instead.
2. Set `COSTFLUENT_API_TOKEN` to the token in your shell, and start Cursor from that shell.
3. Ask Cursor's agent a question, such as "What did we spend on AWS last month, by service?".

</Stepper>

Instead of step 1, you can <a href="cursor://anysphere.cursor-deeplink/mcp/install?name=costfluent&config=eyJjb21tYW5kIjoiY29zdGZsdWVudC1tY3AiLCJhcmdzIjpbXSwiZW52Ijp7IkNPU1RGTFVFTlRfQVBJX1RPS0VOIjoiJHtlbnY6Q09TVEZMVUVOVF9BUElfVE9LRU59In19">add Costfluent to Cursor</a> in one click. The link adds an entry like the installer's, with the same reference to `COSTFLUENT_API_TOKEN`, but names `costfluent-mcp` without the full path the installer writes, so `costfluent-mcp` must be on the `PATH` Cursor sees, and step 2 still applies.

## How it behaves

- Signed in, Cursor gets the read tools alone, and never more than you may read yourself in that organization. It is listed under **Settings**, **Connected apps** in Costfluent, where **Revoke** disconnects it.
- Cursor started from the Dock does not see your shell's variables: start it from a shell, or point the entry's `envFile` at a file that sets the variable.
- `costfluent mcp install --client cursor --write --embed-token` writes the token itself into the entry, for a Cursor started where the variable is not set, and makes the file readable by you alone; see [Command line](/developers/cli#connect-an-assistant).

## Related

- [MCP server](/developers/mcp): the token, the tools and how the server behaves
- [Command line](/developers/cli#connect-an-assistant): every client `costfluent mcp install` writes for
- [costfluent/agent-skills](https://github.com/costfluent/agent-skills): the cost skills for Cursor's agent
- [Ask good questions](/developers/mcp#ask-good-questions) and [Troubleshooting](/developers/mcp#troubleshooting): asking for the right figures, and what each error means
