VS Code · agent mode · .mcp.json

Image generation in VS Code: MCP setup for GitHub Copilot

Add one HTTP entry for the Image MCP Server to a portable .mcp.json or ~/.copilot/mcp-config.json, under mcpServers, and the 8 image tools appear to Copilot agent mode. Agent mode is allowed to act across files. Give it an image server and the assets stop being the one part of a feature that has to wait for a person.

By the Image MCP Server teamPublished Updated VS Code docs verified November 2026

configure tools

✓generate_image
✓edit_image
✓remove_background
✓upscale_image
✓text_to_svg
✓compress_image
+ 5 more from imagemcp

Three ways to add it

VS Code now has two configuration formats: the portable Copilot format, which Copilot sessions read directly, and the older VS Code format in .vscode/mcp.json. All three routes below can write the portable one.

Guided flow

MCP: Add Server

Asks for the details, then a destination: Copilot Global for ~/.copilot/mcp-config.json, or a workspace-root .mcp.json (offered while the experimental chat.mcp.workspaceRootConfig.enabled setting is on).

Discovery

MCP: Browse MCP Servers

Opens MCP discovery in the Extensions view, for servers published to a registry.

By hand

.mcp.json · ~/.copilot/mcp-config.json

What this page documents: a top-level mcpServers object with the key read from the environment.

Whichever route you take, it has to be trusted

Workspace servers inherit Workspace Trust, and servers from other sources get their own trust decision (MCP: Reset Trust clears those). An untrusted server looks exactly like a broken one — nothing in the tools list, no error worth reading — so this is the first thing to check when a correct config appears to do nothing.

The portable config, with the key kept out of git

The portable files take the same top-level key Claude and Cursor use, and VS Code resolves ${IMAGEMCP_API_KEY} from the environment of the host that connects to the server — so the committed file holds a reference rather than a live credential.

Portable files use mcpServers and ${NAME}; the servers key and ${env:…}/${input:…} only work in .vscode/mcp.json.

⚠️ If a key does get committed

Revoke it from the dashboard rather than rewriting history. Keys are individually revocable, and issuing a new one takes seconds.

  1. 1Export IMAGEMCP_API_KEY in the environment VS Code starts from.
  2. 2Create .mcp.json at the workspace root, or ~/.copilot/mcp-config.json for every workspace.
  3. 3Paste the config, save, and accept the trust prompt when it appears.
  4. 4Open the Chat view in agent mode and check the image tools are listed.
.mcp.json (workspace root) or ~/.copilot/mcp-config.json
{
  "mcpServers": {
    "imagemcp": {
      "type": "http",
      "url": "https://mcp.imagemcpserver.com/mcp",
      "headers": {
        "x-api-key": "${IMAGEMCP_API_KEY}"
      }
    }
  }
}
safe to commit — the key comes from the environment, not from this file

Where the config lives

Three locations. The first two are the portable format; the third is the older VS Code format, which still works but is the one VS Code is moving away from. For remote sessions — SSH, dev containers, Codespaces — the key variable has to be set on the remote host, because that is the host that connects to the server.

VS Code and Copilot MCP configuration locations and what each covers
ScopeFileCovers
Global~/.copilot/mcp-config.jsonEvery workspace on this machine. $COPILOT_HOME/mcp-config.json when COPILOT_HOME is set.
Workspace (shared).mcp.jsonAt the workspace root. Commit it and everyone who opens the repo gets the same server — with the key referenced, not pasted.
Legacy.vscode/mcp.jsonThe VS Code format with servers and inputs. Still read, but labelled deprecated in the guided flow.

Legacy .vscode/mcp.json (servers + inputs)

The ${input:…} approach below still works, but VS Code now marks this destination deprecated in its guided flow. It uses servers rather than mcpServers, and an inputs block that makes VS Code prompt for the key once and store it locally.

The catch: Copilot sessions do not read .vscode/mcp.json directly. VS Code forwards eligible servers from it — except servers that require interactive input, which is exactly what an input variable is. So a prompted key is safe in git and invisible to a Copilot session at the same time. The portable config above has neither problem.

.vscode/mcp.json · legacy VS Code format
{
  "inputs": [
    {
      "id": "imagemcp-key",
      "type": "promptString",
      "description": "Image MCP Server API key",
      "password": true
    }
  ],
  "servers": {
    "imagemcp": {
      "type": "http",
      "url": "https://mcp.imagemcpserver.com/mcp",
      "headers": {
        "x-api-key": "${input:imagemcp-key}"
      }
    }
  }
}
the key is prompted for, not stored here — and not forwarded to Copilot sessions

You do not have to enable all 11 tools

The tools picker is a real permission boundary — Chat: Open Customizations → Tools for a Copilot session, Configure Tools in the chat input for a Local one. Turning tools off is the simplest way to give an agent exactly the capability the task needs and nothing more.

Optimisation only

compress_image, convert_format

Cannot spend model credits at all. Every call costs 1 credit. Good for a repo-hygiene agent let loose on /public.

Post-processing

+ remove_background, upscale_image

Works on images you already have. Fixed, predictable per-image costs.

Full creative

everything

Can originate artwork. Worth pairing with an instruction to check the balance first.

Once GitHub Copilot is connected

GitHub Copilot gets the server’s 8 image tools, plus 3 utility tools for the credit balance, the model list and batching: 11 MCP tools in all. The ones most setups reach for first are the AI image generation API, Background removal API and AI SVG generator API; each page covers what the tool does and what a call costs. If the protocol itself is new to you, what is MCP explains how a client like GitHub Copilot finds these tools and calls them.

Setting up another client too? The Cursor MCP setup and Codex CLI MCP setup guides use the same endpoint and key in a different config shape.

VS Code & Copilot questions

How do I connect to an MCP server in VS Code?

Run MCP: Add Server from the Command Palette for the guided flow and pick a destination: Copilot Global writes ~/.copilot/mcp-config.json, and a workspace-root .mcp.json shares the server with your team. MCP: Browse MCP Servers opens discovery in the Extensions view, or you can write the entry yourself. The portable files use a top-level mcpServers object; only the legacy .vscode/mcp.json uses servers.

How do I configure GitHub Copilot with MCP servers?

Copilot sessions read the portable format directly — .mcp.json at the workspace root, or $COPILOT_HOME/mcp-config.json for your user, falling back to ~/.copilot/mcp-config.json. Once a server is added and trusted, its tools are available in agent mode; Chat: Open Customizations → Tools controls which ones a Copilot session can use.

Where does the MCP config go in VS Code?

For every workspace, Copilot Global: ~/.copilot/mcp-config.json (or $COPILOT_HOME/mcp-config.json). To share with a team, a workspace-root .mcp.json. The older .vscode/mcp.json and user-profile mcp.json still work, but VS Code labels those destinations deprecated in its guided flow.

How do I keep the API key out of the repository?

In the portable files, reference it as ${IMAGEMCP_API_KEY}. VS Code resolves ${NAME} from the environment of the host that connects to the server, and HTTP servers can use it in header values. The legacy .vscode/mcp.json uses an input of type promptString referenced as ${input:…} instead, but servers that need interactive input are not forwarded to Copilot sessions.

Do the tools work in Copilot chat, or only agent mode?

MCP tools are used by agent mode, where Copilot is allowed to take actions across files. Plain inline completion does not call tools at all.

Why is the server not starting?

Most often it has not been trusted yet: workspace servers inherit Workspace Trust, and servers from other sources get their own trust decision, and a server sitting untrusted looks identical to one that is broken. After that, check the JSON is valid and the key variable is set, and on a business or enterprise plan check whether an administrator has restricted MCP at the policy level.

Can I restrict which image tools it may use?

Yes. The tools picker — Chat: Open Customizations → Tools for a Copilot session, Configure Tools in the chat input for a Local one — is a real permission boundary. Leaving only compress_image and convert_format enabled, for example, gives you an optimisation assistant that cannot spend model credits.