brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: .mcp.json can read ${VAR} so the team file holds no secrets

Claude
~/tips/tip-claude-mcp-json-env-expansion

claude mcp add --transport http shared-server --scope project https://example.com/mcp

Keeps secrets out of a shared .mcp.json by expanding environment variables.

A shared MCP config is a great idea until someone commits an API key into it.

Add the server with project scope and Claude Code writes it to .mcp.json in the project root, which you can commit.

claude mcp add --transport http shared-server --scope project https://example.com/mcp

Inside that file, ${VAR} and ${VAR:-default} are expanded, in the command, args, env, url and headers:

{
  "mcpServers": {
    "api-server": {
      "type": "http",
      "url": "${API_BASE_URL:-https://api.example.com}/mcp",
      "headers": {
        "Authorization": "Bearer ${API_KEY}"
      }
    }
  }
}

Everyone commits the same file, and each person sets API_KEY in their own environment.

The shape of the config, which servers exist and where they live, is a team decision and belongs in version control. The credentials are personal and belong in each person's environment. A new teammate clones the repo, sets one variable, and the server works, with no secret ever passing through git history.

If a variable is unset and has no default, the config still loads, the text ${VAR} stays as it is, and claude mcp list shows a warning. Also, Claude Code asks for approval before using project-scoped servers the first time. claude mcp reset-project-choices resets those answers.

Further reading: Connect Claude Code to tools via MCP – Claude Code docs, On this site: .claude/settings.local.json overrides the team file just for you, On this site: a skill can run shell commands before Claude reads it

More Claude tips /recap /focus /skill-doctor /autocompact 500k claude purge ~/work/my-repo --dry-run All Claude tips (83) All topics

Link