# Gemini CLI

Gemini CLI connects to the hosted [Costfluent MCP server](/developers/mcp) at `https://mcp.costfluent.com` from an `httpUrl` entry in its `settings.json`, and you sign in or send an API token. The Costfluent extension of [costfluent/agent-skills](https://github.com/costfluent/agent-skills) connects the same hosted server and adds the cost skills; to run the server on your machine instead, see [Run it on your machine](/developers/mcp#run-it-on-your-machine).

## Before you start

- To sign in, a Costfluent account in the organization Gemini CLI 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` on your `PATH`; see [Install the server](/developers/mcp#install-the-server).

## Connect and sign in

<Stepper>

1. Run `gemini mcp add --transport http costfluent https://mcp.costfluent.com`. It adds the server to `.gemini/settings.json` in the current project.
2. Start Gemini CLI and run `/mcp auth costfluent`. Costfluent opens in your browser: sign in, choose the organization Gemini CLI may read and select **Allow**.
3. Ask 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. Add the entry to `~/.gemini/settings.json`, or to `.gemini/settings.json` in a project; Gemini CLI replaces `${COSTFLUENT_API_TOKEN}` with the variable from its environment, so the file holds no token:

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

## Add the skills with the extension

<Stepper>

1. Run `gemini extensions install https://github.com/costfluent/agent-skills`. The extension connects the hosted server; run `/mcp auth costfluent` to sign in.
2. Start Gemini CLI and ask a question, such as "What did we spend on AWS last month, by service?".

</Stepper>

## How it behaves

- `httpUrl` is Gemini CLI's key for a Streamable HTTP server; its `url` key is for the older SSE transport, so the entry takes `httpUrl`.
- Signed in, Gemini CLI 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.
- The extension holds no token: it connects the hosted server and signs in, so Gemini CLI needs no `COSTFLUENT_API_TOKEN` in your environment.

## Related

- [MCP server](/developers/mcp): the token, the tools and how the server behaves
- [Ask good questions](/developers/mcp#ask-good-questions) and [Troubleshooting](/developers/mcp#troubleshooting): asking for the right figures, and what each error means
