Skip to main content
← All posts·
AI Infrastructure

MCP in Your Code Repository: How Model Context Protocol Changes AI-Assisted Infrastructure

Model Context Protocol (MCP) gives AI coding assistants structured access to your infrastructure context — Git history, Kubernetes state, CI/CD status, policy violations, and cost data. Here's how to deploy MCP servers in your code repository workflow and what it means for platform engineering.

Luca Berton14 min read

AI coding assistants are powerful but blind. They see the file you're editing and maybe a few open tabs. They don't see your Kubernetes cluster state, your CI/CD pipeline status, your Kyverno policy violations, your cost dashboard, or your incident history. Every time you need that context, you alt-tab, copy data, paste it into the chat, and hope the AI understands the format.

Model Context Protocol (MCP) fixes this. MCP is an open standard (created by Anthropic, adopted across the ecosystem) that gives AI assistants structured, real-time access to external data sources through a simple server interface. Instead of copying context manually, the AI queries MCP servers directly — and gets structured data it can reason about.

For platform engineering, this is transformative. Your AI assistant doesn't just help you write YAML — it writes YAML informed by your actual cluster state, policy requirements, cost constraints, and deployment history.

What MCP Actually Is

MCP is a client-server protocol. The AI assistant (Cursor, Claude Desktop, VS Code with Copilot) is the client. MCP servers expose tools and resources that the client can call:

  • Tools: Actions the AI can take — query a database, check cluster status, run a policy evaluation, look up cost data
  • Resources: Data the AI can read — configuration files, documentation, API schemas, architecture decision records
  • Prompts: Pre-built prompt templates that combine context from multiple sources into a structured request

The key insight: MCP servers are lightweight. A Kubernetes MCP server is a small process that translates AI requests into kubectl/API calls. A Git MCP server reads repository history. A cost MCP server queries your OpenCost/Kubecost API. Each one is simple; the power comes from combining them.

MCP Servers for Platform Engineering

1. Kubernetes Cluster MCP Server

Gives the AI real-time cluster awareness:

What the AI can ask the Kubernetes MCP server:

  • What pods are running in the ml-team-staging namespace?
  • → Returns pod list with status, resource usage, restart counts
  • What NetworkPolicies apply to the inference-api service?
  • → Returns NetworkPolicy YAML with evaluation of effective rules
  • Are there any pods in CrashLoopBackOff right now?
  • → Returns affected pods with last log lines and restart history
  • What's the GPU utilisation across all nodes?
  • → Returns per-node GPU util %, allocated vs available
  • Show me all resources that would be affected if I delete
  • this ServiceAccount"
  • → Returns dependency analysis: pods, deployments, jobs using it

Now when the AI generates a Kubernetes manifest, it knows the actual cluster state. It won't suggest a resource limit that exceeds your node capacity. It won't create a NetworkPolicy that conflicts with existing rules. It writes infrastructure that fits your reality, not a generic tutorial example.

2. Git Repository MCP Server

Gives the AI project history and team context:

What the AI can ask the Git MCP server:

  • What changed in the last 5 commits to this directory?
  • → Returns diffs with commit messages and authors
  • Who last modified the Kyverno policies?
  • → Returns author, date, commit message, and diff
  • Show me all PRs that touched NetworkPolicy files this quarter
  • → Returns PR list with descriptions and review comments
  • What's the deployment history for the inference-api service?
  • → Returns ArgoCD sync history from Git tags/annotations
  • Are there any merge conflicts in open PRs affecting this file?
  • → Returns conflicting PRs with file-level conflict analysis

When the AI suggests a change, it understands the history. "The last 3 changes to this file were security hardening by the security team — my suggestion should maintain that direction, not undo it."

3. CI/CD Pipeline MCP Server

Gives the AI build and deployment awareness:

What the AI can ask the CI/CD MCP server:

  • What's the current build status of the main branch?
  • → Returns pipeline status, last successful build, any failures
  • What security vulnerabilities were found in the last scan?
  • → Returns Trivy/Grype findings with severity and fix versions
  • What Kyverno policy violations would this manifest trigger?
  • → Runs policy evaluation against current policy set, returns results
  • Show me the SBOM for the current production image
  • → Returns CycloneDX/SPDX SBOM with dependency tree
  • What tests are failing and why?
  • → Returns failed test names, error messages, and relevant code

4. Cost and Capacity MCP Server

Gives the AI financial awareness:

What the AI can ask the Cost MCP server:

  • How much does the ml-team-staging namespace cost per month?
  • → Returns breakdown: compute, GPU, storage, network
  • What's the most expensive workload in the cluster?
  • → Returns top-10 by cost with utilisation percentages
  • If I add 2 A100 GPUs for this deployment, what's the monthly cost?
  • → Returns estimated cost based on current pricing
  • Which workloads are over-provisioned (low utilisation, high cost)?
  • → Returns workloads with utilisation under 30% and cost above threshold
  • What's the GPU reservation status? Any capacity available?
  • → Returns current allocation vs capacity with queue status

Now when the AI suggests infrastructure, it includes cost context. "This deployment will cost approximately 2,400 EUR/month. Based on the team's budget of 10,000 EUR/month and current spend of 7,200 EUR/month, this fits within budget." Infrastructure planning with financial awareness.

5. Policy and Compliance MCP Server

What the AI can ask the Policy MCP server:

  • What Kyverno policies apply to this namespace?
  • → Returns active policies with their rules and enforcement mode
  • Does this manifest comply with all cluster policies?
  • → Runs full policy evaluation, returns pass/fail per policy
  • What DORA/NIS2/AI Act requirements apply to this service?
  • → Returns applicable requirements based on service classification
  • Generate compliance evidence for the last deployment
  • → Returns: SBOM, scan results, policy evaluation, audit log entry
  • What's our current compliance posture for the AI Act?
  • → Returns per-system compliance status with gaps highlighted
📘 Book

Kubernetes Recipes

A practical guide for container orchestration and deployment by Grzegorz Stencel & Luca Berton (Apress).

Watch on Skillshare →

Integrating MCP Into Your Repository Workflow

Repository-Level MCP Configuration

MCP configuration lives in the repository, versioned alongside the code:

# .mcp/config.json (checked into Git)
{
  "servers": {
    "kubernetes": {
      "command": "mcp-kubernetes",
      "args": ["--kubeconfig", "~/.kube/config", "--context", "production"],
      "env": {
        "ALLOWED_NAMESPACES": "ml-team-*,platform-*",
        "READ_ONLY": "true"
      }
    },
    "git-history": {
      "command": "mcp-git",
      "args": ["--repo", "."],
      "env": {
        "MAX_COMMITS": "100",
        "INCLUDE_DIFFS": "true"
      }
    },
    "ci-pipeline": {
      "command": "mcp-cicd",
      "args": ["--provider", "github-actions"],
      "env": {
        "GITHUB_TOKEN_REF": "vault:ci/github-token",
        "INCLUDE_SECURITY_SCANS": "true"
      }
    },
    "cost": {
      "command": "mcp-opencost",
      "args": ["--endpoint", "http://opencost.monitoring:9090"],
      "env": {
        "CURRENCY": "EUR",
        "INCLUDE_GPU": "true"
      }
    },
    "policy": {
      "command": "mcp-kyverno",
      "args": ["--policy-dir", "policies/"],
      "env": {
        "REGULATIONS": "DORA,NIS2,AI-Act,CRA",
        "COMPLIANCE_MAPPING": "policies/compliance-map.yaml"
      }
    }
  }
}

When an engineer opens the repository in Cursor (or any MCP-compatible editor), these servers start automatically. Every team member gets the same context sources. The rulesets and skills combined with MCP servers create an AI assistant that knows your standards AND your current state.

Security Boundaries

MCP servers must respect security boundaries:

  • Read-only by default: MCP servers should query cluster state, not modify it. Changes go through Git (GitOps). The AI suggests changes; humans approve them in PRs
  • Namespace scoping: Engineers only see namespaces they have RBAC access to. The MCP server inherits the engineer's permissions, not cluster-admin
  • Secret filtering: MCP servers must redact secrets, tokens, and credentials from responses. The AI needs to know a secret exists, not its value
  • Audit logging: Every MCP query is logged. "Engineer X queried production pod status at 14:32." Same audit rigour as direct API access
  • Rate limiting: MCP servers should limit query frequency to prevent AI assistants from hammering the API. 10 queries per minute per server is a reasonable starting point

The Compound Effect: MCP + Rulesets + Skills

MCP alone is useful. Combined with project rulesets and shared skills, it's transformative:

  • Rulesets tell the AI your standards (how to write code)
  • Skills tell the AI your patterns (what to generate)
  • MCP tells the AI your reality (what exists, what's running, what it costs)

Together: the AI generates a Kyverno policy (skill) that follows your naming conventions (ruleset) and doesn't conflict with existing policies (MCP cluster query), fits within your compliance requirements (MCP policy evaluation), and costs within your team's budget (MCP cost query). That's not autocomplete — that's an informed engineering partner.

🎓 Course

Automating Azure DevTest Labs

Automate lab management and integrate with CI/CD pipelines.

Start on Pluralsight →

What Open Empower Delivers

  • MCP architecture design: Assess your infrastructure and design the MCP server topology — which data sources, which security boundaries, which team access patterns
  • MCP server deployment: Deploy and configure MCP servers for Kubernetes, Git, CI/CD, cost, and policy compliance — integrated with your existing infrastructure
  • Security and RBAC: Namespace-scoped access, secret filtering, audit logging, and rate limiting for all MCP servers
  • Ruleset + Skill + MCP integration: Combined configuration that gives your AI assistants standards, patterns, and real-time context in a single, version-controlled setup
  • Team rollout: Onboarding documentation, training sessions, and adoption tracking for MCP-enabled AI workflows

Your AI assistant should know your infrastructure as well as your senior engineers do. Let's give it the context it needs.

mcp
model context protocol
ai coding
cursor
copilot
code repository
platform engineering
kubernetes
gitops
developer experience

Need help applying this in your organization?

Get a free 30-minute assessment with actionable recommendations — whether we work together or not.

Book Your Free AI Platform Assessment

Or see AI readiness assessment scope & pricing

18+ years experience · Ex-Red Hat & Dell · Speaker at KubeCon EU 2026

Luca Berton

Written by

Luca Berton

CEO at Open Empower. 18+ years building enterprise infrastructure at JPMorgan Chase, Red Hat & Dell. Author of 9 technical books. Speaker at Red Hat Summit and KubeCon EU 2026. Instructor on Coursera, Pluralsight & Udemy.

Get more insights like this

Practical AI infrastructure and platform engineering guides — delivered to your inbox.

Subscribe to Newsletter →