> ## Content Index
> Fetch the complete content index at: https://claudefox.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Claude Code 2.1.327: claude mcp add-json can read from stdin, so MCP tokens stay off the command line
- URL: https://claudefox.com/claude-code-mcp-add-json-stdin-tokens/
- Published: 2026-11-18T03:24:55.000Z
- Updated: 2026-11-18T03:27:17.000Z
- Description: Claude Code v2.1.327 adds claude mcp add-json <name> -, which reads the server's JSON from stdin so a token never sits in your shell command. The same release fixes project-scope claude mcp add and remove deleting other keys from .mcp.json.
- Author: hupicake
- Tags: Tips

Claude Code v2.1.327, released on GitHub on November 17, changes one command for anyone who has been passing an MCP server's token as a command argument: claude mcp add-json <name> - now reads the server's JSON from stdin, "so tokens can stay off the command line", in the words of the release notes. The notes add one limit: it is not available inside a Claude Code session.

Until now the documented form was claude mcp add-json <name> '<json>', with the whole configuration as one command argument. The examples in Claude Code's MCP docs still show it that way, with an Authorization header or an --api-key argument written straight into the command. In most shells, a command like that is also saved to your shell history.

## How to use the stdin form

The trailing dash is the new part. The JSON itself has the same shape as the docs' add-json examples, for example an HTTP server with type, url and headers. Feeding it from a file uses ordinary shell input redirection; we have not run this on our own machine, so check the result with claude mcp get afterwards. Important: stdin keeps the token out of your command, not out of the config file (see below).

```
# weather-api.json, same shape as the docs' add-json example
{"type":"http","url":"https://api.weather.com/mcp","headers":{"Authorization":"Bearer ${WEATHER_TOKEN}"}}

# Claude Code v2.1.327 or later, in a normal terminal (not inside a Claude Code session)
claude mcp add-json weather-api - < weather-api.json

# then check that it connected
claude mcp get weather-api
```

add-json saves the configuration it receives. If the JSON holds a literal token, that token is written to the scope's config file: \~/.claude.json for local scope (the default) and user scope, .mcp.json for project scope. That is why the example above uses a ${VAR} reference rather than the token itself. The docs list the --scope flag for add-json in general; the release notes do not say anything different about it for the dash form.

## Three ways to keep a token out of the command, compared

- stdin (new in 2.1.327): the JSON is read from a pipe or file instead of the command line. Whatever the JSON contains, a literal token included, is still stored in the config file.
- ${VAR} expansion: write "Authorization": "Bearer ${API\_KEY}" in headers, url, command, args or env, and Claude Code fills it in from your environment. The config file holds only the variable name, and claude mcp list, claude mcp get and the /mcp detail view (v2.1.268 or later) show the reference by name, not the value. The docs present this as the way teams share configurations while keeping API keys out of them, which makes it our pick for a committed .mcp.json.
- headersHelper: a shell command Claude Code runs at connect time to produce headers, for tokens that expire. When the helper is the server's only source of the Authorization header, Claude Code retries an authentication error by running it again, so it can pick up a fresh credential. For a server in a project .mcp.json or at local scope, the helper runs only after you accept the trust dialog for that project directory.

The ${VAR} form has traps, all from the MCP docs. A variable that is not set and has no :-default leaves the literal ${VAR} text in place, with a warning in claude mcp list. A variable set to an empty string counts as set, so ${VAR:-default} expands to nothing; unset it to get the default. And in a remote server's url and headers, Claude Code deliberately reads its own and your cloud credentials as empty, names such as ANTHROPIC\_API\_KEY, ANTHROPIC\_AUTH\_TOKEN, AWS\_BEARER\_TOKEN\_BEDROCK and NPM\_TOKEN, with any :-default ignored, so a project's .mcp.json cannot ship them to a server it names. To send one of those on purpose, copy it into a variable with your own name first.

## Fixes for files Claude Code deleted or overwrote

The same release fixes three cases where Claude Code removed files or settings it should not have touched, and adds one guard. If you hit any of them, update.

- claude mcp add and claude mcp remove with project scope deleted other top-level keys from .mcp.json, such as $schema or another tool's servers.
- claude mcp add --scope project now stops, instead of overwriting the file, when .mcp.json lists its servers at the top level with no mcpServers key.
- Remote Control in worktree mode: stopping the server deleted a running session's git-ignored files, such as .env.
- Self-hosted runners started with --use-anthropic-git-proxy deleted a non-empty directory named by GIT\_CONFIG\_GLOBAL at startup. The runner now keeps it, ignores the variable and warns.

**Try it with your AI.** Copy this to your coding agent to move an MCP server's token out of your command and config file, using a variable instead.

```
I use Claude Code and want an MCP server's credential out of my command line and my
config files. Server name: [server name]. Scope it is in now: [local, user or project].

First check: claude --version. If the version is below 2.1.327, stop and tell me to
update before using the stdin form.

Rules: do not print, copy or open any token value or credential file. If you need to see
the current entry, tell me which file to open myself (~/.claude.json for local and user
scope, .mcp.json for project scope) and let me paste it with the token removed.

Then:
1. Draft a replacement JSON entry (type, url, headers or command, args, env) that uses
   ${VAR} expansion for the token, with a variable name of my own such as
   [MY_SERVICE_TOKEN]. Do not use ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN,
   AWS_BEARER_TOKEN_BEDROCK or NPM_TOKEN in a remote server's url or headers, because
   Claude Code reads those as empty there.
2. Show me the exact commands, each with --scope [scope], to remove the old entry with
   claude mcp remove and add the new one with claude mcp add-json [server name] -
   reading the JSON from a file. Wait for my OK before running anything.
3. Remind me to set [MY_SERVICE_TOKEN] in my own shell setup. Do not write the token
   yourself and do not delete any file.
```

## Also in 2.1.327

/export now asks before overwriting an existing file, and /export <name> keeps the file and tells you to run /export instead. /install-github-app asks before it changes a repository. /status lists broken agent, skill, command and output style files, keybinding errors, an unavailable sandbox, ignored permission settings and hook matchers that never match.

## FAQ

What does the dash in claude mcp add-json <name> - do? It tells add-json to read the server's JSON from stdin instead of from a command argument. It arrived in Claude Code v2.1.327 and is not available inside a Claude Code session.

Does the stdin form stop my token being saved in the config file? No. add-json stores the JSON it receives. Put a ${VAR} reference in the JSON so \~/.claude.json or .mcp.json holds the variable name, not the value.

Where does claude mcp add-json save the server? Local scope, the default, and user scope go to \~/.claude.json; project scope goes to .mcp.json at the project root.

Why does my MCP server get 'Bearer' with no token and return 401? You probably referenced a credential name Claude Code reads as empty in a remote server's url or headers, such as ANTHROPIC\_AUTH\_TOKEN. Copy the value into a variable with your own name and reference that instead.

What happens if a ${VAR} reference names a variable that is not set? Claude Code warns in claude mcp list and /mcp, naming the variable, and still loads the server with the ${VAR} text unexpanded.

Did an older Claude Code remove $schema from my .mcp.json? Before v2.1.327, project-scope claude mcp add and claude mcp remove could delete other top-level keys, including $schema and another tool's servers. Updating stops it happening again but does not bring them back; if .mcp.json is in git, you can restore the keys from an earlier commit.

## Related on claudefox

- [Kanzo puts a kanban board and an MCP server for coding agents in one 4.7 MB binary](https://claudefox.com/kanzo-kanban-mcp-coding-agents/)
- [BLA (bla-agents): a CLI and MCP server that trips AI reverse-engineering limits on release files](https://claudefox.com/bla-agents-mcp-cli-ai-reverse-engineering-defense/)
- [What a Claude Code mod can do on your machine, and the guard many solo users don't get](https://claudefox.com/what-a-claude-code-mod-can-do-and-the-guard-solo-users-dont-get/)
- [How the Claude Code team verifies agent work: a verify skill, REVIEW.md on a protected branch, and a commit gate](https://claudefox.com/claude-code-verify-skill-review-md-commit-gate/)

Source: [Claude Code v2.1.327 release notes (GitHub)](https://github.com/anthropics/claude-code/releases/tag/v2.1.327?ref=claudefox.com), [Claude Code docs: Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp?ref=claudefox.com)

This story first appeared in the [claudefox daily briefing for November 18, 2026](https://claudefox.com/daily-2026-11-18/).