# Connect VS Code and GitHub Copilot

VS Code connects to a gateway through an entry in `.vscode/mcp.json`, and GitHub Copilot uses the gateway's tools in agent mode. A person signs in with a gateway user. A setup that cannot open a browser sends an API key.

## Before you begin

- A gateway that serves at least one API. See [Create a gateway](https://docs.faustine.ai/agent-gateway/create-a-gateway/).
- A [gateway user](https://docs.faustine.ai/agent-gateway/gateway-users/) or an [API key](https://docs.faustine.ai/agent-gateway/api-keys/) in the environment you connect to.
- VS Code with GitHub Copilot. See [Use MCP servers in VS Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) in the VS Code docs.

The configuration on this page is in the gateway's **Connect** tab, under **VS Code / Copilot**, with your gateway's values filled in.

## Add the gateway

Add the server to `.vscode/mcp.json` in your workspace folder. `<gateway>` is the name VS Code shows for the server. The portal uses the gateway's slug.

**Gateway user**

```json filename=".vscode/mcp.json"
{
  "servers": {
    "<gateway>": {
      "type": "http",
      "url": "https://gateway.faustine.ai/<workspace>/<gateway>/mcp"
    }
  }
}
```

Then start the server and sign in:

1. Open the Command Palette and run **MCP: List Servers**.
2. Select the server, then **Start**. A browser window opens on the gateway's sign-in page.
3. Enter the username and password of the gateway user.

**API key**

Replace `<GATEWAY_KEY>` with the key you saved when you created it.

```json filename=".vscode/mcp.json"
{
  "servers": {
    "<gateway>": {
      "type": "http",
      "url": "https://gateway.faustine.ai/<workspace>/<gateway>/mcp",
      "headers": {
        "Authorization": "Bearer <GATEWAY_KEY>"
      }
    }
  }
}
```

> **Warning:** `.vscode/mcp.json` is part of the repository. Do not commit a file that contains an API key. Use a gateway user for a shared repository.

## Make the first call

Open Copilot Chat in agent mode and ask what it can do with the gateway, or ask for something the API returns, such as a list of contacts.

In the portal, the request appears in the gateway's **Logs** tab, and the **VS Code / Copilot** card in the **Connect** tab shows when the client was last seen.

VS Code cannot ask the person for a confirmation. For an operation that requires one, the gateway refuses the call unless the credential is set to **Run without asking**. A new gateway user and a new API key both start on **Refuse**. See [Confirmation](https://docs.faustine.ai/agent-gateway/confirmation/).

## Next steps

- [Scope a key or user](https://docs.faustine.ai/agent-gateway/scope-a-credential/): limit what Copilot can call.
- [Serving modes: Code and Tools](https://docs.faustine.ai/agent-gateway/serving-modes/): which tools the gateway gives Copilot.
- [Connect clients](https://docs.faustine.ai/agent-gateway/connect-clients/): the other clients a gateway supports.
