Security & privacy

Securing AI agents in DevOps with the Model Context Protocol

The Model Context Protocol connects AI assistants to infrastructure tools. Engineers must treat credentials like valet keys, limiting access to prevent accidental or malicious changes.

A valet key on a server rack representing secure AI access
Illustration created for this article

Connecting artificial intelligence assistants to development and operations infrastructure introduces significant security risks if not managed correctly. The Model Context Protocol (MCP) serves as the bridge between these AI agents and tools like Kubernetes, GitHub, or cloud providers, acting as an adapter that translates natural language requests into API calls. As of late 2026, engineers are urged to treat these connections with the same caution used for physical key management, ensuring that AI agents only possess the minimum necessary permissions to perform their tasks.

What happened

The core issue revolves around how MCP servers function as intermediaries. An MCP server takes a tool’s application programming interface and exposes it as a list of actions an AI assistant can execute. For instance, a GitHub MCP server allows an agent to list failing pull requests, while a Kubernetes MCP server enables it to query pod logs. While this automation reduces manual copy-pasting between windows, it also grants the AI potential write access to critical systems. Many developers overlook that even observability tools like Grafana or Datadog can modify dashboards or create monitors, meaning "read-only" assumptions are often incorrect without explicit configuration.

Security depends heavily on the type of credential provided to the MCP server. Older or locally hosted servers often rely on static environment variables, such as personal access tokens or cloud command-line profiles. This approach is risky because a token with broad administrative scope gives the AI the same level of access as the human who created it. If that token leaks through a configuration file or a compromised extension, the attacker gains full control over the connected resources. Newer hosted servers mitigate this by using OAuth flows, where users approve access via a browser, generating tokens bound to specific servers and scopes rather than leaving static keys in plain text.

Key details

  • MCP servers act as adapters, converting AI prompts into API calls for tools like AWS, Terraform, and PagerDuty.
  • Static credentials in environment variables pose high risks, whereas OAuth-bound tokens limit exposure to specific scopes.
  • Many servers offer read-only modes or toolset profiles that disable destructive actions like deleting resources.
  • Confirmation prompts are essential for production changes, requiring explicit user approval before executing state-modifying commands.
  • Prompt injection attacks can occur when AI agents read untrusted text from logs or issues, potentially tricking them into executing harmful tools.
  • Audit logs from both the MCP server and the target system provide necessary visibility into which actions the AI performed.

Background

The Model Context Protocol is an open standard designed to help AI applications access local and remote data sources. In a DevOps context, it allows large language models to interact with infrastructure as code, cluster management, and monitoring platforms. Without MCP, an AI assistant is isolated from your actual systems, limited to processing text you manually provide. With MCP, the assistant becomes an active participant in your workflow, capable of querying live data and triggering changes. This shift transforms the AI from a passive advisor into an active operator, necessitating robust identity and access management strategies similar to those used for human employees or service accounts.

Why it matters

For teams running their own software, the convenience of AI-driven operations must be balanced against the risk of unintended consequences. An AI agent with excessive permissions could accidentally delete a production database, modify security groups, or deploy untested code if it misinterprets a prompt or falls victim to prompt injection. Prompt injection occurs when malicious text embedded in logs or issue comments tricks the AI into executing a tool it should not use. By treating MCP credentials like valet keys—granting only the access needed for specific tasks—teams can prevent catastrophic errors while still leveraging automation.

Furthermore, proper segmentation of environments is critical. Using separate MCP server instances for staging and production ensures that an agent working in a development context cannot inadvertently affect live services. This separation, combined with strict read-only defaults and confirmation gates for write operations, creates a defense-in-depth strategy. It allows engineers to benefit from AI assistance in debugging and analysis without exposing their most critical infrastructure to unnecessary risk.

What you can do

  • Configure MCP servers to use OAuth wherever possible to avoid storing static tokens in environment variables.
  • Enable read-only modes for all servers initially, only granting write access after testing in non-production environments.
  • Separate MCP server instances for different environments, such as creating distinct entries for staging and production clusters.
  • Turn off auto-run features in AI clients like Cursor or VS Code for any server connected to production systems.
  • Implement confirmation prompts for any tool that modifies state, ensuring human approval before destructive actions.
  • Regularly review audit logs from both the MCP server and the underlying infrastructure to monitor AI activity.

More news

All news