# How to connect VS Code to a server

In VS Code, the GitHub Copilot agent talks to a server through MCP. You can run your own MCP server on a VPS and add its address, or connect a service whose MCP server already exists. Here is what each way takes.

## Tell your AI

1. Connect BitHut to your AI (Claude, ChatGPT or Codex): add the address `https://api.bithut.app/mcp`. How: https://bithut.app/connect.md
2. Then tell it:

```
Show my BitHut projects
```

## The short answer

VS Code works with MCP through GitHub Copilot: an MCP server offers the agent tools, such as "show the logs" or "restart the app", and the agent calls them while it works on your code. Without Copilot there is no agent to call them.

There are two ways to give VS Code such a server:

1. **Your own MCP server on your VPS.** You install it, give it a public HTTPS address, protect it with a sign-in and add that address to VS Code.
2. **A service that already runs an MCP server.** You add its address and sign in. BitHut works this way: there is nothing to install, and Copilot puts your projects online through it.

Everything below comes from the VS Code and GitHub documentation, read on 5 December 2026. One change matters if you followed an older tutorial: the `.vscode/mcp.json` file with a `servers` object belongs to the editor-managed setup, which VS Code calls deprecated and plans to remove in February 2027 ([MCP configuration](https://code.visualstudio.com/docs/agents/reference/mcp-configuration)). New setups go to the Copilot files below.

## What you need on the VS Code side

- **GitHub Copilot.** MCP and agent mode are included in Copilot Free, Pro, Pro+ and Max ([Copilot plans](https://docs.github.com/en/copilot/get-started/plans)). With a Business or Enterprise seat, your organization has to turn on the "MCP servers in Copilot" policy, which is off by default ([GitHub Docs](https://docs.github.com/en/copilot/how-tos/provide-context/use-mcp/extend-copilot-chat-with-mcp)).
- **VS Code 1.99 or later.**
- **Copilot picked as the agent** in the chat's session list.

## Where VS Code keeps the servers

For Copilot there are two places ([MCP configuration](https://code.visualstudio.com/docs/agents/reference/mcp-configuration)):

- `~/.copilot/mcp-config.json` for you, in every workspace on this computer;
- `.mcp.json` in the workspace root, to share the server with your team through the repository.

A remote server is one entry under `mcpServers`:

```json
{
  "mcpServers": {
    "my-server": { "type": "http", "url": "https://mcp.example.com/mcp", "tools": ["*"] }
  }
}
```

`type` is `http` (VS Code tries Streamable HTTP first and falls back to SSE). `headers` adds a key in a header if the server wants one.

You don't have to edit the file by hand. Run **Chat: Open Customizations**, go to **MCP Servers**, press **Add Server (+)**, choose **HTTP**, paste the address, give the server a name and pick **Copilot Global** (just you) or the workspace `.mcp.json` (the team). The command **MCP: Add Server** starts the same flow ([MCP servers](https://code.visualstudio.com/docs/agent-customization/mcp-servers)).

A service can also publish an install link, `vscode:mcp/install?…` or its web form `https://vscode.dev/redirect?url=…`. VS Code then opens the server's page for you to review before installing ([extension guide](https://code.visualstudio.com/api/extension-guides/ai/mcp)).

## Your own MCP server on a VPS

### What you need

- **An MCP server program.** Either one a service publishes, or one you (or your AI) write for your own tasks.
- **A public HTTPS address**, for example `https://mcp.example.com/mcp`: a domain, a certificate and a proxy in front of the program.
- **A sign-in.** VS Code handles OAuth itself. It first uses a client ID you set in the config, then a saved registration, then a Client ID Metadata Document if your server supports it, and Dynamic Client Registration as the last resort ([extension guide](https://code.visualstudio.com/api/extension-guides/ai/mcp)). If you register VS Code by hand, its callback addresses are `http://127.0.0.1:33418/` and `https://vscode.dev/redirect`. A client secret goes into VS Code's secret storage, not into the file.
- **Upkeep.** The program has to run day and night, restart after a crash or a reboot, and get updates. If the VPS is down, Copilot loses its tools.
- **A firewall** that leaves HTTPS open and closes everything you don't need.

### Working on the VPS itself

If you open the VPS in VS Code as a remote host, the address of an HTTP server doesn't change: storing the config on the remote side doesn't move the service ([manage MCP servers](https://code.visualstudio.com/docs/agents/run/manage-mcp-servers)). For Copilot sessions on a remote host, put the server into `.mcp.json` in that workspace or into the Copilot user file on that host: your local `~/.copilot/mcp-config.json` isn't carried over.

### Keep it safe

Copilot asks before a tool call unless your permission level or a saved approval says otherwise. You can allow a call once, for the session, or always; **Chat: Manage Tool Approval** shows the approvals per server and per tool, and **Chat: Reset Tool Confirmations** clears them ([approvals](https://code.visualstudio.com/docs/agents/run/approvals)). Servers from a workspace file follow Workspace Trust, so an untrusted folder can't start them. For your own VPS, our advice:

- **Never give an AI the root password** or a tool that runs any command as root. Give the MCP server its own user with access only to what it needs.
- **Keep keys out of `.mcp.json` in a repository**: anyone with the repository gets them.
- **Offer only the tools you need,** and keep global auto-approval off.
- **Read the call** before you approve anything that changes or deletes data.

## The BitHut way: nothing to host

If what you want from "VS Code on a server" is to put a site, a bot or a script online, you don't need a VPS of your own. BitHut already runs an MCP server at `https://api.bithut.app/mcp`. On the [Connect page](/connect#vscode) press **Add BitHut to VS Code**: VS Code opens with BitHut ready to install. Press **Install**, sign in to BitHut and press **Allow**.

Then you just talk to Copilot:

- "Put this project online on BitHut": it uploads the code, BitHut builds and checks it, and Copilot gets the address.
- "Why did my bot stop?": Copilot reads the logs and the error and fixes the code.
- "Roll back to yesterday's version": Copilot asks you to confirm, then does it.

Keys are stored apart from the code, sites start private behind a password page, and the price is fixed for the account: from $5 a month, see [pricing](/pricing). The first 14 days are free.

To be clear: we have not yet run BitHut with VS Code end to end ourselves. Other AIs and their steps are on the same [Connect page](/connect).

## When something doesn't work

- **There is no MCP in the chat.** Check that Copilot is picked as the agent and, with a Business or Enterprise seat, that your organization allows MCP servers.
- **The server doesn't start.** Run **MCP: List Servers**, pick the server and choose **Show Output** to read its log ([manage MCP servers](https://code.visualstudio.com/docs/agents/run/manage-mcp-servers)). The same list has Start, Restart and Authenticate.
- **A workspace server is blocked.** The folder isn't trusted; trust it, or run **MCP: Reset Trust** if you declined earlier.
- **The sign-in fails.** Press **Authenticate** on the server in **MCP: List Servers**; for a server without automatic registration, set a client ID in the config.
- **Old tools still show up.** Run **MCP: Reset Cached Tools**.
- **"Cannot have more than 128 tools per request".** This limit is documented for the editor-managed setup: open **Configure Tools** and switch off servers or tools you don't need ([tools](https://code.visualstudio.com/docs/agents/run/tools)).
- **BitHut is connected but Copilot doesn't answer about projects.** Ask it: "Show my BitHut projects." If it lists them, the connection works.
