Searching for an mcp.json example usually means you already know what an MCP server is and now need a durable host-side config: how to declare command / args / env, where the file lives, and why the same server works in one IDE and fails in another. This page is the host-config companion to building a server in the MCP server tutorial and hardening it in MCP server best practices. It is not a product UI tour for turning MCP on in any one editor.

01

Independence note

02

What mcp.json is for (vs the server itself)

The server package advertises tools/resources; the host config tells the IDE how to spawn or reach that process. Confusing the two causes most “MCP not loading” tickets: a correct server with a wrongcommand, cwd, or env still looks “broken” in the UI.

  • Server code: schemas, authz, side effects—see the tutorial.
  • Host mcp.json (or equivalent): transport, argv, env, optional headers/URL for remote.
  • Neither: production secrets committed next to the example.

Transport choice (stdio vs Streamable HTTP) belongs in selection notes— MCP stdio vs Streamable HTTP— then wire the matching keys here.

03

Common schema shape (illustrative)

Most local hosts share a mental model: a map of server name → launch descriptor. Exact top-level keys (mcpServers vs nestedservers) differ—copy from your host’s current docs, then adapt.

{
  "mcpServers": {
    "docs-search": {
      "command": "node",
      "args": ["./dist/server.js"],
      "env": {
        "DOCS_ROOT": "/absolute/path/to/docs",
        "LOG_LEVEL": "info"
      }
    }
  }
}

Remote / HTTP-style entries often add a URL (and sometimes headers) instead of command. Prefer env-based tokens over pasting API keys into the JSON that teammates commit.

{
  "mcpServers": {
    "issue-tracker": {
      "url": "https://mcp.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${ISSUE_TOKEN}"
      }
    }
  }
}

Whether ${…} interpolation works is host-specific. When in doubt, put secrets only in the host’s secret store or shell env that the spawned process inherits—never in a shared gist.

04

Env & secrets

  • Absolute paths in args when the host’s cwd is not your repo root.
  • Pin the runtime (node, uvx, npx) to a version your team actually has on PATH.
  • Pass API keys via env, not argv—argv shows up in process listings.
  • Least privilege: give the server only the scopes its tools need; see best practices.
  • Do not commit filled secrets; keep a mcp.json.example with placeholders if you share layout.

05

Multi-host differences (expect drift)

ConcernWhat often differs
Filename / locationProject .cursor/…, user-level app config, VS Code settings, Claude Desktop JSON—same idea, different paths.
Top-level keymcpServers vs product-specific nesting; some UIs edit JSON for you.
Transport fieldsstdio-only hosts ignore URL entries; remote hosts need URL + auth.
Env expansionSome expand $VAR; others require literal values or a separate secrets UI.
ReloadRestart app vs reload window vs toggle server—failures look like “bad JSON” when it is stale process.

Maintain one canonical server package; keep thin, host-specific launch snippets. Do not fork business logic per IDE.

06

Pitfalls that waste hours

  • stdout logging on stdio servers: corrupts the protocol—log to stderr.
  • Relative args without knowing cwd: host spawns from an unexpected directory.
  • npx/uvx without pins: silent major upgrades break schemas overnight.
  • Mixing transports in one mental model: stdio launch keys on an HTTP-only host entry.
  • Committing tokens in mcp.json “just for local” that later gets pushed.
  • Treating UI toggles as schema docs: always re-read the host’s current config reference after upgrades.

08

FAQ

Is this the official way to enable MCP in Cursor / VS Code?

No. This is a cross-host engineering note about config shape, env, and pitfalls. Product-specific “how to open the MCP panel” belongs in that product’s docs—we deliberately do not mirror those UI tours.

Where should mcp.json live?

Depends on the host: project-scoped vs user-scoped paths differ. Prefer project config when the server is repo-specific; user config for personal tokens. Confirm the path for your installed version.

How do I pass secrets safely?

Use env vars or the host’s secret store. Keep a placeholder example file in git; never commit live tokens. Rotate anything that was pasted into chat or screenshots.

stdio or HTTP in mcp.json?

Local single-user IDE agents usually spawn stdio servers withcommand/args. Remote or multi-user setups use URL-based entries. Decision notes: stdio vs Streamable HTTP.