# Claude Code

Claude Code connects to the hosted [Costfluent MCP server](/developers/mcp) at `https://mcp.costfluent.com` with one command, and you sign in or send an API token. The Costfluent plugin connects the same hosted server and adds the task skills of [costfluent/agent-skills](https://github.com/costfluent/agent-skills). To run the server on your machine instead, `costfluent mcp install` adds it alone.

## Before you start

- To sign in, a Costfluent account in the organization Claude Code should read. To send a token, an API token from the **Read only** preset, with write capabilities only if Claude Code may change objects; see [Create a token](/developers/mcp#create-a-token).
- To run the server on your machine, `costfluent-mcp` on your `PATH`; see [Install the server](/developers/mcp#install-the-server).

## Connect and sign in

<Stepper>

1. Run `claude mcp add --transport http costfluent https://mcp.costfluent.com`. Add `--scope user` to reach the server from every project, or `--scope project` to share it with your team through the project's `.mcp.json`.
2. In Claude Code, run `/mcp`, select `costfluent` and sign in. Costfluent opens in your browser: sign in, choose the organization Claude Code may read and select **Allow**.
3. Ask Claude Code a question, such as "What did we spend on AWS last month, by service?".

</Stepper>

## Connect with an API token

For the write tools, or where no one can sign in in a browser, send a token instead. Add the server to the project's `.mcp.json` with a reference to `COSTFLUENT_API_TOKEN`, which Claude Code reads from its environment when it starts:

```bash
claude mcp add --transport http --scope project costfluent https://mcp.costfluent.com --header 'Authorization: Bearer ${COSTFLUENT_API_TOKEN}'
```

The single quotes keep your shell from replacing the reference with the token, so the file holds `${COSTFLUENT_API_TOKEN}`, never the token. Start Claude Code from a shell where `COSTFLUENT_API_TOKEN` is set, and ask it a question.


## Add the skills with the plugin

<Stepper>

1. In Claude Code, run `/plugin marketplace add costfluent/agent-skills`.
2. Run `/plugin install costfluent@costfluent`. The plugin connects the hosted server, which `/mcp` lists as `costfluent`; sign in there.
3. Restart Claude Code and ask it a question, such as "What did we spend on AWS last month, by service?".

</Stepper>

## Run it on your machine

<Stepper>

1. Install the [command line](/developers/cli#install), which comes in the same release archive as the server.
2. In your project's directory, run `costfluent mcp install --client claude-code --write`. It adds the server to `.mcp.json` there, with a reference to `COSTFLUENT_API_TOKEN` rather than the token.
3. Start Claude Code from a shell where `COSTFLUENT_API_TOKEN` is set, and ask it a question.

</Stepper>

## How it behaves

- Claude Code renews the sign-in on its own until it ends, then `/mcp` asks you to sign in again. `claude mcp login costfluent` signs in from the shell, and **Clear authentication** under `/mcp` signs Claude Code out.
- A token Costfluent refuses in the header fails the connection; Claude Code does not fall back to signing in.
- The plugin holds no token: it connects the hosted server, and you sign in to it as above.
- Claude Code started without `COSTFLUENT_API_TOKEN` passes the server the text `${COSTFLUENT_API_TOKEN}` rather than a token, which the server takes for no token: it then uses the sign-in of `costfluent login`, and without one it stops and says so.

## Related

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