Model Context Protocol (MCP) servers are how AI assistants and agents connect to your other tools: a database, a ticketing system, a CRM, a cloud account. Each connection needs a credential. Research published on September 18 shows those credentials are often stored in the worst possible place.
What the research found
Hush Security analyzed about 82,000 MCP configuration files in public GitHub repositories. The results:
- 12% of credential slots held hardcoded credentials, meaning real API keys and access tokens pasted directly into the file.
- 24% of the exposed credentials were broad-scope tokens designed never to expire.
- 53% of the classified credentials gave organization-, account-, workspace-, or database-wide access.
- 80% of the credentials from providers that support expiration didn't expire by default.
- 243 configurations had removed a secret from the current file, but it was still in Git history.
Hush Security's CEO, Micha Rave, described the root problem: MCP config files are meant to be committed and shared so a whole team can use the same setup. Traditional secret scanning was built for secrets that slip in by accident. Here they're included on purpose, often by people who didn't know better.
Why MCP makes this worse
A leaked database password is bad. A leaked token that an AI agent uses can be worse, because of what that token usually allows. MCP credentials tend to be broad, because the people creating them want the agent to "just work." They also tend to be long-lived, because nobody wants a connection breaking in the middle of a task. The result is a key that opens a lot and never expires, stored in a file built to be copied.
A practical cleanup guide
Step 1: Find what you already have
Search your repositories, including private ones, for MCP configuration files. Common names include .mcp.json, mcp.json, and client-specific settings files that contain an mcpServers block. For each server entry, write down which credential it uses and where that credential comes from.
Step 2: Rotate anything that was ever committed
This is the step teams skip most often. Deleting a secret from the file doesn't remove it from Git history. If a real credential was ever committed, assume it's compromised. Revoke it with the provider and issue a new one. Rewriting Git history is optional hygiene. Rotating the credential is required.
Step 3: Move credentials out of the file
Most MCP clients can read credentials from environment variables. The config file should reference the credential, not contain it:
{
"mcpServers": {
"tickets": {
"command": "tickets-mcp",
"env": { "TICKETS_API_TOKEN": "${TICKETS_API_TOKEN}" }
}
}
}
Exact syntax depends on the client, so check its docs. For shared or production setups, go one step further and have credentials injected from a secrets manager, not from individual developers' shell profiles.
Step 4: Narrow the scope
For each credential, ask: what does the agent actually need to do? If it only reads tickets, it shouldn't have a token that can delete projects. Where the provider supports it, create a dedicated, narrowly scoped credential for each MCP server instead of reusing a personal admin token.
Step 5: Turn expiration on
If the provider supports expiring tokens, use them. The research found that most tokens with an expiration option didn't use it by default, so this needs to be a deliberate choice. A token that expires in 90 days limits the damage from a leak nobody noticed.
Step 6: Stop it from happening again
- Add a pre-commit hook or CI check that blocks commits with high-entropy strings in MCP config files.
- Commit a template (such as
mcp.example.json) with placeholder values, and keep the real config in.gitignore. - Add MCP servers to your inventory of non-human identities: every agent credential should have an owner, a scope, and a review date.
The question reviewers will ask
As more companies adopt MCP, security reviewers are starting to ask about it directly: which MCP servers does your product or team use, and how are their credentials managed? A written answer that covers where credentials live, how they're scoped, and when they rotate is quick to produce once you've done the cleanup above. Without it, you'll struggle to answer.
Sources