# VS Code

New agent sessions in VS Code run on its Copilot harness, which reads the same configuration file as GitHub Copilot CLI. A `"type": "http"` entry there connects to the hosted [Costfluent MCP server](/developers/mcp) at `https://mcp.costfluent.com`, 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` rather than writing it into the file.

## Before you start

- To sign in, a Costfluent account in the organization VS Code 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 `~/.copilot/mcp-config.json`, or to `mcp-config.json` in `COPILOT_HOME` when that is set. If `costfluent mcp install` wrote a `costfluent` entry there before, replace it:

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

2. Start a new agent session. When VS Code offers **Authenticate** among the session's server actions, select it. Costfluent opens in your browser: sign in, choose the organization VS Code may read and select **Allow**.
3. Ask a question, such as "What did we spend on AWS last month, by service?". Expand the tool call to see that the `costfluent` server answered.

</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 VS Code's environment, so the file holds no token:

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

## Run it on your machine

<Stepper>

1. Run `costfluent mcp install --client copilot --write`. It adds the server to `~/.copilot/mcp-config.json`, or to `mcp-config.json` in `COPILOT_HOME` when that is set, the file VS Code reads for a server used across your workspaces.
2. Set `COSTFLUENT_API_TOKEN` to the token in the environment VS Code starts from, and restart VS Code so it takes the variable up. Or set no variable and run `costfluent login` once: the server then uses that [sign-in](/developers/cli#sign-in).
3. Start a new agent session and ask a question, such as "What did we spend on AWS last month, by service?". Expand the tool call to see that the `costfluent` server answered.

</Stepper>

## How it behaves

- The entry is yours rather than a project's: it reaches every workspace on this machine, and Copilot CLI reads the same one, connecting with the API token entry.
- Signed in, VS Code gets the read tools alone. It is listed under **Settings**, **Connected apps** in Costfluent, where **Revoke** disconnects it.
- The file holds no token. VS Code started from the Dock or the Start menu does not see your shell's variables: start it from a shell where the variable is set, or use the sign-in of `costfluent login`, which reads the one organization you approved and never offers the write tools.

:::note
`costfluent mcp install --client vscode` writes a project's `.vscode/mcp.json` with a token prompt instead. Only sessions on VS Code's Local harness receive that entry: the Copilot harness does not take a server that asks for its token. VS Code has deprecated the Local harness and removes it in February 2027.
:::

## 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
- [Copilot CLI](/developers/assistants/copilot-cli): the same entry, with the Costfluent plugin's cost skills
- [Ask good questions](/developers/mcp#ask-good-questions) and [Troubleshooting](/developers/mcp#troubleshooting): asking for the right figures, and what each error means
