Table of Contents
To secure MCP servers in an enterprise, deploy Hush Security to surface every agent and server, assign named human owners, and broker task credentials just in time. Hardening an enterprise deployment takes a structured, multi-phase rollout across developer workstations and production runtimes. This identity-first approach replaces static configuration secrets with strict least-privilege access managed from a single control plane.
This security model holds because the Model Context Protocol changes how applications access backend systems. Rather than routing queries through hardened API gateways with fixed integration schemas, client tools execute local commands and access internal data stores through dynamic model instructions. MCP servers act as bridges between language models and enterprise resources. When language models select tools based on natural language prompts, unmonitored agents and static credential files expose sensitive infrastructure to unauthorized actions, prompt injection, and credential leakage.
Before you start
Before deploying operational controls across your enterprise fleet, verify these baseline requirements:
- An inventory of approved AI developer clients (such as Cursor, VS Code, or Claude Code) across developer workstations.
- Administrative visibility into workstation configuration directories where local MCP files reside.
- An identity provider or credential broker that supports OAuth 2.1-style flows (authorization code with PKCE).
- Centralized log aggregation that can capture MCP tool-call traffic and server error/log streams.
What is MCP security and why does it matter?
Model Context Protocol security is the practice of authenticating, authorizing, isolating, and auditing the connections between AI models and external tools. The protocol, introduced by Anthropic in November 2024, standardizes how AI applications connect to external data sources and local tools. That standardization simplifies integration, but it also changes the enterprise attack surface. In traditional service architectures, engineers define explicit API calls with predictable schemas and fixed permissions. With MCP, client applications let large language models choose which tools to invoke, when to call them, and what parameters to pass, based on natural language prompts.
This dynamic invocation layer creates serious risks without administrative oversight. AI agents that touch external data can encounter prompt injection, where untrusted third-party input manipulates model instructions. According to OWASP guidance on MCP security, letting models dynamically execute tools with access to sensitive systems combines prompt injection, supply chain attacks, and confused deputy vulnerabilities. If an AI agent holds broad administrative tokens, a malicious input can trigger unintended tool execution against production databases or internal code repositories.
Treating these integrations as privileged infrastructure protects against unauthorized tool execution, lateral movement, and data exfiltration. Security teams must govern the protocol boundary by enforcing strong authentication, scoping tool permissions, and auditing all runtime activity.
| Security dimension | Traditional enterprise APIs | MCP servers |
|---|---|---|
| Caller invocation | Deterministic programmatic code | Natural language decisions by language models |
| Credential lifespan | Managed service credentials or user sessions | Frequently hardcoded personal tokens or static API keys |
| Parameter integrity | Rigid, validated API request schemas | Model-generated tool arguments influenced by prompt context |
| Execution environment | Controlled cloud containers or microservices | Local developer machines via stdio, or remote servers over HTTP |
What are the biggest security risks in MCP configuration files?
Configuration files are the primary vulnerability vector for MCP deployments, because they store launch commands and authentication secrets in plaintext. Desktop coding assistants and IDE plugins rely on configuration files (such as claude_desktop_config.json or project-level manifests) to define how to launch integration processes. Local MCP configurations specify a command plus an args array to start a server process over standard input/output (stdio). Because these files dictate what the host executes, an unsecured configuration directly exposes the machine to arbitrary command execution.
Static credentials embedded in these files create pervasive non-human identity (NHI) risk. Developers often paste long-lived personal access tokens, database connection strings, and cloud credentials straight into a server’s env block. The OWASP Non-Human Identities Top 10 names this pattern directly: Secret Leakage (NHI2:2025) and Long-Lived Secrets (NHI7:2025). When these files sit in unencrypted developer directories or shared repositories, any compromised endpoint or exposed repo hands over persistent enterprise access.
Below is an example of an insecure local configuration with static credentials and an unpinned package:
{
"mcpServers": {
"production-database": {
"command": "npx",
"args": ["-y", "@example/database-server@latest"],
"env": {
"DB_CONNECTION_STRING": "postgres://admin:SecretPassword123@db.internal:5432/prod",
"ENTERPRISE_API_KEY": "sk-live-99482472948729482749"
}
}
}
}
This configuration has two critical problems: it runs a package through a dynamic package runner with no version pinning or integrity check, and it exposes production credentials in plaintext. Remediation means replacing these blocks with centrally governed, short-lived credentials and pinned, sandboxed server binaries.
How should enterprises manage credentials and secrets used by MCP servers?
Enterprises should eliminate static tokens and move to short-lived, brokered authorization. Secrets stored in local JSON files or persistent environment variables stay valid until someone manually revokes them. Secure MCP management decouples credential lifecycles from developer machines and replaces static tokens with short-lived access tokens scoped to specific tasks.
The MCP specification draws a clear line by transport. Authorization is optional in MCP. Remote servers that use HTTP and implement authorization are expected to follow the spec’s OAuth 2.1-based flow: clients must use PKCE, treat the MCP server as an OAuth resource server, and request tokens bound to that specific server. Local stdio servers are outside that flow; the spec tells them to read credentials from the environment instead. That gap is exactly why so many secrets end up hardcoded in env blocks, and why centralized brokering matters for local servers.
Transport rules also apply to the handshake itself. Authorization endpoints must be served over HTTPS, and redirect URIs must be either HTTPS or localhost. As an added defense against Server-Side Request Forgery (SSRF), block private IP ranges (RFC 1918) when clients fetch OAuth metadata, so a malicious server cannot steer requests toward internal endpoints.
Platform engineering teams should apply these credential controls:
- Eliminate plaintext secrets: Ban raw credentials in local project files, user directories, and shell profiles.
- Enforce audience-bound tokens: Bind every token to the specific MCP server it is meant for (the spec uses RFC 8707 resource indicators). Never pass a client’s token through to downstream APIs; the spec explicitly forbids token passthrough.
- Implement just-in-time brokering: Issue task-specific tokens with lifetimes measured in minutes, not days or months.
- Validate redirect URIs: Use exact string matching against pre-registered URIs, and require TLS on every non-localhost channel.
Short-lived credentials shrink an attacker’s window if an agent environment is compromised.
How can organizations discover unmonitored AI agents and audit MCP server access?
Organizations need full visibility over their agent footprint before they can govern it. Desktop AI clients make it easy to create shadow integrations that connect unapproved models to production data without anyone’s knowledge. Because MCP servers install through ordinary package managers, engineers often add tools without a security review. You cannot protect internal databases if you cannot see which local processes talk to external language models.
Hush Security closes this blind spot by discovering and cataloging every agent and MCP server across developer workstations and cloud infrastructure, including the shadow ones nobody provisioned. Each agent gets its own identity and a named human owner, so every action traces back to an accountable employee. Security teams run policy from one control plane and can prove what every agent did on demand, replacing fragmented manual audits with automated discovery.
Effective auditing captures detailed telemetry for every invocation: the human behind the request, the tool invoked, the arguments the model passed, and the outcome. For local stdio servers, the protocol messages themselves travel over standard output, while diagnostic logs go to standard error. Capturing both gives teams the forensic record to reconstruct incidents, spot prompt injection payloads, and verify policy compliance. Scrub tokens and authorization headers from these logs before they are stored.
No agent touches a resource directly: identity and policy are checked first, and the gateway records every call.
How do you enforce least privilege and secure MCP servers in production?
Least privilege means limiting each tool to the exact operations a discrete business task needs. Default setups often grant broad admin rights to a whole data store or repository, letting an AI assistant delete, update, or change schemas when it only needed to read. Operations that change permissions, such as password resets, access grants, and account deprovisioning, belong in the strictest risk tier, behind mandatory confirmation.
A centralized policy gateway enforces these limits at scale. Placed in front of MCP servers, a gateway applies scope-based access, rate limiting, and token validation in one uniform layer instead of relying on each developer’s configuration. Isolation is the other half: the MCP specification does not define a sandbox, so enterprises must provide containerized execution boundaries that stop a compromised tool from reaching the host file system.
Production deployments should enforce these boundaries with deterministic controls that sit outside the model:
- Tool-level scope restriction: Break broad admin servers into granular tools with dedicated read-only scopes.
- Runtime container sandboxing: Run server processes in containers with read-only file systems and restricted network access.
- Deterministic approval gates: Require explicit user consent or secondary approval before an agent runs irreversible operations, following best practices for AI agent user consent. Reserve these gates for high-risk actions so routine work does not cause approval fatigue.
- Input and output sanitization: Validate every model-generated argument against a strict schema, and treat all model output as untrusted input.
What research exists on leaked credentials in public MCP configurations?
Public repositories show identity hygiene problems at scale. In The State of MCP Configuration, published by Hush Security in 2026, researchers analyzed roughly 82,000 public MCP configuration files across more than a dozen AI coding agents, including Claude Code, Cursor, VS Code, Windsurf, Gemini, OpenAI Codex, and JetBrains. The study examined how developers handle credentials when connecting coding assistants to repositories, databases, and third-party tools.
Key findings:
- Direct credential hardcoding: 12% of credential slots contained a hardcoded secret rather than a reference to an environment variable or secret store.
- Invisible to signature scanners: 55% of those hardcoded secrets have no recognizable pattern that traditional regex-based secret scanners can detect.
- Unprotected internal endpoints: Bearer tokens, private database connection URIs, and custom corporate auth headers frequently appear alongside public platform tokens.
Regex scanning falls short because proprietary API tokens, custom headers, and database credentials do not share uniform vendor prefixes. Hush Security discovers and inventories non-human credentials across repositories, secret managers, cloud platforms, Kubernetes, and SaaS based on identity context, not syntax alone. Mapping each credential to the identity that uses it lets teams find and revoke exposed keys before attackers use them to move laterally.
Common MCP implementation mistakes to avoid
- Permitting unreviewed shadow installs: Letting engineers pull unvetted community packages from public registries without container isolation or software composition review.
- Hardcoding secrets in env blocks: Pasting long-lived API keys into local JSON configuration instead of using just-in-time credential brokering.
- Granting full system privileges to local servers: Running MCP servers under the host user account with unrestricted read and write access to the file system.
- Over-relying on manual consent prompts: Expecting developers to approve dozens of routine prompts, which causes approval fatigue and rubber-stamping of destructive actions.
- Failing to centralize audit telemetry: Leaving execution logs on individual workstations where security teams cannot investigate credential misuse or prompt injection.
Next steps for enterprise security teams
Platform and security engineering teams should audit developer endpoints now for unmanaged MCP configuration files and hardcoded tokens. Organizations running AI coding assistants or deploying autonomous agents should evaluate the Hush Security AI agent and MCP security platform to discover shadow agents automatically, assign a named human owner to every non-human identity, and replace persistent secrets with just-in-time credential brokering.