VS Code · agent mode · .vscode/mcp.json

Image generation in VS Code: MCP setup for GitHub Copilot

Add one HTTP server entry to .vscode/mcp.json, trust it when VS Code prompts, and eleven 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 imagemcpserver.com teamPublished Updated

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 has grown a gallery and a guided command since MCP landed, so hand-editing JSON is now the third option rather than the only one. They all write the same thing.

MCP server gallery

Extensions view → search @mcp

Install adds it to your user profile. Right-click and choose Install in Workspace to write it into .vscode/mcp.json instead.

Command Palette

MCP: Add Server

A guided flow that asks for the details and lets you target Workspace or Global. The quickest route if you would rather not write JSON.

By hand

.vscode/mcp.json

What this page documents. VS Code gives you IntelliSense on the schema as you type, so it is less error-prone than it sounds.

Whichever route you take, you have to trust it

VS Code asks you to confirm you trust a server before it will start it. 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. Checked September 2026.

The config, with the key kept out of git

Note the key is servers, not mcpServers — VS Code differs from Claude and Cursor here, and a config copied from one of those will silently do nothing.

The inputs block is the part worth copying. It makes VS Code prompt for the key once and store it locally, so the file you commit contains a placeholder rather than a live credential.

⚠️ 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. 1Create .vscode/mcp.json in the workspace root.
  2. 2Paste the config and save.
  3. 3Start the server from the action shown above the entry, trust it, and paste your key when prompted.
  4. 4Open the Chat view, switch to agent mode, and check Configure Tools.
.vscode/mcp.json
{
  "inputs": [
    {
      "id": "imagemcp-key",
      "type": "promptString",
      "description": "imagemcpserver API key",
      "password": true
    }
  ],
  "servers": {
    "imagemcp": {
      "type": "http",
      "url": "https://mcp.imagemcpserver.com/mcp",
      "headers": {
        "x-api-key": "${input:imagemcp-key}"
      }
    }
  }
}
safe to commit — the key is prompted for, not stored here

Where mcp.json lives

Three locations, and the third is the one people miss. A server defined in your user profile runs on your own machine — which is wrong if you are working over SSH, in a dev container or in Codespaces.

VS Code MCP configuration locations and what each covers
ScopeHow to open itCovers
Workspace.vscode/mcp.jsonShareable. Commit it and everyone who opens the repo gets the same servers.
User profileMCP: Open User ConfigurationEvery workspace on this machine. Each VS Code profile keeps its own.
RemoteMCP: Open Remote User ConfigurationRuns the server on the remote machine rather than locally — the one to use with dev containers, SSH and Codespaces.

The Agent Host caveat

The ${input:…} approach above is the right default, and it has one documented limitation worth knowing before it surprises you.

Sessions running on Agent Host do not read .vscode/mcp.json directly. VS Code forwards your server configuration to 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 Agent Host at the same time.

If you need the server available across Agent Host and other Copilot surfaces, use a workspace .mcp.json at the repository root, or a user ~/.copilot/mcp-config.json, and take the key from the environment instead. Checked September 2026.

.mcp.json · portable variant
{
  "servers": {
    "imagemcp": {
      "type": "http",
      "url": "https://mcp.imagemcpserver.com/mcp",
      "headers": {
        "x-api-key": "${env:IMAGEMCP_API_KEY}"
      }
    }
  }
}
key comes from the shell environment, so nothing is prompted

You do not have to enable all eleven

Configure Tools in the chat input is a real permission boundary. 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.

VS Code & Copilot questions

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

Three routes. Search @mcp in the Extensions view to install from the MCP server gallery. Run MCP: Add Server in the Command Palette for a guided flow. Or write the entry yourself in .vscode/mcp.json. All three end up in the same place — a servers block that VS Code reads.

How do I configure GitHub Copilot with MCP servers?

The server config is a VS Code concern rather than a Copilot one: once a server is added and trusted, its tools appear to agent mode automatically. Open the Chat view, switch to agent mode, and use Configure Tools in the chat input to see and toggle what is available.

Where does the MCP config go in VS Code?

Two places. .vscode/mcp.json in the workspace is shareable — commit it and the team gets the same servers. For every workspace on your machine, run MCP: Open User Configuration instead. If you work on a remote machine, MCP: Open Remote User Configuration puts the server on the remote rather than locally.

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

Use an input of type promptString marked as a password, and reference it as ${input:...} from the header. VS Code asks for the value the first time and stores it locally, so the committed file contains only the placeholder. See the Agent Host note on this page for the one case where that has a trade-off.

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 — VS Code asks you to confirm you trust a server before it will start, and a server sitting untrusted looks identical to one that is broken. After that, check the JSON is valid, 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. Configure Tools in the chat input 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.