Safeguard
AI Security•

A security checklist for MCP servers in VS Code

VS Code can run MCP servers from workspace files, and local servers can run arbitrary code. A checklist on trust, config location, secrets and sandboxing.

Safeguard Security Team
3 min read

MCP servers you add to VS Code can run code on your machine, and a repository can carry its own MCP configuration. Review where each server comes from, keep secrets out of config files, and treat workspace MCP files like any other executable project file.

Local servers run code

The VS Code documentation warns that local MCP servers can run arbitrary code on your machine. Review the publisher and configuration before you start one, the same way you would review an extension. See what an extension can do for the comparable reasoning.

How trust works

  • Servers in .vscode/mcp.json and a workspace root .mcp.json inherit Workspace Trust. In a trusted workspace they start without a separate prompt. In Restricted Mode they are blocked.
  • Servers from other sources prompt on first start or after a configuration change. If you decline, the server does not start.
  • MCP: Reset Trust resets those decisions without changing Workspace Trust.

So trusting a repository can start its MCP servers without another question. Read the MCP files before you trust.

The checklist

  1. Read the config location. Workspace files can be shared through source control, so a repository can introduce servers for everyone who opens it. User level files apply across workspaces.
  2. Review each server. Who publishes it, what command it runs, and what arguments and environment it receives.
  3. Keep secrets out. The documentation says to avoid hardcoding sensitive information like API keys. Use input variables or environment files.
  4. Consider sandboxing. On macOS and Linux you can set sandboxEnabled and restrict file reads, file writes and network domains. The documentation notes that tool calls from a sandboxed server are auto approved, and that sandboxing is not available on Windows.
  5. Check autostart. The default newAndOutdated setting starts servers when you submit a chat message, including servers whose configuration changed. Setting chat.mcp.autostart to never does not stop a Copilot harness session from starting its configured servers.
  6. Limit discovery. When discovery is enabled, VS Code can reuse server configurations from other applications and forward eligible ones to Copilot harness sessions.
  7. Think about sync. MCP server configs are one of the categories Settings Sync can copy. See what syncs.
  8. For teams. Organisations can control MCP access centrally through Copilot enterprise managed settings.

What to do on an unfamiliar repository

Stay in Restricted Mode, read .vscode/mcp.json and .mcp.json, and only then decide on trust.

An example of how it goes wrong

A repository includes a .vscode/mcp.json that defines a server which runs a package fetched at start time. A developer opens the repository, trusts the folder to get their tools working, and the server starts when they send their first chat message. The trust decision covered the whole folder, and the MCP file was part of it. Reading the file first would have taken one minute.

Where to go next

Treat MCP servers like dependencies: know who publishes them, pin what you can, and keep the list short. For a team, decide which servers are approved, where their configuration lives, and who may add one.

Quick check

Does Reset Trust change Workspace Trust?

No. The documentation says MCP: Reset Trust does not change Workspace Trust.

Is sandboxing a complete fix?

No. It limits file and network access on macOS and Linux, but it is unavailable on Windows and tool calls from the server are auto approved.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.