> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP in 90 Seconds What It Is and Why Agents Need It

> Explains the Model Context Protocol and how agents use JSON-RPC to connect to tools like kubectl, plus steps to set up an MCP server with Kubernetes

Welcome back. This quick overview explains the Model Context Protocol (MCP), how agents use it to access external tools, and what you’ll set up in the hands‑on portion of this lesson.

What is MCP?

* MCP is an open standard that connects clients (typically language-model-driven agents) to tools and resources.
* Clients request actions via JSON-RPC messages, and servers advertise and execute the capabilities they expose (for example, CLI tools, cluster queries, or other automated tasks).
* Common transports include local stdio (a server process wrapping CLI tools) and remote transports such as HTTP or Server-Sent Events (SSE).

How it works (high level)

* A client sends a JSON-RPC request to perform an action.
* The server lists the tools and capabilities it can run (for example, kubectl operations).
* The server executes the requested tool and returns results back to the client.

Typical example tools an MCP server might expose:

```bash theme={null}
kubectl get
kubectl describe
kubectl logs
```

When an MCP server exposes Kubernetes tooling, a standard MCP image can wrap `kubectl` as MCP tools. You mount your kubeconfig into the MCP server container so the server can access the cluster using the same credentials `kubectl` uses. By default this setup is read‑only, but always verify permissions for your environment.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/T18tVEAgpbgJNg44/images/Building-Kubernetes-FinOps-AI-Agent/MCP-Gateway-for-Kubernetes/MCP-in-90-Seconds-What-It-Is-and-Why-Agents-Need-It/kubeconfig-mounted-mcp-server-kubectl-credentials.jpg?fit=max&auto=format&n=T18tVEAgpbgJNg44&q=85&s=16de4f019dc93750a29841272ef931bb" alt="A simple diagram showing a kubeconfig file mounted into an MCP Server (read-only by default), which then connects to a Kubernetes cluster with read access. The image notes these are the same credentials kubectl already uses." width="1920" height="1080" data-path="images/Building-Kubernetes-FinOps-AI-Agent/MCP-Gateway-for-Kubernetes/MCP-in-90-Seconds-What-It-Is-and-Why-Agents-Need-It/kubeconfig-mounted-mcp-server-kubectl-credentials.jpg" />
</Frame>

Lesson plan — what we’ll do

* Stage 1: Set up the MCP instance and connect it to the Kubernetes cluster you created.
* Stage 2: Use a simple client to prompt the MCP server and extract resource labels from the cluster.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/T18tVEAgpbgJNg44/images/Building-Kubernetes-FinOps-AI-Agent/MCP-Gateway-for-Kubernetes/MCP-in-90-Seconds-What-It-Is-and-Why-Agents-Need-It/setup-mcp-connect-cluster-extract-labels.jpg?fit=max&auto=format&n=T18tVEAgpbgJNg44&q=85&s=f2a9929a14ed5a5774fbbfefa19a6803" alt="A dark presentation slide titled &#x22;We'll do this in two stages&#x22; with two rounded boxes numbered 1 and 2. The boxes read &#x22;Set up the MCP — Connect to the cluster&#x22; and &#x22;Extract the labels — With a few prompts,&#x22; with a small KodeKloud logo at the corner." width="1920" height="1080" data-path="images/Building-Kubernetes-FinOps-AI-Agent/MCP-Gateway-for-Kubernetes/MCP-in-90-Seconds-What-It-Is-and-Why-Agents-Need-It/setup-mcp-connect-cluster-extract-labels.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Tip: When mounting your kubeconfig into an MCP server, verify what permissions that kubeconfig grants. The MCP image defaults to read-only behavior, but you should still follow your security best practices for credentials and least privilege.
</Callout>

Quick reference — MCP components and common transports

| Component | Purpose | Example / Notes |
| - | - | - |
| Client | Initiates actions using JSON-RPC | Typically an LLM-based agent that decides which tools to call |
| Server | Advertises and runs tools | Wraps CLIs (e.g., `kubectl`) or exposes APIs |
| Transport | How messages are sent | `stdio` (local process), `HTTP`, `Server-Sent Events (SSE)` |
| Tools | The actionable capabilities | `kubectl get`, `kubectl describe`, `kubectl logs` |

Links and references

* MCP repository: [https://github.com/microsoft/mcp](https://github.com/microsoft/mcp)
* JSON-RPC specification: [https://www.jsonrpc.org/specification](https://www.jsonrpc.org/specification)
* kubectl reference: [https://kubernetes.io/docs/reference/kubectl/](https://kubernetes.io/docs/reference/kubectl/)
* Kubeconfig concepts: [https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
* Server-Sent Events (SSE) overview: [https://developer.mozilla.org/en-US/docs/Web/API/Server-sent\_events/Using\_server-sent\_events/](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events/)

Next: we’ll walk through spinning up an MCP server that uses your kubeconfig and then run a few client prompts to extract labels from cluster resources.

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/building-kubernetes-finops-ai-agent/module/195615db-9bd2-4d1d-b899-9bd378d97521/lesson/250c1f26-d18a-4642-957f-34731980dfc3" />
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.