Keep MCP Server API Keys Out of Claude Code Config Files and Git
The guide advises against placing raw API keys in .mcp.json, recommending OAuth sign-in where supported, or committing ${VAR} references and supplying values via environment variables or a secret manager. It explains that Claude Code's claude mcp add, add-json, and get commands write and display literal values, so passing a key directly stores it in plaintext. Configuration is stored in local, project, or user scope, each with different sharing implications, and local entries override project entries without merging fields. The author's tests on version 2.1.307 found that project-scope files are created with permissions readable by other users, and that get and list output reveals stored literals. Readers are cautioned to check their own CLI version, since redaction behavior has changed across releases.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in