Guide8 min read
MCP config in the repo: the terminal says [REDACTED], the file keeps your token
A committed MCP config either carries somebody's token or names a variable half the team never set. What we measured in Claude Code and Codex with the variable set, unset, empty or given a default, the three files, and the checks that make a missing token show up.

You want every clone of the repository to come with the team's memory server. So you run, once:
claude mcp add --transport http --scope project memory https://memory.example.com/mcp \
--header "Authorization: Bearer <your token>"
The terminal prints the header as [REDACTED], and it looks handled. The file the command wrote, .mcp.json, holds the value in plain text. You commit it. From that push on, your token is in every clone's history, and every teammate's agent reads and writes to the team's memory as you.
The careful version fails differently. You replace the value with ${TEAM_MEMORY_TOKEN} and commit that. A new teammate clones the repository and never exports the variable. Their sessions start, the server is marked failed in a status list nobody opens, and the agent answers from the repository alone for a week. Every run exits 0.
![Card: On screen, [REDACTED]. In .mcp.json, your token. Left, a terminal with Claude Code 2.1.329: the command claude mcp add --transport http --scope project memory https://memory.example.com/mcp --header with Authorization: Bearer lab-token-ana, and its answer: Added HTTP MCP server memory with URL https://memory.example.com/mcp to project config, Headers with Authorization: [REDACTED], marked “looks handled”, and File modified: .mcp.json. Right, the .mcp.json file it wrote, marked “the value in plain text”: mcpServers, memory, type http, the url and, under headers, the line Authorization: Bearer lab-token-ana, highlighted in red and linked to the [REDACTED] line. Below: git commit, then your token in every clone’s history, then every teammate’s agent reads and writes as you. In a dark band, the careful version: ${TEAM_MEMORY_TOKEN}, the new teammate never exports it, server failed, every run exits 0.](/img/blog/config-de-mcp-no-repositorio-sem-token-no-git/config-mcp.en.png)
When the variable is missing, none of the three stops
Claude Code, Codex and Cursor all accept a server config that lives in the repository: .mcp.json at the root, .codex/config.toml in the project, and .cursor/mcp.json. All three can name a variable instead of a value. They differ on what happens when it is not set.
- Claude Code. The docs say "the config still loads", with a warning in
claude mcp listand/mcp, and that it "uses the unexpanded ${VAR} text as-is". - Codex. "If no credential source resolves, Codex can connect to the server without authentication." With
required = truein the server's table, startup fails. - Cursor. The pages we read don't say.
Swapping the value for a variable trades the "token in git" failure for "server quietly missing". The second one has no alert.
What we measured
On November 30, 2026 we ran a lab on one Linux machine with Claude Code 2.1.329 and codex-cli 0.156.1, against a probe MCP server on 127.0.0.1 that logs the Authorization header it receives and answers 401 unless it is the expected one. Every value was a dummy. In Claude Code each case was one claude -p with stream-json output: the server status came from the system/init event, and what reached the server came from its log.
- Variable unset. Claude Code sent
Bearer ${TEAM_MEMORY_TOKEN}, the placeholder itself as the credential. Serverfailed, exit code 0. - Variable empty. It sent
Bearerand nothing after it.failed, exit code 0. - A default in the file. With
${TEAM_MEMORY_TOKEN:-lab-token-fallback}and the variable unset, it connected with the fallback. A default in a committed file is a committed credential. - A name another tool already uses. With
${NPM_TOKEN}set, the server received an empty bearer. In a remote server's url and headers, Claude Code reads a set of credential variables as empty, and the only trace was one line in the debug log.GITHUB_TOKENandVALORBRAIN_MCP_TOKENexpanded on this version. The docs give examples, not the whole list, so give the variable a name no other tool uses. - The listing is not the session.
claude mcp listshowed the server asPending approval, because nobody had approved it in an interactive session. In the same folder,claude -pconnected without asking, which is what the docs say it does with project servers. - Codex without
required. With the variable unset or empty,codex execprinted nothing about the server and made no request. - Codex with
required = true. The same situation became a failed start with the variable's name in the error:Environment variable TEAM_MEMORY_TOKEN for MCP server 'probe' is not set. - Codex in an untrusted project. The project config was ignored, and
codex mcp listansweredNo MCP servers configured yet.
The three files
One variable name for all three harnesses. Each file can go into git because it holds the name, not the value.
.mcp.json, for Claude Code:
{
"mcpServers": {
"memory": {
"type": "http",
"url": "https://memory.example.com/mcp",
"headers": { "Authorization": "Bearer ${TEAM_MEMORY_TOKEN}" }
}
}
}
.codex/config.toml, for Codex:
[mcp_servers.memory]
url = "https://memory.example.com/mcp"
bearer_token_env_var = "TEAM_MEMORY_TOKEN"
required = true
.cursor/mcp.json, for Cursor:
{
"mcpServers": {
"memory": {
"url": "https://memory.example.com/mcp",
"headers": { "Authorization": "Bearer ${env:TEAM_MEMORY_TOKEN}" }
}
}
}
If you create the Claude Code entry from the command line, put the placeholder in single quotes, --header 'Authorization: Bearer ${TEAM_MEMORY_TOKEN}', so your shell does not expand it first. In the lab that command wrote the placeholder. The same command with a pasted value wrote the value and printed [REDACTED] on screen. codex mcp add writes to the user config, so the Codex project file is one you write by hand.
Two things to say in the pull request that adds these files. The value lives in each person's environment, outside the repository: by what we read, none of the three reads a repository .env for a remote server's headers, and a .env is one git add . away from the history. And in Claude Code a project entry outranks a user entry with the same name, without merging fields. A teammate who had a working user-level memory server and never exported the variable finds it failed the morning after the merge.
Make a missing token show up
Three checks, cheapest first.
The first is a preflight in the repository, run by whatever the team already runs first: a make setup, a pre-commit hook, the job's first step.
#!/bin/sh
# scripts/check-mcp-env.sh
: "${TEAM_MEMORY_TOKEN:?is not set. The memory server will not connect. See docs/memory-setup.md}"
In the lab it exited 2 when the variable was unset or empty, and 0 when it was set. It checks that a value exists, not that the server accepts it.
The second is Codex's required = true, already in the file above. It is strict on purpose: a teammate who has not set the token cannot use Codex in that repository until they do. If the team prefers a softer start, drop required and keep the preflight.
The third is a gate for runs nobody watches. With claude -p, read the first event of the output and fail the job if any server did not connect:
claude -p "$(cat prompt.md)" --output-format stream-json --verbose > run.jsonl
jq -e 'select(.type=="system" and .subtype=="init") | .mcp_servers | all(.status=="connected")' run.jsonl
On the lab run without the variable, jq printed false and exited 1. With the variable, true and 0. In CI the variable comes from the runner's secret store under the same name, with a token issued for the runner and not borrowed from a person. We did not run this part on a CI runner.
One token per person
The committed file makes it easy to hand everybody the same value. Don't. With one token for the team, every write to the server has the same author. Revoking it because a laptop went missing disconnects everybody until each person updates their environment. And a copy that leaks is the team's whole access, with no way for the server to tell whose copy it was. One token per person costs each person one export line, and the CI runner gets its own.
If the token is already in the history
- Revoke the token on the server. It is the only step that ends the exposure: deleting the line, force-pushing or rewriting history does not reach the clones and forks that already have the value.
- Issue a new one, put it in the environment, and replace the value in the file with the placeholder.
- If the server keeps a log, look for the old token between the commit date and the revocation.
- Only then decide about the history. Once the token is dead, rewriting is optional and costs every teammate a fresh clone. Turn on your git host's secret scanning or a pre-commit scanner so the next one is stopped before the push.
What ValorBrain does and doesn't do
With ValorBrain, the three files are the ones above with the server named valorbrain, the URL https://mcpbrain.valor.digital/mcp and the variable VALORBRAIN_MCP_TOKEN. On the rest of the problem:
- One token per person is the model. Each person creates their own
vbm_token under Settings → MCP tokens. The workspace comes from the token, so the committed file is the same for any team and carries no workspace id. - Agents are told apart by headers, not by tokens. One person running Claude Code, Codex and Cursor uses one token. The harness and the agent identify themselves with
X-ValorBrain-HarnessandX-Source-Agent, which are not secrets. - Revocation is per token. Revoking in the app ends one person's token and nobody else's. The server stores a sha256 of the token, not the token.
- There is a path with no token to paste. The server speaks OAuth 2.1 with dynamic client registration: a client that supports it needs only the URL in the file and a sign-in per person.
- The first call says who you are.
memory_preparereturns your identity in the workspace. It is the quickest check that a teammate's export is theirs and not a value copied from someone else.
A note for current users: our install pages write the user-scope entry with the name valorbrain, the same as the project entry. In Claude Code the repository's entry replaces yours, so export VALORBRAIN_MCP_TOKEN before pulling the commit that adds .mcp.json.
What it doesn't do:
- It does not scan your repository. A
vbm_token committed by mistake is found by your git host's scanning or by you. Revoke it in the app. - It does not set the variable on anyone's machine. The preflight and
required = trueare what catch the teammate who skipped the export. - It does not expire a token created in the app. The token is valid until someone revokes it, so offboarding a person has to include the revocation.
- It does not decide trust or approval. Whether a cloned repository's server loads is the harness's call.
What we ran and what we didn't
We ran the cases above on one Linux machine, against a local probe server with dummy values: claude -p for each case, claude mcp list and claude mcp get, the mcp add commands, the preflight, the jq gate and Codex at startup. Our Codex was not signed in, so its rows show what happened to the MCP connection, and no model turn ran. We did not run Cursor, in the editor or the CLI: what is here about it is documentation. We also did not run a CI runner, Claude Code's interactive approval prompt, or the three ValorBrain files with a real token.
The full per-harness table, the whole lab, and Claude Code's headersHelper for teams that don't want a token in an environment variable are in the guide: One MCP config in the repo, no token in git.
ValorBrain works over MCP, in Claude Code, Codex, Cursor and any compatible client. The free plan needs no card: valorbrain.com.br.
Sources, read on November 30, 2026: Claude Code, MCP and Run Claude Code programmatically; Codex, Model Context Protocol; Cursor, MCP and MCP in the CLI. The tests are from November 30, 2026, with Claude Code 2.1.329 and codex-cli 0.156.1.
Next step
Less starting over. More continuity
Bring a real project. In one conversation we map where context gets lost between the people and agents on your team, and where to start.