<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mahendran Selvakumar on Medium]]></title>
        <description><![CDATA[Stories by Mahendran Selvakumar on Medium]]></description>
        <link>https://medium.com/@skmahe1077?source=rss-b05127d2ebbb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YKxAjOGGTmbpx78b6yDSLw.jpeg</url>
            <title>Stories by Mahendran Selvakumar on Medium</title>
            <link>https://medium.com/@skmahe1077?source=rss-b05127d2ebbb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:44:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@skmahe1077/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Terraform MCP Server with Open Policy Agent for Platform Engineering]]></title>
            <link>https://devopstronaut.com/terraform-mcp-server-with-open-policy-agent-for-platform-engineering-7340e63bc68b?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7340e63bc68b</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[terraform-mcp-server]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 10:53:47 GMT</pubDate>
            <atom:updated>2026-08-31T10:53:47.093Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_xrclnMDj9ZZ-IIz6GNkzg.png" /></figure><p>AI assistants can help engineers write Terraform, but infrastructure code needs more than a plausible answer.</p><p>Provider versions change. Arguments are deprecated. Resource schemas evolve. An assistant relying only on its training data may suggest outdated configuration or unsupported arguments.</p><p>The Terraform MCP Server helps address the context problem by allowing an AI assistant to query current Terraform Registry information. Open Policy Agent and Conftest address a different problem: deciding whether the proposed infrastructure meets platform and security requirements.</p><p>This article explains how these tools can work together in a local platform engineering workflow.</p><h4>What is the Terraform MCP Server?</h4><p>The Terraform MCP Server is an open-source Model Context Protocol server maintained by HashiCorp. It connects MCP-compatible clients to Terraform tools and information.</p><p>Instead of relying only on model memory, an assistant can call tools to search the Terraform Registry, inspect provider resources, retrieve data-source documentation, find modules, and check versions.</p><p>For example, an engineer can ask:</p><ul><li>Search for the AWS provider in the Terraform Registry.</li><li>Show the details of the aws_instance resource.</li><li>Find public Terraform modules for a VPC.</li><li>Check the latest version of the HashiCorp AWS provider.</li></ul><p>The assistant selects the appropriate MCP tool, sends the required parameters, and uses the returned Registry information to prepare its response.</p><p>The public Registry toolset is enabled by default. The available tools include:</p><ul><li>search_providers</li><li>get_provider_details</li><li>get_latest_provider_version</li><li>search_modules</li><li>get_module_details</li><li>get_latest_module_version</li></ul><p>The project is available in the <a href="https://github.com/hashicorp/terraform-mcp-server">HashiCorp Terraform MCP Server repository</a>.</p><h4>Why this matters for platform engineering</h4><p>Platform teams often provide reusable Terraform modules, templates, service catalogues, and documented deployment patterns.</p><p>AI assistants introduce another interface for consuming those platform capabilities. Engineers can describe what they need in natural language, while the assistant uses Terraform tools to find the relevant provider or module information.</p><p>However, access to current documentation does not guarantee that the generated infrastructure follows organisational standards.</p><p>A configuration can be valid Terraform and still create:</p><ul><li>A security group open to the internet</li><li>An unencrypted storage bucket</li><li>A publicly accessible database</li><li>Resources without mandatory tags</li><li>An instance type that is not approved</li><li>Infrastructure in a restricted region</li></ul><p>The Terraform MCP Server improves the information available to the assistant. It does not replace infrastructure review or policy enforcement.</p><h4>Running the Terraform MCP Server locally</h4><p>The server can run locally using Docker and the default Stdio transport.</p><p><strong>Clone the repository:</strong></p><pre>git clone https://github.com/hashicorp/terraform-mcp-server.git<br>cd terraform-mcp-server</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UJrPnR5_vGI5EHh6.png" /></figure><p><strong>Build the development image:</strong></p><p>Now build the Docker image locally using below command</p><pre>make docker-build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EF3P6rVnAyhrN742.png" /></figure><p>This command builds the Terraform MCP Server Docker image locally. After the build is completed, the local Docker image can be used for MCP server configuration and testing.</p><p>The local development image is usually available as terraform-mcp-server:dev</p><p><strong>Running the Server in stdio Mode</strong></p><p>The Terraform MCP Server can be started in stdio mode by running the following command.</p><pre>docker run -i --rm terraform-mcp-server:dev</pre><p>This starts the Terraform MCP Server using standard input and output communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y6XElSYWNq_XGBER.png" /></figure><p>This mode is commonly used when the MCP server is connected directly to an AI assistant such as Claude Desktop, Cursor, VS Code, or Claude Code CLI.</p><p>In this setup, the AI assistant starts the Docker container and communicates with the Terraform MCP Server through the MCP protocol.</p><p>Stdio is useful for local integrations because the MCP client starts the container and communicates with it through standard input and output.</p><p><strong>Configuring Terraform MCP Server in Claude Desktop</strong></p><p>After building the Terraform MCP Server Docker image locally, I configured it in Claude Desktop.</p><p>Claude Desktop uses a JSON configuration file to define local MCP servers. In this case, I added a new MCP server named terraform.</p><p>The configuration looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xH8dh4VLrmK3-UNk.png" /></figure><p>In this configuration, Claude Desktop uses Docker to start the locally built Terraform MCP Server image.</p><p>The command value is set to docker.</p><p>The args section tells Docker to run the container in interactive mode, remove the container after it stops, and use the local image named terraform-mcp-server:dev.</p><p>Here is what each argument means:</p><ul><li>run starts a new Docker container.</li><li>-i keeps standard input open so Claude Desktop can communicate with the MCP server.</li><li>--rm removes the container automatically after it stops.</li><li>terraform-mcp-server:dev is the locally built Terraform MCP Server Docker image.</li></ul><p>After saving this configuration, restart Claude Desktop.</p><p>Then open Claude Desktop settings and go to:</p><p>Settings → Developer → Local MCP servers</p><p>You should see the `terraform` MCP server listed as running.</p><p>This confirms that Claude Desktop successfully started the Terraform MCP Server using the local Docker image.</p><p>Press enter or click to view image in full size</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kwbdL94lQw9eDzuc.png" /></figure><p><strong>Verifying a Registry tool call</strong></p><p>After configuring the Terraform MCP Server in Claude Desktop, I verified whether Claude was actually using the MCP server.</p><p>I asked Claude the following prompt:</p><pre>Search for the AWS provider in the Terraform Registry</pre><p>Claude started by identifying that it should use the Terraform tool to search the AWS provider in the Terraform Registry.</p><p>In the response, I could see that Claude loaded the available Terraform MCP tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ye_K7Hgc4NJRennQ.png" /></figure><h4>Accurate documentation is not a security control</h4><p>The Terraform MCP Server can help an assistant produce version-aware Terraform configuration, but it does not decide whether that configuration is safe for your environment.</p><p>This is where policy as code becomes useful.</p><p>A platform team can evaluate the Terraform plan before allowing an apply. The policy decision remains consistent whether the code was:</p><ul><li>Written manually</li><li>Generated by an AI assistant</li><li>Produced from an approved module</li><li>Created through a service catalogue</li><li>Submitted through a CI/CD pipeline</li></ul><p>The policy evaluates the proposed infrastructure, not how the code was written.</p><h4>What is Open Policy Agent?</h4><p><a href="https://www.openpolicyagent.org/">Open Policy Agent</a> is an open-source, general-purpose policy engine.</p><p>OPA evaluates structured input, usually JSON, against policies written in Rego. It returns a policy decision that another system can enforce.</p><p>OPA can be used across different parts of the technology stack, including:</p><ul><li>Kubernetes resources</li><li>Terraform plans</li><li>API requests</li><li>Container metadata</li><li>Application authorisation</li><li>CI/CD pipelines</li></ul><p>For Terraform, the input can be the JSON representation of a saved plan. This allows the policy to evaluate the changes Terraform intends to make before those changes are applied.</p><p>The official <a href="https://www.openpolicyagent.org/docs/terraform">OPA Terraform documentation</a> describes this plan-based policy model.</p><h4>What is Conftest?</h4><p><a href="https://www.conftest.dev/">Conftest</a> is a command-line tool built on Open Policy Agent.</p><p>It runs Rego policies against structured configuration files, including JSON, YAML, Kubernetes manifests and Terraform plan output.</p><p>Conftest is useful in platform workflows because it produces a standard command result:</p><ul><li>Exit code 0 when the tests pass</li><li>A nonzero exit code when a policy rule fails</li></ul><p>A local script or CI/CD pipeline can use that result to stop the workflow before terraform apply.</p><h4>Creating a Terraform plan for policy evaluation:</h4><p>Create a saved Terraform plan:</p><pre>terraform init <br>terraform plan -out=tfplan</pre><p>Convert the saved plan into JSON:</p><pre>terraform show -json tfplan &gt; tfplan.json</pre><p>The JSON contains planned resource changes, actions and values that can be evaluated by OPA.</p><p>Policy checks are limited to information available at plan time. Computed or unknown values may not be available until Terraform applies the change.</p><p><strong>Example policy: block public SSH access</strong></p><p>The following Rego policy checks an AWS VPC security group ingress rule. It denies the plan when port 22 is accessible from 0.0.0.0/0.</p><p>Create a policy directory:</p><pre>mkdir policy</pre><p>Create policy/security.rego:</p><pre>package main<br><br>deny contains msg if {<br>  some resource in input.resource_changes<br><br>  resource.type == &quot;aws_vpc_security_group_ingress_rule&quot;<br>  resource.change.after.cidr_ipv4 == &quot;0.0.0.0/0&quot;<br>  resource.change.after.from_port &lt;= 22<br>  resource.change.after.to_port &gt;= 22<br><br>  msg := sprintf(<br>    &quot;%s allows SSH access from the internet&quot;,<br>    [resource.address]<br>  )<br>}</pre><p>This example uses aws_vpc_security_group_ingress_rule. If your Terraform configuration uses inline ingress blocks or another security group resource type, adjust the policy to match the corresponding plan JSON structure.</p><p><strong>Testing the plan with Conftest</strong></p><p>Run Conftest against the Terraform plan:</p><pre>conftest test tfplan.json --policy policy/</pre><p>If the plan contains public SSH access, Conftest returns a failure similar to:</p><pre>FAIL - tfplan.json - main - aws_vpc_security_group_ingress_rule.ssh allows SSH access from the internet</pre><p>Because the command returns a nonzero exit code, the next stage can be prevented from running.</p><p>A simple local workflow could use:</p><pre>set -e<br><br>terraform plan -out=tfplan<br>terraform show -json tfplan &gt; tfplan.json<br>conftest test tfplan.json --policy policy/<br>terraform apply tfplan</pre><p>With set -e, the script stops when Conftest reports a policy failure. Terraform apply is reached only when the policy test succeeds.</p><p>A production workflow should also include appropriate review, plan handling, credentials, state protection and approval controls.</p><h4>Separating context from control</h4><p>Terraform MCP Server, OPA and Conftest solve different problems.</p><p>The Terraform MCP Server provides current Terraform context to the AI assistant.</p><p>Terraform creates an explicit plan showing the proposed infrastructure changes.</p><p>OPA evaluates those changes against policies written in Rego.</p><p>Conftest turns the policy result into a local or CI/CD gate.</p><p>Human approval provides accountability before the approved plan is applied.</p><p>Keeping these responsibilities separate makes the workflow easier to understand and operate.</p><h4>Platform engineering use cases</h4><p>This pattern can support policies such as:</p><ul><li>Block public SSH or RDP access</li><li>Require encryption for storage services</li><li>Restrict cloud regions</li><li>Enforce mandatory tags</li><li>Limit approved instance types</li><li>Prevent publicly accessible databases</li><li>Require logging and monitoring</li><li>Reject destructive changes to protected resources</li></ul><p>Platform teams can maintain these rules centrally while allowing engineers to use different Terraform authoring tools.</p><p>The same policies apply whether an engineer uses an IDE, an AI assistant, a reusable module or a self-service portal.</p><h4>Conclusion:</h4><p>Terraform MCP Server gives AI assistants access to current Terraform information through visible tool calls.</p><p>That improves the quality and traceability of the context used to create infrastructure code. It does not remove the need for review or policy enforcement.</p><p>OPA and Conftest provide the guardrail layer. They evaluate the Terraform plan and stop changes that do not meet platform requirements.</p><p>Together, these tools provide a practical pattern for platform engineering:</p><ul><li>Use current Terraform information</li><li>Generate an explicit plan</li><li>Evaluate the plan against policy</li><li>Review the permitted changes</li><li>Apply only after the required checks pass</li></ul><p>To try the Terraform MCP Server, visit:</p><p><a href="https://github.com/hashicorp/terraform-mcp-server">GitHub - hashicorp/terraform-mcp-server: The Terraform MCP Server provides seamless integration with Terraform ecosystem, enabling advanced automation and interaction capabilities for Infrastructure as Code (IaC) development.</a></p><h4>References</h4><ul><li><a href="https://github.com/hashicorp/terraform-mcp-server">Terraform MCP Server</a></li><li><a href="https://www.openpolicyagent.org/docs/terraform">Open Policy Agent Terraform documentation</a></li><li><a href="https://www.conftest.dev/">Conftest documentation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7340e63bc68b" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/terraform-mcp-server-with-open-policy-agent-for-platform-engineering-7340e63bc68b">Terraform MCP Server with Open Policy Agent for Platform Engineering</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stateless MCP: How MCP 2026-07-28 Made MCP Stateless?]]></title>
            <link>https://devopstronaut.com/stateless-mcp-how-mcp-2026-07-28-made-mcp-stateless-38b673cdeb14?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/38b673cdeb14</guid>
            <category><![CDATA[model-context-protocol]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Fri, 14 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-14T02:31:01.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xrFyny5aTWR8px_IpLPIQ.png" /></figure><p>The <strong>MCP 2026–07–28 specification</strong> does not simply say that MCP should be stateless. It changes several parts of the protocol to make stateless communication possible.</p><p>Protocol-level sessions and Mcp-Session-Id are removed. The initialize and notifications/initialized handshake is removed. Protocol version and client capabilities now travel with individual requests. server/discover provides a new way to discover server capabilities, while explicit state identifiers provide a better pattern for workflows that genuinely need state.</p><p>The specification also introduces changes around Multi Round-Trip Requests, HTTP routing headers, subscriptions, and caching that make MCP work more naturally with modern HTTP infrastructure.</p><p>In this blog, we will understand how these changes work together and how MCP moved from a session-oriented model toward a stateless, request-oriented architecture.</p><h4>From Session-Based MCP to Self-Contained Requests</h4><p>The biggest architectural difference can be understood by comparing the previous MCP model with the new one.</p><p>Previously, the MCP Client first established protocol context with the MCP Server. With Streamable HTTP, a server could also associate subsequent requests with a protocol session using Mcp-Session-Id.</p><p>That meant later requests could depend on information established earlier.</p><p>MCP 2026–07–28 changes that assumption. Each request now carries the protocol information required to process it. The server does not need to depend on a protocol session created by an earlier request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHZb-igwz_CHH66bxkpvwg.png" /></figure><p>The image above summarizes the architectural shift. Instead of requiring subsequent requests to return to the server holding a particular MCP protocol session, requests can be processed independently.</p><p>From an infrastructure perspective this is what makes normal load balancing much easier.</p><h4>The initialize Handshake Is Removed</h4><p>One of the most important changes is the removal of the MCP initialization lifecycle.</p><p>Earlier MCP revisions normally started communication with:</p><pre>initialize</pre><p>followed by:</p><pre>notifications/initialized</pre><p>The initialization process exchanged information such as the protocol version, client capabilities, server capabilities, and client/server identity.</p><p>The problem was not that initialization itself was expensive. The bigger architectural issue was that later communication could depend on information established during that earlier interaction.</p><p>If a server needs information from a previous request before it can understand the current request, the server is maintaining protocol state.</p><p>MCP 2026–07–28 removes this dependency. The final specification explicitly removes both initialize and notifications/initialized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1sEoUEiLI2Ke_D3h168Yg.png" /></figure><p>Instead of establishing protocol context once and remembering it, important protocol information now travels with each request.</p><p>For example, request metadata can contain:</p><pre>io.modelcontextprotocol/protocolVersion</pre><p>and:</p><pre>io.modelcontextprotocol/clientCapabilities</pre><p>Clients should also identify themselves using:</p><pre>io.modelcontextprotocol/clientInfo</pre><p>and servers should identify themselves in result metadata using:</p><pre>io.modelcontextprotocol/serverInfo</pre><p>This means the MCP Server can examine the current request and understand which protocol version and capabilities apply without looking up an earlier initialization session.</p><p>That is a fundamental part of making MCP stateless.</p><h4>Every Request Carries Its Own Protocol Context</h4><p>This is worth understanding carefully because it is the core idea behind the new architecture.</p><p>Imagine that an MCP Client calls a tool called:</p><pre>get_pods</pre><p>In the previous architecture, some information needed to understand the request may already have been negotiated during initialization.</p><p>In the new architecture, the request itself carries the necessary protocol context.</p><p>Conceptually, the JSON-RPC request contains the method, parameters, protocol metadata, capabilities, and client information required by the server.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t9EtKIbjOTkyooPADocdkw.png" /></figure><p>The exact metadata used will depend on the client and request, but the architectural principle is what matters:</p><p><strong>the server should be able to process the request using the information available with that request.</strong></p><p>The fact that two requests happen to arrive over the same HTTP connection or STDIO process should not automatically mean that they belong to one protocol session.</p><p>Connection reuse and protocol state are different concepts.</p><p>This distinction allows MCP implementations to reuse efficient transport connections without making application behavior depend on the lifetime of those connections.</p><h4>How Does the Client Discover the Server Without initialize?</h4><p>Removing initialization creates an obvious question.</p><p>If there is no initialization handshake, how does an MCP Client know which protocol versions or capabilities the MCP Server supports?</p><p>The new specification introduces:</p><pre>server/discover</pre><p>Servers supporting MCP 2026–07–28 must implement this RPC. The client can call it to discover the server’s supported protocol versions, capabilities, and identity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSCr2oEnGhQ8A1RFt1MrKQ.png" /></figure><p>One important point is that server/discover is <strong>discovery, not session creation</strong>.</p><p>The client can learn what the server supports without establishing a protocol session that subsequent requests must belong to.</p><p>Also, a client does not necessarily need to call server/discover before every interaction. The specification says clients <strong>may</strong> call it before another request for up-front version selection.</p><p>This gives clients a clean mechanism for capability and version discovery while preserving the stateless request model.</p><h4>Protocol-Level Sessions and Mcp-Session-Id Are Removed</h4><p>Removing initialization solves one part of the problem, but MCP also needed to remove the protocol session itself.</p><p>Earlier versions of Streamable HTTP allowed the server to return:</p><pre>Mcp-Session-Id</pre><p>The client then included that identifier with subsequent requests belonging to the same MCP session.</p><p>This created an implicit relationship between requests.</p><p>For example, an infrastructure platform might need to determine which server instance owned a particular session or maintain shared session storage accessible by multiple instances.</p><p>MCP 2026–07–28 removes both the Mcp-Session-Id header and the protocol-level session concept.</p><p>This means MCP itself no longer requires the infrastructure to preserve protocol sessions between requests.</p><p>But this introduces another important question.</p><p><strong>What happens when an MCP application genuinely needs state?</strong></p><h4>Protocol State and Application State Are Different</h4><p>Stateless MCP does not mean that MCP applications cannot maintain state.</p><p>This distinction is extremely important.</p><p>Imagine an MCP Server that starts a Terraform deployment.</p><p>The first tool call might be:</p><pre>start_deployment()</pre><p>The deployment could take several minutes.</p><p>The server clearly needs a way to identify that deployment later.</p><p>One possible approach would have been to hide the deployment inside an MCP session:</p><pre>session[&quot;terraform_run&quot;] = current_run</pre><p>But now the deployment depends on the lifetime and meaning of that protocol session.</p><p>Instead, Stateless MCP encourages <strong>explicit application state</strong>.</p><p>The tool can return something like:</p><pre>{<br>  &quot;deployment_id&quot;: &quot;deploy-1042&quot;<br>}<br><br>A later tool can accept:<br><br>{<br>  &quot;deployment_id&quot;: &quot;deploy-1042&quot;<br>}</pre><p>The application can store the actual deployment information in a suitable backend such as DynamoDB, PostgreSQL, Redis, S3, or a workflow engine.</p><p>SEP-2567 describes this as using explicit, server-generated state handles passed through normal tool results and tool arguments. Importantly, there is no special MCP handle protocol primitive; it is an application/tool-design pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PiKeeTzc3nmfz3SOb4jxzg.png" /></figure><p>The key architectural difference is:</p><p><strong>Protocol state</strong></p><p>Information that MCP itself previously associated with a session.</p><p><strong>Application state</strong></p><p>Information that actually belongs to the workflow or application.</p><p>Stateless MCP removes the first where possible while still allowing the second when applications genuinely need it.</p><p>This is a much cleaner design for distributed systems.</p><h4>Why Explicit State Is Better for Production Workflows</h4><p>Explicit state identifiers also make workflows easier to reason about.</p><p>Consider the following tools:</p><pre>start_terraform_run()</pre><p>and:</p><pre>get_terraform_run_status()</pre><p>The first call can return:</p><pre>terraform_run_id = run-2381</pre><p>The second receives:</p><pre>terraform_run_id = run-2381</pre><p>Now the relationship between the operations is obvious.</p><p>The state does not exist because the two calls happened over the same HTTP connection or because they came from the same MCP session.</p><p>They are related because they explicitly refer to the same resource.</p><p>This is already a familiar pattern in Cloud and DevOps APIs.</p><p>We work with identifiers such as:</p><ul><li>EC2 instance IDs</li><li>Kubernetes resource names</li><li>Terraform run IDs</li><li>GitHub workflow IDs</li><li>deployment IDs</li><li>transaction IDs</li><li>job IDs</li></ul><p>Stateless MCP applies the same distributed-system design principle to stateful MCP workflows.</p><h4>Multi Round-Trip Requests for Interactive Workflows</h4><p>There is another interesting problem that a stateless protocol needs to solve.</p><p>What if the server cannot immediately complete a request because it needs more information from the client?</p><p>Consider an MCP Server exposing:</p><pre>delete_database</pre><p>The user asks the AI application to delete the production database.</p><p>The server should probably not immediately perform that operation. It may need user confirmation first.</p><p>MCP 2026–07–28 introduces the <strong>Multi Round-Trip Request</strong>, or <strong>MRTR</strong>, pattern for these workflows. It replaces the previous approach where servers sent requests such as elicitation, sampling, or roots requests back to the client while processing another request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_Z-Rg09JL1P4wc9gWXG-g.png" /></figure><p>Instead of holding a server operation open indefinitely and depending on a particular server instance, the server can return:</p><pre>resultType: &quot;input_required&quot;</pre><p>The result contains the additional inputRequests required before the operation can continue.</p><p>The MCP Client collects the necessary information and retries the original operation with:</p><pre>inputResponses</pre><p>When processing is finished, the server returns:</p><pre>resultType: &quot;complete&quot;</pre><p>The specification now requires results to indicate whether they are complete or require further input.</p><p>The important point is that interaction is still possible even though MCP itself is stateless.</p><p>Each round trip is explicit.</p><h4>Why MRTR Matters for Cloud-Native MCP</h4><p>The MRTR design becomes particularly useful when MCP Servers are horizontally scaled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHHaBXHK5XEVxKlYq60hEw.png" /></figure><p>Imagine the first request reaches:</p><pre>MCP-01</pre><p>The server determines that confirmation is required and returns input_required.</p><p>The user may take several seconds, several minutes, or potentially much longer to provide the requested information.</p><p>With the new pattern, the server instance does not necessarily need to remain occupied waiting for that interaction.</p><p>When the client retries with the requested input, the request contains the information needed to continue the operation.</p><p>This reduces the need for sticky load balancing and avoids making normal MCP interactions dependent on long-lived SSE connections. Those scaling and fault-tolerance concerns were explicit motivations for the MRTR design.</p><h4>MCP Traffic Becomes Easier for Infrastructure to Understand</h4><p>Another change that I find particularly interesting from a DevOps and Platform Engineering perspective is HTTP header standardization.</p><p>Traditionally, network infrastructure sees an HTTP request but much of the MCP-specific information lives inside the JSON-RPC body.</p><p>That means a load balancer, WAF, API gateway, rate limiter, or observability platform may need to inspect the body before understanding what type of MCP operation is being performed.</p><p>MCP 2026–07–28 requires standard MCP routing headers on Streamable HTTP POST requests.</p><p>Two important headers are:</p><pre>Mcp-Method</pre><p>and:</p><pre>Mcp-Name</pre><p>For example:</p><pre>POST /mcp HTTP/1.1<br>MCP-Protocol-Version: 2026-07-28<br>Mcp-Method: tools/call<br>Mcp-Name: restart_pod<br>Content-Type: application/json</pre><p>Mcp-Method mirrors the JSON-RPC method, while Mcp-Name exposes the relevant tool name, resource URI, or prompt name for requests where it applies. SEP-2243 was specifically designed so load balancers, gateways, proxies, observability systems, rate limiters, and WAFs can understand important MCP routing information without deep inspection of the JSON body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzDmGMdqEaBaZ2dqT6IYyg.png" /></figure><p>Imagine an MCP Server exposing:</p><pre>get_pods<br>restart_pod<br>delete_pod<br>scale_deployment</pre><p>Infrastructure can more easily distinguish:</p><pre>Mcp-Name: get_pods</pre><p>from:</p><pre>Mcp-Name: delete_pod</pre><p>That creates useful possibilities for:</p><ul><li>routing</li><li>rate limiting</li><li>audit logging</li><li>observability</li><li>WAF policies</li><li>security controls</li><li>traffic analysis</li></ul><p>This is one of the changes that makes MCP increasingly resemble a normal production HTTP workload.</p><h4>Tool Parameters Can Also Be Exposed to Infrastructure</h4><p>MCP Servers can designate certain primitive tool parameters to be mirrored into HTTP headers using:</p><pre>x-mcp-header</pre><p>That can result in headers following the pattern:</p><pre>Mcp-Param-*</pre><p>For example, imagine:</p><pre>restart_pod(<br>    namespace=&quot;production&quot;,<br>    pod=&quot;checkout-api&quot;<br>)</pre><p>A server could choose to expose a routing-relevant parameter such as the namespace through an HTTP header.</p><p>This can allow infrastructure to make routing or policy decisions using information that would otherwise be buried inside the JSON-RPC body.</p><p>This feature should be used carefully, particularly when parameters may contain sensitive information, but from an infrastructure perspective it creates some interesting possibilities.</p><h4>Discovery Results Become Cacheable</h4><p>Another important improvement in MCP 2026–07–28 is client-side caching.</p><p>Consider:</p><pre>tools/list</pre><p>A client may call this to discover the tools available from an MCP Server.</p><p>But if the server’s tool catalog changes only occasionally, repeatedly requesting exactly the same tool list creates unnecessary traffic.</p><p>The new specification introduces cache information for several MCP results, including:</p><pre>tools/list<br>prompts/list<br>resources/list<br>resources/read<br>resources/templates/list</pre><p>These responses now include:</p><pre>ttlMs</pre><p>and:</p><pre>cacheScope</pre><p>ttlMs tells the client how long the result can be considered fresh.</p><p>cacheScope tells the client who is allowed to cache the result. The supported values are:</p><pre>public</pre><p>and:</p><pre>private</pre><p>A public response may be cached by clients or shared intermediaries, while a private response should only be cached for the requesting user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z9d3bBK1ivZHFfjiHV_K-g.png" /></figure><p>For example, a tools/list response might include a TTL of:</p><pre>60000</pre><p>That tells the client the result can be considered fresh for 60 seconds.</p><p>If the client needs the list again during that period, it can reuse the cached result instead of immediately making another request.</p><p>Once the result becomes stale, the client can fetch it again when needed.</p><p>One subtle but important point is that TTL is a <strong>freshness hint</strong>, not an instruction to automatically poll the server every time the TTL expires. The specification says clients should check freshness when the data is needed and re-fetch if it is stale.</p><p>The specification also recommends deterministic ordering for tools/list, which can improve both client-side caching and LLM prompt cache hit rates.</p><h4>What About Server-to-Client Notifications?</h4><p>Stateless MCP does not mean long-lived server-to-client communication has disappeared completely.</p><p>Instead, the model becomes more explicit.</p><p>MCP 2026–07–28 replaces the old HTTP GET endpoint and resources/subscribe / resources/unsubscribe mechanisms with:</p><pre>subscriptions/listen</pre><p>This provides a long-lived POST-response stream for clients that explicitly want server-side change notifications. Clients can opt into notification categories such as tool list, prompt list, or resource changes.</p><p>Request-specific notifications such as progress messages continue to use the response stream belonging to that particular request.</p><p>This follows the same overall architecture:</p><p><strong>the normal MCP path remains stateless, while long-lived behavior is explicitly requested only when it is actually required.</strong></p><h4>SSE Stream Resumability Is Also Removed</h4><p>Another related change is the removal of SSE stream resumability using:</p><pre>Last-Event-ID and SSE event IDs.</pre><p>If an in-flight response stream breaks under MCP 2026–07–28, the client reissues the operation as a new request with a new request ID rather than trying to resume a protocol session stream.</p><p>Again, this aligns with the broader design direction: individual requests are independent units of work rather than pieces of a persistent MCP protocol session.</p><h4>What Does This Mean for MCP Server Developers?</h4><ul><li>Review how much your MCP Server depends on <strong>session or connection state</strong>.</li><li>Check whether application data is stored using Mcp-Session-Id.</li><li>Verify whether your server assumes that the initialize handshake has already established protocol version, capabilities, or client information.</li><li>Avoid treating a single HTTP or STDIO connection as one conversation or workflow.</li><li>Review long-running operations such as deployments, workflows, or background tasks. If their state exists only in one MCP Server instance, scaling and failover become more difficult.</li><li>Check whether your infrastructure depends on <strong>sticky sessions</strong> to route requests back to the same MCP Server.</li><li>Review any dependency on the older <strong>GET/SSE behavior</strong> or Last-Event-ID.</li><li>Review interactive workflows that depend on <strong>server-initiated requests</strong>.</li><li>For workflows that genuinely need state, make that state <strong>explicit</strong> instead of storing it inside the MCP session.</li></ul><p>Instead of:</p><pre>session[&quot;deployment&quot;] = current_deployment</pre><p>return an explicit identifier:</p><pre>deployment_id = &quot;deploy-1042&quot;</pre><p>Then use that identifier in later operations:</p><pre>get_deployment_status(<br>    deployment_id=&quot;deploy-1042&quot;<br>)</pre><ul><li>Store the actual application state in an appropriate backend such as a database, Redis, DynamoDB, S3, or a workflow engine.</li><li>This makes the relationship between requests explicit and makes the workflow easier to <strong>scale, recover, and understand</strong>.</li></ul><h4>Why This Matters for Cloud and DevOps Engineers</h4><ul><li>MCP Servers can be treated more like standard cloud-native HTTP services.</li><li>Multiple MCP Server replicas can run behind a load balancer without tying a client to one specific server instance.</li><li>MCP Servers can scale horizontally using platforms such as Kubernetes and Amazon ECS.</li><li>Unhealthy or terminated MCP Server instances can be replaced while new requests are routed to other healthy instances.</li><li>Rolling deployments and autoscaling become easier because the infrastructure does not need to preserve a hidden MCP protocol session.</li><li>Standardized headers such as Mcp-Method and Mcp-Name make MCP traffic easier for gateways, load balancers, WAFs, rate limiters, and observability tools to understand.</li><li>Platform teams can apply routing, access control, rate limiting, monitoring, and audit logging based on MCP request information.</li><li>Cacheable discovery results such as tools/list can reduce unnecessary requests and improve client and server performance.</li><li>Workflows can still maintain state, but that state is stored explicitly and referenced using identifiers instead of being tied to a protocol session.</li><li>Overall, MCP 2026–07–28 aligns more closely with modern production patterns such as stateless request handling, horizontal scaling, explicit application state, HTTP-based routing, and infrastructure-level observability.</li></ul><h4>Conclusion:</h4><p>Stateless MCP is more than removing Mcp-Session-Id or the initialize handshake. The MCP 2026-07-28 specification introduces a broader shift toward self-contained requests, explicit state, better routing, and easier scaling.</p><p>For Cloud and DevOps teams, this makes MCP much easier to run across load balancers, Kubernetes, autoscaling platforms, and other production cloud-native environments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38b673cdeb14" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/stateless-mcp-how-mcp-2026-07-28-made-mcp-stateless-38b673cdeb14">Stateless MCP: How MCP 2026-07-28 Made MCP Stateless?</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stateless MCP Explained: Why MCP Needed to Become Stateless?]]></title>
            <link>https://devopstronaut.com/stateless-mcp-explained-why-mcp-needed-to-become-stateless-48679d7116c7?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/48679d7116c7</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[model-context-protocol]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 02:31:01 GMT</pubDate>
            <atom:updated>2026-08-12T02:31:01.325Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lrRrAythouyMK3KKMsRhKg.png" /></figure><p>Model Context Protocol has been evolving very quickly. When I started writing about MCP, most examples were focused on understanding MCP Clients, MCP Servers, tools, resources, prompts, stdio, and Streamable HTTP. As MCP adoption grows, however, the discussion is moving beyond simply connecting an AI application to an MCP Server. We now need to think about how MCP Servers behave when they are deployed behind load balancers, run with multiple replicas, autoscale in Kubernetes, recover from failures, and serve production traffic.</p><p>The <strong>MCP 2026–07–28 specification</strong> introduces one of the most important architectural changes to the protocol so far: <strong>MCP is now stateless at the protocol layer</strong>. The specification explicitly defines MCP as a stateless protocol where all information required to process a request is contained in that request and a server should process each request independently rather than inferring context from previous requests on the same connection.</p><p>This might initially sound like a relatively small protocol change, but from a Cloud, DevOps, SRE, and Platform Engineering perspective, it has major implications. Stateless MCP Servers can fit much more naturally into the infrastructure patterns we already use for modern applications: load balancers, Kubernetes Deployments, ECS services, autoscaling groups, API gateways, rolling deployments, serverless platforms, and multi-instance architectures.</p><p>In this blog, we will understand why MCP needed to become stateless, how the previous session-based architecture worked, what changed in the 2026–07–28 specification, how application state can still be maintained when required, and why these changes make MCP much easier to operate in production.</p><h4>What Does Stateless Actually Mean?</h4><p>Before looking specifically at MCP, it helps to understand what we mean by a stateless service.</p><p>Imagine that an application sends three requests to a backend service. In a stateful architecture, the backend might remember information from the first request and expect that information to still be available when processing the second or third request. That creates a relationship between the client and the particular backend instance holding that information.</p><p>A simplified stateful flow might look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbqKhAiCVxK09IvagU7nbA.png" /></figure><p>The problem appears when we introduce multiple backend instances</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGxsFEYvYZXTSP2-HXQ4jw.png" /></figure><p>If the first request reaches Server A and Server A stores information about the client locally, the next request cannot necessarily be sent to Server B. Server B may not know anything about the state stored inside Server A.</p><p>There are several traditional ways of solving this problem. We could configure sticky sessions so that the load balancer always routes the same client to the same server. We could also move the session information to a shared backend such as Redis or another distributed data store. Both approaches work, but they introduce additional infrastructure and operational complexity.</p><p>A stateless architecture takes a different approach. Instead of relying on information stored implicitly by one server instance, every request provides the information required to process it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idkPA8s1bWQ3aIpQiiAmHA.png" /></figure><p>Server B does not need to know that Request 1 previously went to Server A. Each request can be understood independently.</p><p>This is the core principle now applied to MCP. The 2026–07–28 specification states that servers must not rely on previous requests over the same connection to establish protocol version, capabilities, or client identity. When information genuinely needs to survive across multiple operations, it must instead be referenced using an explicit identifier that the client passes with the request.</p><h4>How MCP Worked Before Stateless MCP?</h4><p>To understand why this change matters, we first need to look at the previous MCP communication model.</p><p>In earlier MCP protocol revisions, communication normally started with an initialization handshake. The MCP Client sent an initialize request containing information such as the MCP protocol version it supported, its capabilities, and client information. The MCP Server then returned its own protocol version, capabilities, and server information. Finally, the client sent notifications/initialized, indicating that initialization had completed.</p><p>Conceptually the flow looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjnIBtQivqttfBuYEJ18oA.png" /></figure><p>After this handshake completed, both sides could assume that the negotiated information remained valid throughout the connection or session.</p><p>This design was perfectly understandable when MCP was primarily being used with local servers or relatively simple client-server deployments. The difficulty appeared when MCP Servers started moving into distributed infrastructure. SEP-2575, the proposal that drove the stateless change, explains that the mandatory initialization handshake created state that the server had to retain and made standard load balancing more difficult.</p><p>Streamable HTTP added another session-related concept. Earlier Streamable HTTP revisions allowed an MCP Server to assign a session using the Mcp-Session-Id HTTP header. Clients would then include that identifier in later requests associated with the session. The server could terminate the session lifecycle separately, and the transport also supported mechanisms such as standalone GET-based SSE streams and stream resumability using Last-Event-ID. These mechanisms are not part of the 2026–07–28 Streamable HTTP revision.</p><p>That architecture effectively meant that an MCP deployment might look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lyRGYIM3e5F6-Xjl3FbWGA.png" /></figure><p>If we wanted to add more MCP Server replicas, we then had to think about where that session lived and how later requests would find it.</p><h4>Why Was Stateful MCP a Problem?</h4><p>The first major challenge was <strong>horizontal scaling</strong>.</p><p>Suppose we deploy three MCP Server replicas behind an Application Load Balancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qVAlORC6pzYLiuhHqyPTvA.png" /></figure><p>The first request from an MCP Client could reach MCP-01. If that server stored protocol session information locally and the next request was routed to MCP-02, the second instance would not necessarily have the required session context.</p><p>The natural solution would be to use session affinity, commonly called sticky sessions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qBTbo-VtEtSd9e7dkRaj7w.png" /></figure><p>While this solves the immediate routing issue, it reduces the flexibility of normal load balancing. SEP-2575 specifically identified sticky sessions as an infrastructure workaround that complicates horizontal scaling and can lead to uneven traffic distribution.</p><p>The second problem was <strong>resilience</strong>.</p><p>Consider that the client has an active session with an MCP Server running inside a Kubernetes pod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chQjie3LECiSZTYLRbOqoA.png" /></figure><p>Now imagine Pod 1 crashes, Kubernetes reschedules the workload, or a rolling deployment replaces that pod. If the session information existed only inside that instance, the session disappeared together with it. The client then had to reconnect, establish another session, and synchronize the required state again.</p><p>SEP-2575 identifies this dependency between a client session and a specific backend instance as a fault-tolerance problem.</p><p>The third problem was <strong>implementation complexity</strong>. Servers needed logic for creating session state, retaining it, expiring it, and cleaning it up. Clients also needed connection and reconnection handling. As MCP deployments became larger, session management became part of the operational architecture rather than simply an implementation detail.</p><p>The MCP maintainers therefore moved towards a simple design principle: make the common path stateless and introduce state only when an application actually needs it. SEP-2575 describes this as a “pay as you go” approach to protocol complexity.</p><h4>MCP 2026–07–28: MCP Becomes Stateless</h4><p>The new MCP specification changes the interaction model significantly.</p><p>Instead of assuming that the server learned important information from an earlier initialization process, the request itself contains the metadata required to process it.</p><p>The simplified architecture becomes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fSTAVaobOOp-NETxwoacA.png" /></figure><p>Any healthy MCP Server instance should be capable of processing the request.</p><p>Importantly, the specification also makes clear that even an open STDIO process or HTTP connection should not automatically be treated as a conversation or session. Unrelated requests can share a transport, and servers should not infer conversation continuity merely because requests arrived through the same connection.</p><h4>Why This Is an Important Change for MCP</h4><p>At first, making MCP stateless might appear to be a relatively small protocol change. But when we look at MCP from an infrastructure perspective, we can see why this change is important.</p><p>MCP Servers are no longer limited to simple local environments where one client communicates with one server process. As organizations start deploying remote MCP Servers in production, those servers need to work with the same infrastructure patterns we already use for modern applications.</p><p>For example, we may want to run multiple MCP Server instances behind a load balancer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XBWa7mccbzBcE3jS16J9Ag.png" /></figure><p>We may also want Kubernetes to automatically scale those instances when traffic increases, replace unhealthy pods, perform rolling deployments, or distribute workloads across multiple availability zones.</p><p>A protocol-level session creates an additional dependency in this architecture because the infrastructure needs to know where the session state exists.</p><p>Stateless MCP changes this model.</p><p>Instead of the server relying on protocol information established during a previous request, each request contains the information required for the server to process it.</p><p>Conceptually:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tbYHwW4hdZEtwoSAWvQy7w.png" /></figure><p>The important point is that MCP-02 does not need the protocol session created by MCP-01 before it can process Request 3.</p><p>Each request can be processed independently.</p><p>That allows MCP Servers to fit much more naturally into distributed infrastructure such as Kubernetes, Amazon ECS, load balancers, autoscaling platforms, and other cloud-native environments.</p><p>Of course, some applications genuinely need state.</p><p>A Terraform deployment may run for several minutes. A Kubernetes operation may need to be checked later. An AI workflow might contain several related steps.</p><p>Stateless MCP does not mean that this application state disappears.</p><p>Instead, the distinction is between <strong>protocol state</strong> and <strong>application state</strong>.</p><p>The MCP protocol no longer needs to maintain an implicit session simply to understand subsequent requests. When an application genuinely needs state, that state can be represented explicitly and referenced by later requests.</p><h4>Final Thoughts</h4><p>MCP started with a relatively straightforward interaction model: establish communication between the MCP Client and MCP Server, negotiate the required protocol information, and then allow the client to interact with tools, resources, and prompts.</p><p>That model worked well, particularly for local MCP Servers.</p><p>But running MCP Servers in production introduces a different set of requirements.</p><p>We need horizontal scaling.</p><p>We need load balancing.</p><p>We need failure recovery.</p><p>We need rolling deployments.</p><p>We need autoscaling.</p><p>And we should be able to replace one MCP Server instance without breaking the communication model for every client that happened to be connected to it.</p><p>This is where Stateless MCP becomes important.</p><p>The MCP 2026–07–28 specification changes the underlying assumption from:</p><pre>The server remembers the protocol context<br>from previous interactions.</pre><p>to:</p><pre>The request provides the protocol context<br>required to process that request.</pre><p>That might appear to be a simple change, but architecturally it is significant.</p><p>It moves MCP closer to the stateless service patterns that Cloud, DevOps, SRE, and Platform Engineering teams have been using for years.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48679d7116c7" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/stateless-mcp-explained-why-mcp-needed-to-become-stateless-48679d7116c7">Stateless MCP Explained: Why MCP Needed to Become Stateless?</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP Zero to Hero: 5.Build Your First Remote MCP Server on Amazon EC2]]></title>
            <link>https://devopstronaut.com/mcp-zero-to-hero-5-build-your-first-remote-mcp-server-on-amazon-ec2-028a64d1d09d?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/028a64d1d09d</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Wed, 15 Jul 2026 01:02:10 GMT</pubDate>
            <atom:updated>2026-07-15T01:02:10.069Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RMTsYwqJKCLKkyNhFOp18g.png" /></figure><p>Model Context Protocol servers are commonly demonstrated by running them on a local machine. This is useful for development, but there are situations where the MCP server needs to run on a remote environment such as Amazon EC2.</p><p>Running an MCP server on EC2 provides a separate environment for hosting MCP tools, installing dependencies, managing authentication, and testing remote connectivity.</p><p>In this blog, a Kubernetes MCP server will run on an EC2 instance. The Kubernetes cluster will continue to run on the local machine.</p><p>SSH port forwarding will connect all the components securely without exposing the MCP server or Kubernetes API directly to the internet.</p><h4>What Will Be Configured?</h4><p>This setup contains three main components:</p><ol><li>A Kubernetes cluster running on the local machine</li><li>An MCP server running on Amazon EC2</li><li>An MCP client running on the local machine</li></ol><p>Two SSH tunnels will be used.</p><p>The first tunnel forwards local port 18000 to port 8000 on the EC2 instance.</p><pre>Local machine:18000 → EC2 instance:8000</pre><p>The second tunnel allows the EC2 instance to connect back to the local Kubernetes API.</p><pre>EC2 instance:16443 → Local Kubernetes API port</pre><p>This means that no additional application ports need to be opened in the EC2 security group.</p><h4>Prerequisites</h4><p>Before starting, make sure the following components are available:</p><ul><li>An AWS account</li><li>A Kubernetes cluster running locally</li><li>kubectl configured on the local machine</li><li>Python installed on the EC2 instance</li><li>Node.js and npx installed on the local machine</li><li>An MCP client such as Claude Desktop or another MCP-compatible client</li></ul><p>The Kubernetes cluster can be created using Kind, Docker Desktop, Minikube, or another local Kubernetes environment.</p><h4>Step 1: Launch an Amazon EC2 Instance</h4><p>Open the <strong>AWS Management Console</strong> and go to <strong>Amazon EC2</strong>. Click <strong>Launch Instance</strong>, provide a name for the instance, and select <strong>Amazon Linux</strong> as the Amazon Machine Image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plUe3XDpsfLZbfbL1k6-BQ.png" /></figure><p>Choose the required instance size, select an existing key pair, and configure the VPC and subnet. Create or select a security group for the instance.</p><p>For this demo, a wider security group rule was used for testing. In a production environment, access should be restricted to trusted IP addresses only, especially for SSH and any application ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMmps_9bf8rwMUUNwy-hKA.png" /></figure><p>Configure the storage settings for the EC2 instance. The default storage size is enough for this demo, but you can increase it if required. After reviewing the instance configuration, click <strong>Launch Instance</strong> to create the EC2 instance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LrcmZ3C2jz9b6jhqsVrIKg.png" /></figure><p>Once the EC2 instance is launched, wait until the instance state changes to <strong>Running</strong>. This confirms that the instance has been created successfully and is ready for SSH access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxTkbIWIcUSWFhBaHOgNXA.png" /></figure><p>Connect to the EC2 instance using the key pair selected during the instance launch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6n4Ex19lQFI2FBx3CG7XEA.png" /></figure><p>Install Python 3.11 and pip on the EC2 instance using the following command</p><pre>sudo yum install -y python3.11 python3.11-pip</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L6kM0-I6_5vA6jOXflgEjw.png" /></figure><p>Install kubectl on the EC2 instance using the following commands and verify the installation “kubectl version — client”</p><pre>curl -LO &quot;https://dl.k8s.io/release/v1.33.0/bin/linux/amd64/kubectl&quot;<br>chmod +x kubectl<br>sudo mv kubectl /usr/local/bin/kubectl</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MGZWVKBtmvHo0FCPuWffdA.png" /></figure><p>Install the required Python packages for the MCP Server using the following command</p><pre>pip install mcp starlette uvicorn</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zQVQL9S7ac2SjZtHVdJP0g.png" /></figure><p>Find the local Kubernetes API port</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iiLyrKw6FavpvoXEC801Dw.png" /></figure><p>In this example, the local Kubernetes API server is running on port 64337.</p><p>Use your actual port in the tunnel command.</p><h4>Step 2: Start the combined SSH tunnel</h4><p>Run this command from your local machine and keep the terminal open</p><pre>ssh -i ~/Downloads/mcp-server.pem.pem \<br>  -o ExitOnForwardFailure=yes \<br>  -o ServerAliveInterval=30 \<br>  -o ServerAliveCountMax=3 \<br>  -L 127.0.0.1:18000:127.0.0.1:8000 \<br>  -R 127.0.0.1:16443:127.0.0.1:64337 \<br>  ec2-user@34.248.43.160 \<br>  -N</pre><p>Replace 64337 with your local Kubernetes API server port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rEU7xhSe4-KeibtW4mjxtA.png" /></figure><p>This tunnel does two things:</p><ul><li>-L 127.0.0.1:18000:127.0.0.1:8000 (This allows Claude Desktop on the Mac to reach the MCP Server running on EC2)</li><li>-R 127.0.0.1:16443:127.0.0.1:64337 (This allows kubectl on EC2 to reach the local Kubernetes API server running on the Mac)</li></ul><h4>Step 3: Copy kubeconfig to EC2</h4><p>From your Mac, create the .kube directory on EC2,Copy kubeconfig and Update the kubeconfig on EC2 to use the tunnel port 16443</p><pre>ssh -i ~/Downloads/mcp-server.pem.pem ec2-user@34.248.43.160 &quot;mkdir -p ~/.kube&quot;<br>scp -i ~/Downloads/mcp-server.pem.pem ~/.kube/config ec2-user@34.248.43.160:~/.kube/config<br>ssh -i ~/Downloads/mcp-server.pem.pem ec2-user@34.248.43.160 &quot;sed -i &#39;s|https://127.0.0.1:[0-9]*|https://127.0.0.1:6443|&#39; ~/.kube/config&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZktaHnp6mIgue4LqztL2Pw.png" /></figure><h4>Step 4: Verify Kubernetes access from EC2</h4><p>Run this command to validate the access from EC2</p><pre>curl -k --max-time 10 https://127.0.0.1:16443/version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s62ufWB0wuNLyUZCN5Rdjw.png" /></figure><p>Run these commands <strong>on the EC2 instance</strong>, after starting the SSH tunnel from your Mac to update kubeconfig on EC2 to use the tunnel port</p><pre>CLUSTER_NAME=$(kubectl config view --minify -o jsonpath=&#39;{.contexts[0].context.cluster}&#39;)<br><br>kubectl config set-cluster &quot;$CLUSTER_NAME&quot; --server=https://127.0.0.1:16443<br>kubectl config view --minify -o jsonpath=&#39;{.clusters[0].cluster.server}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKZcXS1hwcoDs52B1Dsidg.png" /></figure><p>Run kubectl get namespaces and kubectl get nodes command to verify the Kubernetes access</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lnd8tB8LbQPeHyLwY6WqHg.png" /></figure><p>Generate a random bearer token that will be used as a shared secret between the MCP Server running on EC2 and Claude Desktop</p><pre>openssl rand -hex 32</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EO86MgUKmwjDFcm5srIpow.png" /></figure><h4>Step 5: Create the MCP Server</h4><p>On EC2, create server.py inside ~/mcp-server</p><pre>from mcp.server.fastmcp import FastMCP<br>from starlette.middleware.base import BaseHTTPMiddleware<br>from starlette.responses import JSONResponse<br>import subprocess<br>import os<br>import re<br><br>mcp = FastMCP(&quot;remote-k8s-mcp-server&quot;)<br><br>SHARED_TOKEN = os.environ[&quot;MCP_AUTH_TOKEN&quot;]<br><br><br>def run_kubectl(args: list[str]) -&gt; str:<br>    try:<br>        result = subprocess.run(<br>            [&quot;kubectl&quot;] + args,<br>            capture_output=True,<br>            text=True,<br>            timeout=10,<br>        )<br><br>        if result.returncode != 0:<br>            return result.stderr.strip()<br><br>        return result.stdout.strip()<br><br>    except FileNotFoundError:<br>        return &quot;kubectl is not installed or not available on PATH.&quot;<br><br>    except subprocess.TimeoutExpired:<br>        return &quot;kubectl timed out. Is the cluster reachable?&quot;<br><br><br>@mcp.tool()<br>def list_namespaces() -&gt; str:<br>    &quot;&quot;&quot;Lists all namespaces in the Kubernetes cluster.&quot;&quot;&quot;<br>    return run_kubectl([&quot;get&quot;, &quot;namespaces&quot;])<br><br><br>@mcp.tool()<br>def get_pods_by_namespace(namespace: str = &quot;default&quot;) -&gt; str:<br>    &quot;&quot;&quot;Returns pods from the given Kubernetes namespace.&quot;&quot;&quot;<br><br>    if not re.fullmatch(r&quot;[a-z0-9]([-a-z0-9]*[a-z0-9])?&quot;, namespace):<br>        return f&quot;Invalid namespace name: &#39;{namespace}&#39;.&quot;<br><br>    return run_kubectl([&quot;get&quot;, &quot;pods&quot;, &quot;-n&quot;, namespace])<br><br><br>class RequireBearerToken(BaseHTTPMiddleware):<br>    async def dispatch(self, request, call_next):<br>        auth_header = request.headers.get(&quot;authorization&quot;, &quot;&quot;)<br><br>        if auth_header != f&quot;Bearer {SHARED_TOKEN}&quot;:<br>            return JSONResponse({&quot;error&quot;: &quot;unauthorized&quot;}, status_code=401)<br><br>        return await call_next(request)<br><br><br>app = mcp.streamable_http_app()<br>app.add_middleware(RequireBearerToken)</pre><h4>Step 6: Understand the Code</h4><p>Let’s understand the main parts of the MCP Server code.</p><p>This server runs on EC2 and exposes Kubernetes tools over Streamable HTTP. Claude Desktop connects to this server through mcp-remote, and the server uses kubectl to read data from the Kubernetes cluster.</p><pre>from mcp.server.fastmcp import FastMCP<br>from starlette.middleware.base import BaseHTTPMiddleware<br>from starlette.responses import JSONResponse<br>import subprocess<br>import os<br>import re</pre><p>FastMCP is used to create the MCP Server and expose Python functions as MCP tools.</p><p>BaseHTTPMiddleware and JSONResponse are used to add a simple bearer token check for incoming HTTP requests.</p><p>subprocess is used to run kubectl commands from Python.</p><p>os is used to read the token from the environment variable.</p><p>re is used to validate the namespace name before passing it to the kubectl command.</p><pre>mcp = FastMCP(&quot;remote-k8s-mcp-server&quot;)</pre><p>The MCP Server name is remote-k8s-mcp-server. This is the name that appears when the MCP client connects and discovers the available tools.</p><p>The next line reads the bearer token from the environment variable.</p><pre>SHARED_TOKEN = os.environ[&quot;MCP_AUTH_TOKEN&quot;]</pre><p>This means the server expects an environment variable named MCP_AUTH_TOKEN to be available before the server starts.</p><pre>export MCP_AUTH_TOKEN=&quot;replace-with-a-real-secret&quot;</pre><p>If this environment variable is missing, the server will fail to start. This is useful because we do not want to hardcode the token inside the Python file.The same token must be passed from Claude Desktop in the Authorization header.</p><pre>def run_kubectl(args: list[str]) -&gt; str:</pre><p>This helper function runs kubectl commands from the MCP Server. For example, when the tool passes [&quot;get&quot;, &quot;namespaces&quot;], the final command becomes:</p><pre>kubectl get namespaces</pre><p>It also handles common errors such as kubectl not being available or the Kubernetes cluster not being reachable.</p><pre>@mcp.tool()<br>def list_namespaces() -&gt; str:<br>    return run_kubectl([&quot;get&quot;, &quot;namespaces&quot;])</pre><p>This exposes a tool to Claude Desktop for listing Kubernetes namespaces. When Claude asks for namespaces, this tool runs:</p><pre>kubectl get namespaces</pre><pre>@mcp.tool()<br>def get_pods_by_namespace(namespace: str = &quot;default&quot;) -&gt; str:</pre><p>This exposes a tool to get pods from a specific Kubernetes namespace. The namespace input is validated before running the command.</p><p>For example, if the namespace is kube-system, the command becomes:</p><pre>kubectl get pods -n kube-system</pre><pre>class RequireBearerToken(BaseHTTPMiddleware):</pre><p>This middleware checks whether every incoming MCP request has the correct bearer token. If the token is missing or incorrect, the request is rejected with 401 unauthorized. If the token is valid, the request is allowed.</p><pre>app = mcp.streamable_http_app()<br>app.add_middleware(RequireBearerToken)</pre><p>This creates the Streamable HTTP MCP application and attaches the bearer token middleware.</p><h4>Step 7: Start the MCP Server on EC2</h4><p>Copy the generated value and use it as the MCP_AUTH_TOKEN on EC2 and in the Claude Desktop Authorization header.Use this command on <strong>EC2</strong> before starting the MCP Server</p><pre>export MCP_AUTH_TOKEN=09b943710b36db18077bbbb15965197945596ebdabde5b3d135e861b2b6f9e8d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pX_FeaVsy_dI8T-AYrZzCQ.png" /></figure><p>Start the MCP Server using this command</p><pre>uvicorn server:app --host 0.0.0.0 --port 8000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dyby6109W8Ux6mzjO4eHA.png" /></figure><h4>Step 8: Test the MCP tunnel from Mac</h4><p>From your Mac, run</p><pre>curl -i --max-time 10 http://127.0.0.1:18000/mcp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*muY-p4-BXv_NAIJckxkM9A.png" /></figure><p>If you see 401 Unauthorized, 405 Method Not Allowed, or 406 Not Acceptable, the tunnel is working.</p><h4>Step 9: Configure Claude Desktop</h4><p>Update claude_desktop_config.json</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;remote-k8s-mcp-server&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;-y&quot;,<br>        &quot;mcp-remote&quot;,<br>        &quot;http://127.0.0.1:18000/mcp&quot;,<br>        &quot;--header&quot;,<br>        &quot;Authorization: Bearer 09b943710b36db18077bbbb15965197945596ebdabde5b3d135e861b2b6f9e8d&quot;<br>      ]<br>    }<br>  }<br>}</pre><p>Save the file and restart Claude Desktop.</p><p>Now Claude Desktop can connect to the Streamable HTTP MCP Server through mcp-remote using the local SSH tunnel. Make sure the SSH tunnel and the MCP Server on EC2 are already running before opening Claude Desktop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nl3lBREEcSe9N9Nmgtc3ww.png" /></figure><p>To verify the connection, click the + in the chat window and choose connectors and you should see remote-k8s-mcp-server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3MTQ0py1SZeGoVlGqArkrQ.png" /></figure><p>To test it, enter the following prompt</p><p>“List all Kubernetes namespaces in my cluster”</p><p>Before the tool is executed, Claude asks for your permission. You can review the request and click <strong>Always allow</strong> or <strong>Allow once</strong> to let Claude invoke the tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-fkClVG4PZrmjtx-Ih8-QQ.png" /></figure><p>Once permission is granted, Claude invokes the MCP tool, which executes the corresponding kubectl command and returns the list of namespaces from the Kubernetes cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6VpnsjgkoM666YmVctDvg.png" /></figure><p>You can verify the namespaces by opening a new terminal and running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s5r1vWKm4L5sh8Tc.png" /></figure><h4>Conclusion</h4><p>In this tutorial, we built a remote MCP Server on an EC2 instance using Streamable HTTP and connected it to a local Kubernetes cluster.</p><p>The important part of this setup was the SSH tunnel. Since the Kubernetes cluster was running locally on the laptop, the EC2 instance could not access the cluster API directly. By using a tunnel, the MCP Server running on EC2 was able to execute kubectl commands and return live Kubernetes information back to Claude Desktop through mcp-remote.</p><p>This tutorial is useful for understanding how remote MCP Servers work without moving the Kubernetes cluster to the cloud or exposing the Kubernetes API server publicly.</p><p>For production usage, this setup should be improved with restricted network access, proper authentication, TLS, logging, and a more durable deployment model. The next step would be to run the MCP Server inside Kubernetes itself using a ServiceAccount and RBAC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=028a64d1d09d" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/mcp-zero-to-hero-5-build-your-first-remote-mcp-server-on-amazon-ec2-028a64d1d09d">MCP Zero to Hero: 5.Build Your First Remote MCP Server on Amazon EC2</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP Zero to Hero:4.Build Your First MCP Server with Streamable HTTP]]></title>
            <link>https://devopstronaut.com/mcp-zero-to-hero-4-build-your-first-mcp-server-with-streamable-http-94bf883d410c?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/94bf883d410c</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 02:45:00 GMT</pubDate>
            <atom:updated>2026-07-10T02:45:00.774Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxNE3ebmaVnJkR0ZhAK25Q.png" /></figure><p>In the previous blog, we explored the difference between stdio and Streamable HTTP in MCP. We saw that stdio is useful when the MCP Server runs locally on a developer machine, while Streamable HTTP is useful when the MCP Server needs to run as an HTTP service.</p><p>In this blog, we are going to build a simple Streamable HTTP MCP Server using Python.</p><p>To keep this practical for Cloud, DevOps, and Platform Engineers, the MCP Server will connect to a Kubernetes cluster using kubectl. The server will expose read-only tools, and we will test them using MCP Inspector.</p><p>The goal of this blog is not production deployment. The goal is to understand how to build and run an MCP Server using Streamable HTTP.</p><p>The official MCP Python SDK supports standard transports such as stdio, Streamable HTTP, and SSE. The MCP specification describes Streamable HTTP as a transport where the server runs as an independent process and clients communicate with it using HTTP POST and GET requests.</p><h4>What we are going to do</h4><p>In this guide, we will create a Streamable HTTP MCP Server named k8s-http-mcp-server.</p><p>This server will expose two tools:</p><ul><li>list_namespaces</li><li>get_pods_by_namespace</li></ul><p>The first tool lists Kubernetes namespaces. The second tool returns pods from a specific namespace. Both tools use kubectl, so the output comes from the Kubernetes cluster configured on the local machine.</p><p>The flow will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7e9raoQo4OYd63QMu1tDiw.png" /></figure><p>In the previous stdio example, the MCP client started the server process. In this example, the MCP Server runs as an HTTP service and the client connects to it using an HTTP endpoint.</p><h4>Prerequisites</h4><p>Before starting, make sure the following tools are available on your machine:</p><ul><li>Python 3.10 or later</li><li>kubectl</li><li>Kind or any Kubernetes cluster reachable from your kubeconfig</li><li>Node.js for MCP Inspector</li></ul><p>First, confirm that your Kubernetes cluster is reachable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8kQQwe6UNBwmaayws25YxA.png" /></figure><p>If these commands return output from your cluster, you are ready to continue.</p><h4>Step 1: Create the project folder</h4><p>Create a new folder for the MCP Server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygCv3_DOJrB0lucwHlbLMQ.png" /></figure><p>Install the MCP Python SDK using this command</p><pre>pip install mcp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rkHd-lKN2HTc8JXUtW3QFA.png" /></figure><p>If you already have mcp installed, you can upgrade it.</p><pre>pip install --upgrade mcp</pre><h4>Step 2: Create the MCP Server</h4><p>Create a file named server.py. Add the following code:</p><pre>from mcp.server.fastmcp import FastMCP<br>import subprocess<br>import re<br><br>mcp = FastMCP(&quot;k8s-http-mcp-server&quot;)<br><br><br>def run_kubectl(args: list[str]) -&gt; str:<br>    try:<br>        result = subprocess.run(<br>            [&quot;kubectl&quot;] + args,<br>            capture_output=True,<br>            text=True,<br>            timeout=10,<br>        )<br><br>        if result.returncode != 0:<br>            return result.stderr.strip()<br><br>        return result.stdout.strip()<br><br>    except FileNotFoundError:<br>        return &quot;kubectl is not installed or not available on PATH.&quot;<br><br>    except subprocess.TimeoutExpired:<br>        return &quot;kubectl command timed out. Check whether the cluster is reachable.&quot;<br><br><br>@mcp.tool()<br>def list_namespaces() -&gt; str:<br>    &quot;&quot;&quot;Lists all namespaces in the Kubernetes cluster.&quot;&quot;&quot;<br>    return run_kubectl([&quot;get&quot;, &quot;namespaces&quot;])<br><br><br>@mcp.tool()<br>def get_pods_by_namespace(namespace: str) -&gt; str:<br>    &quot;&quot;&quot;Returns pods from the given Kubernetes namespace.&quot;&quot;&quot;<br><br>    if not re.fullmatch(r&quot;[a-z0-9]([-a-z0-9]*[a-z0-9])?&quot;, namespace):<br>        return f&quot;Invalid namespace name: &#39;{namespace}&#39;.&quot;<br><br>    return run_kubectl([&quot;get&quot;, &quot;pods&quot;, &quot;-n&quot;, namespace])<br><br><br>if __name__ == &quot;__main__&quot;:<br>    mcp.run(transport=&quot;streamable-http&quot;)</pre><p>The important part in this code is the transport configuration.</p><pre>mcp.run(transport=&quot;streamable-http&quot;)</pre><p>In the previous local MCP Server example, we used stdio</p><pre>mcp.run(transport=&quot;stdio&quot;)</pre><p>With Streamable HTTP, the server runs as an HTTP service. The MCP client connects to the server endpoint instead of starting the Python file as a local subprocess.</p><h4>Step 3: Understand the code</h4><p>Let’s understand what this MCP Server is doing.</p><p>The server is built using the MCP Python SDK. We are using FastMCP because it makes it simple to define an MCP Server and expose Python functions as MCP tools.</p><pre>from mcp.server.fastmcp import FastMCP<br>import subprocess<br>import re</pre><p>FastMCP is used to create the MCP Server.</p><p>subprocess is used to run kubectl commands from Python.</p><p>re is used to validate the namespace name before passing it to the command.</p><p>Next, we create the MCP Server and give it a name.</p><pre>mcp = FastMCP(&quot;k8s-http-mcp-server&quot;)</pre><p>The server name is k8s-http-mcp-server. This is the MCP Server that will expose Kubernetes-related tools over Streamable HTTP.</p><p>The next function is a helper function.</p><pre>def run_kubectl(args: list[str]) -&gt; str:</pre><p>This helper function is used to run kubectl commands. Instead of writing the same subprocess.run() logic inside every MCP tool, we keep it in one place and reuse it.</p><p>Inside this function, the command starts with kubectl, and the remaining arguments are passed dynamically.</p><pre>result = subprocess.run(<br>    [&quot;kubectl&quot;] + args,<br>    capture_output=True,<br>    text=True,<br>    timeout=10,<br>)</pre><p>For example, when the tool passes [&quot;get&quot;, &quot;namespaces&quot;], the final command becomes:</p><pre>kubectl get namespaces</pre><p>When the tool passes [&quot;get&quot;, &quot;pods&quot;, &quot;-n&quot;, &quot;default&quot;], the final command becomes:</p><pre>kubectl get pods -n default</pre><p>The capture_output=True option captures the command output, and text=True returns the output as a string. The timeout=10 option prevents the command from running forever if the cluster is not reachable.</p><p>If the command fails, the error output is returned.</p><pre>if result.returncode != 0:<br>    return result.stderr.strip()</pre><p>If the command succeeds, the normal output is returned.</p><pre>return result.stdout.strip()</pre><p>The code also handles common errors. If kubectl is not installed or not available in the system path, it returns a clear message.</p><pre>except FileNotFoundError:<br>    return &quot;kubectl is not installed or not available on PATH.&quot;</pre><p>If the Kubernetes cluster is not reachable and the command takes too long, it returns a timeout message.</p><pre>except subprocess.TimeoutExpired:<br>    return &quot;kubectl command timed out. Check whether the cluster is reachable.&quot;</pre><p>Now let’s look at the first MCP tool.</p><pre>@mcp.tool()<br>def list_namespaces() -&gt; str:<br>    &quot;&quot;&quot;Lists all namespaces in the Kubernetes cluster.&quot;&quot;&quot;<br>    return run_kubectl([&quot;get&quot;, &quot;namespaces&quot;])</pre><p>The @mcp.tool() decorator exposes this Python function as an MCP tool. Once the MCP client connects to this server, it can discover and call this tool.</p><p>The list_namespaces tool runs this Kubernetes command:</p><pre>kubectl get namespaces</pre><p>This returns the namespaces from the Kubernetes cluster configured in your local kubeconfig.</p><p>The second MCP tool is get_pods_by_namespace.</p><pre>@mcp.tool()<br>def get_pods_by_namespace(namespace: str) -&gt; str:<br>    &quot;&quot;&quot;Returns pods from the given Kubernetes namespace.&quot;&quot;&quot;</pre><p>This tool accepts one input: namespace.</p><p>For example, if the namespace value is default, the tool will return pods from the default namespace.</p><p>Before running the command, the namespace name is validated.</p><pre>if not re.fullmatch(r&quot;[a-z0-9]([-a-z0-9]*[a-z0-9])?&quot;, namespace):<br>    return f&quot;Invalid namespace name: &#39;{namespace}&#39;.&quot;</pre><p>This validation is important because the namespace value comes from the MCP client. Even though this tool is read-only, we should still avoid passing unvalidated input into a command.</p><p>After validation, the tool runs kubectl get pods for the selected namespace.</p><pre>return run_kubectl([&quot;get&quot;, &quot;pods&quot;, &quot;-n&quot;, namespace])</pre><p>If the namespace is default, this becomes:</p><pre>kubectl get pods -n default</pre><p>Finally the server is started using Streamable HTTP</p><pre>if __name__ == &quot;__main__&quot;:<br>    mcp.run(transport=&quot;streamable-http&quot;)</pre><p>This is the key difference from the earlier stdio example.</p><p>With stdio, the MCP client starts the server as a local process.</p><p>With Streamable HTTP, the MCP Server runs as an HTTP service, and the MCP client connects to the server endpoint.</p><h4>Step 4: Run the Streamable HTTP MCP Server</h4><p>Start the server.</p><pre>python server.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*96IM_Q1M54Rw9Rga-9ryEw.png" /></figure><p>Keep this terminal running. The MCP Server must be active while we test it.</p><p>This is the main difference from the stdio example. With stdio, the MCP client starts the server process. With Streamable HTTP, the server is already running and waits for MCP clients to connect over HTTP.</p><h4>Step 5: Test with MCP Inspector</h4><p>Now open a new terminal and start MCP Inspector.It provides a browser-based UI to connect to the server, list the tools, and run them manually.</p><p>Run the command below from the same project directory.</p><pre>npx @modelcontextprotocol/inspector</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qn6UvVHmsQmUNGVYd_m_gw.png" /></figure><p>MCP Inspector is an interactive tool for testing and debugging MCP Servers, and it supports selecting the transport type when connecting to a server.</p><p>This will start the MCP Inspector and open a browser UI (http://127.0.0.1:6274)</p><p>In the MCP Inspector UI, select Streamable HTTP as the transport type.Enter the server URL: <a href="http://127.0.0.1:8000/mcp">http://127.0.0.1:8000/mcp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*limieApFyTMQic5juCpZeA.png" /></figure><p>Click Connect.Once connected, click Tools and then click List Tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TVNEw8so4dxRmcjJ8CqW8A.png" /></figure><p>You should see the tools exposed by the server:</p><ul><li>list_namespaces</li><li>get_pods_by_namespace</li></ul><p>This confirms that MCP Inspector is connected to the Streamable HTTP MCP Server.</p><h4>Step 6: Run the list_namespaces tool</h4><p>Run the list_namespaces tool from MCP Inspector.The tool should return the namespaces from your Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgkzUr-yTy41ZtrMlmfzrQ.png" /></figure><p>You can compare the result with the direct kubectl command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8itapEe2vwH9F5RjaaCqwA.png" /></figure><p>If both outputs match, the MCP Server is successfully reading data from your Kubernetes cluster.This is an important point. The MCP Server is not returning static text. It is calling kubectl and returning the current cluster information.</p><h4>Step 7: Run the get_pods_by_namespace Tool</h4><p>Next, run the get_pods_by_namespace tool.Use a namespace that exists in your cluster, for example default.</p><p>The MCP Server will run the equivalent command in the background.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ts4C4L7hvkNWQqoxdZsT_Q.png" /></figure><p>You can verify the output manually by running the same command in another terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WFPWpTWntDUCZ-FwcecZcg.png" /></figure><p>If the namespace has pods, they will be listed in the MCP Inspector output. If there are no pods, Kubernetes will return the corresponding output.</p><h4>What Changed from stdio?</h4><p>The tool logic is almost the same as the earlier MCP Server examples. We are still using Python functions, the @mcp.tool() decorator, and kubectl.</p><p>The main change is the transport.</p><p>With stdio, the MCP client starts the server process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQW5JeRP_v_DxbAWEmkuUw.png" /></figure><p>With Streamable HTTP, the MCP Server starts independently and waits for clients to connect over HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWSAabsprvN-XGChbGBevA.png" /></figure><p>That is the key difference.The tools can remain similar, but the way the client connects to the server changes.</p><h4>Why Streamable HTTP Matters</h4><p>Streamable HTTP becomes useful when the MCP Server needs to run as a service.</p><p>For example, a platform team may want to build an MCP Server that exposes approved read-only tools for Kubernetes troubleshooting. Instead of asking every engineer to run the server locally, the team can run the MCP Server in one place and allow engineers to connect to it.</p><p>This approach is useful for shared DevOps and Platform Engineering workflows.</p><p>Examples include:</p><ul><li>Kubernetes cluster inspection</li><li>GitHub repository insights</li><li>Terraform module discovery</li><li>Prometheus alert summaries</li><li>CI/CD pipeline status</li><li>Cloud resource inventory</li></ul><p>The important point is that Streamable HTTP changes the MCP Server from a local script into a service that clients can connect to</p><p>For this blog, we are only running the server locally. But the same idea can later be extended to Docker, Kubernetes, ECS, Azure Container Apps, or Amazon Bedrock AgentCore Runtime.</p><h4>Step 4: Connect Streamable HTTP MCP Server with Claude Desktop</h4><p>Claude Desktop configuration usually starts local MCP Servers using stdio. Since our server is running with Streamable HTTP, we can use mcp-remote as a bridge.</p><p>Add the following configuration to claude_desktop_config.json:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;k8s-inspector&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;-y&quot;,<br>        &quot;mcp-remote&quot;,<br>        &quot;http://127.0.0.1:8000/mcp&quot;<br>      ]<br>    }<br>  }<br>}</pre><p>Save the file and restart Claude Desktop.</p><p>Now Claude Desktop can connect to the Streamable HTTP MCP Server through mcp-remote. Make sure the MCP Server is already running before opening Claude Desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubOMf3T7gROEAzTkMFAsFA.png" /></figure><p>Also keep the Python server name the same</p><pre>mcp = FastMCP(&quot;k8s-http-mcp-server&quot;)</pre><p>To verify the connection, click the + in the chat window and choose connectors and you should see k8s-http-mcp-server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4Up0GZ6_guqiE-x17YrbA.png" /></figure><p>To test it, enter the following prompt</p><p>“List all Kubernetes namespaces in my cluster”</p><p>Before the tool is executed, Claude asks for your permission. You can review the request and click <strong>Always allow</strong> or <strong>Allow once</strong> to let Claude invoke the tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pZUgpKLFOoP5THpBH75CRg.png" /></figure><p>Once permission is granted, Claude invokes the MCP tool, which executes the corresponding kubectl command and returns the list of namespaces from the Kubernetes cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KBcxJWCCJwwwh72D7lEScg.png" /></figure><p>You can verify the namespaces by opening a new terminal and running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qKVqXIf0Rwk5BtzBw1XQgg.png" /></figure><p>You can run the prompt “Show me the pods in the kube-system namespace”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-p-9OljKwz8pxJyoAs44Q.png" /></figure><p>Since the request is to show pods from the <strong>kube-system</strong> namespace, the MCP Server will invoke the get_pods_by_namespace tool and return the current pod details from that namespace. This provides live information from the cluster instead of a static response.</p><h4>Security considerations</h4><p>This tutorial runs the Streamable HTTP MCP Server locally for learning and testing.</p><p>Before using this pattern in a shared or production environment, security needs to be considered properly. At minimum, think about authentication, authorization, TLS, audit logging, input validation, least-privilege Kubernetes access, and avoiding arbitrary shell execution.</p><p>In this example, the server exposes only two controlled read-only tools. It does not expose full terminal access or unrestricted kubectl commands.</p><p>That is the pattern to follow when building MCP Servers for Cloud and DevOps workflows.</p><h4>Conclusion</h4><p>In this tutorial, we built a simple Streamable HTTP MCP Server using Python.</p><p>The server exposed two Kubernetes tools: one to list namespaces and another to get pods from a namespace. We ran the server locally as an HTTP service and tested it using MCP Inspector.</p><p>The important takeaway is that Streamable HTTP changes how MCP clients connect to the server. With stdio, the client starts the server locally. With Streamable HTTP, the server runs independently and clients connect to it over HTTP.</p><p>For Cloud, DevOps, and Platform Engineers, this is the next step after local MCP development. Start with stdio to learn and build quickly. Move to Streamable HTTP when the MCP Server needs to run as a shared service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94bf883d410c" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/mcp-zero-to-hero-4-build-your-first-mcp-server-with-streamable-http-94bf883d410c">MCP Zero to Hero:4.Build Your First MCP Server with Streamable HTTP</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP Zero to Hero:3. stdio vs Streamable HTTP: Which MCP Transport Should You Use?]]></title>
            <link>https://devopstronaut.com/mcp-zero-to-hero-stdio-vs-streamable-http-which-mcp-transport-should-you-use-fd24abd71866?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd24abd71866</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Thu, 09 Jul 2026 13:43:05 GMT</pubDate>
            <atom:updated>2026-07-09T23:59:30.293Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuwygZxHqADAwj2z-ejZZg.png" /></figure><p>In the previous blog, we built a simple Kubernetes MCP Server using Python. The server exposed tools to read pod status and create a pod in a local Kind cluster. We tested it using MCP Inspector and then connected it with Claude Desktop.</p><p>That example worked well because we used the stdio transport.</p><p>At that stage, the focus was mainly on building the MCP Server and testing the tools. But once the server starts working, the next question is important:</p><p>How does the AI client actually communicate with the MCP Server?</p><p>This is where MCP transports come in.</p><p>In this blog, we will look at stdio and Streamable HTTP from a practical Cloud, DevOps, and Platform Engineering point of view. Instead of only explaining the specification, we will connect it back to the Kubernetes MCP Server example and understand which transport makes sense for different use cases.</p><h4>What Is an MCP Transport?</h4><p>An MCP transport defines how the MCP client and MCP Server communicate with each other.</p><p>The transport does not change the tools exposed by the server. Your MCP Server may expose tools to check Kubernetes pods, run Terraform plan, list GitHub pull requests, query Prometheus metrics, or retrieve AWS resource details. Those tools remain the same</p><p>The transport only decides how requests and responses move between the client and the server.</p><p>MCP currently defines stdio and Streamable HTTP as standard transport mechanisms for client-server communication. MCP messages are encoded using JSON-RPC, and the selected transport decides how those messages are exchanged.</p><p>In simple terms:</p><ul><li>Use stdio when the MCP Server runs locally.</li><li>Use Streamable HTTP when the MCP Server needs to run remotely or be shared.</li></ul><p>That is the easiest way to understand the difference.</p><h4>Why We Used stdio First</h4><p>In the Kubernetes MCP Server tutorial, we used this line:</p><pre>mcp.run(transport=&quot;stdio&quot;)</pre><p>This tells the MCP Server to use standard input and standard output for communication.</p><p>With stdio, the MCP client launches the MCP Server as a subprocess. The server reads messages from stdin and sends responses back through stdout.</p><p>In our example, Claude Desktop started the Python MCP Server locally. There was no web server, no HTTP endpoint, no port number, no ingress, and no TLS certificate. Everything happened on the laptop.</p><p>That is why stdio is a good starting point. It removes the deployment complexity and allows us to focus on writing useful MCP tools.</p><p>For DevOps engineers, this feels natural because we already use many local CLI tools every day, such as kubectl, terraform, aws, az, docker, and gh. With stdio, we can wrap those commands inside MCP tools and allow the AI assistant to call only the operations we expose.</p><h4>Practical Experience with stdio</h4><p>While testing the Kubernetes MCP Server locally, the setup was straightforward. Claude Desktop was configured to run the Python file. The Python file used kubectl. The kubectl command used the local kubeconfig. The kubeconfig pointed to the Kind cluster running on the laptop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8wDPqYeKEGenegjaiwfSQ.png" /></figure><p>This worked well because the MCP Server used the same Kubernetes access that was already configured on the laptop. If kubectl get pods worked from the terminal, the MCP tool was also able to return pod status.</p><p>When Claude Desktop was asked to create a pod, it did not generate a guessed response. It invoked the create_pod tool exposed by the MCP Server. The MCP Server executed the approved kubectl command and returned the actual result.</p><p>That is the key difference between a normal AI response and an MCP-enabled workflow. The AI assistant is not only explaining Kubernetes. It is using a controlled tool that interacts with the local Kubernetes environment.</p><h4>Where stdio Works Well</h4><p>The stdio transport works well when the MCP Server is mainly for one user and one local environment.</p><p>It is a good choice for:</p><ul><li>Learning MCP</li><li>Building your first MCP Server</li><li>Local Kubernetes testing with Kind or Minikube</li><li>Personal DevOps automation</li><li>Local Terraform workflows</li><li>Docker Desktop workflows</li><li>CLI-based experiments</li><li>Testing custom tools before remote deployment</li></ul><p>For beginners, stdio should usually be the first choice. It keeps the setup simple and avoids unnecessary platform complexity. You can focus on the tool logic first.</p><p>Once the tools become useful and other engineers also need to use them, then it makes sense to think about remote deployment.</p><h4>Where stdio Becomes a Limitation</h4><p>The limitation appears when the MCP Server needs to be shared.</p><p>Imagine a platform team with 30 or 50 engineers. If the MCP Server only runs through stdio, every engineer needs to clone the code, install dependencies, configure the MCP client, install the required CLI tools, manage local credentials, and keep the local copy updated.</p><p>This is acceptable for learning and personal usage, but it becomes difficult to manage for a team.</p><p>At that point, the better question is:</p><p>Can we deploy the MCP Server once and allow multiple engineers to connect to it?</p><p>That is where Streamable HTTP becomes useful.</p><h4>What Is Streamable HTTP?</h4><p>Streamable HTTP is used when the MCP Server runs as an independent process and clients connect to it over HTTP.</p><p>Instead of the AI client starting a local Python process, the MCP Server is deployed somewhere centrally. It could run on a virtual machine, a Kubernetes cluster, Amazon ECS, Azure Container Apps, or an internal platform service.</p><p>In Streamable HTTP, the server can operate independently and handle multiple client connections. The transport uses HTTP POST and GET requests, and the server can optionally use Server-Sent Events for streaming server messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Smya7s-SwsyMXKqLjofnQ.png" /></figure><p>This changes the model from a local personal server to a shared engineering service.</p><h4>Practical Example: Moving from stdio to Streamable HTTP</h4><p>In the previous Kubernetes MCP Server, we used stdio.</p><pre>if __name__ == &quot;__main__&quot;:<br>    mcp.run(transport=&quot;stdio&quot;)</pre><p>This worked because Claude Desktop and the MCP Server were running on the same laptop.</p><p>For a remote or shared setup, the same idea can move toward Streamable HTTP.</p><p>A simplified example looks like this:</p><pre>if __name__ == &quot;__main__&quot;:<br>    mcp.run(transport=&quot;streamable-http&quot;)</pre><p>The exact server options can vary based on the MCP Python SDK or FastMCP version you are using, but the concept is the same: the server is no longer launched only as a local subprocess by the AI client. It can run as an HTTP service and expose an MCP endpoint for clients to connect to.</p><p>The Python SDK supports standard transports including stdio, Streamable HTTP, and SSE.</p><p>For example, in a platform engineering setup, the MCP Server could be deployed as a container. Instead of every engineer running the Python script locally, they connect their MCP-compatible client to the shared MCP endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_L6Ako5EDjiV80-Gh3oiw.png" /></figure><p>This is where Streamable HTTP becomes more practical. The platform team can manage the server centrally, control access, apply logging, and update the tools in one place.</p><h4>Practical Team Scenario</h4><p>Consider a platform team that wants to provide AI-assisted troubleshooting for Kubernetes workloads.</p><p>With stdio, each engineer may run their own MCP Server locally. That works during learning, but it becomes harder when the same workflow needs to be shared across the team.</p><p>With Streamable HTTP, the platform team can deploy one shared MCP Server that exposes approved tools such as:</p><ul><li>Get pod status</li><li>Fetch pod logs</li><li>Show failed deployments</li><li>Query Prometheus alerts</li><li>List recent GitHub Actions failures</li><li>Retrieve Terraform module information</li><li>Show AWS resource inventory</li></ul><p>Now engineers do not need to maintain separate local copies of the same MCP Server. They connect to the shared server, and the platform team controls what tools are available.</p><p>This is closer to how platform engineering teams usually operate. Instead of every engineer creating their own scripts, the platform team provides a common interface that is secure, repeatable, and easier to maintain.</p><h4>stdio vs Streamable HTTP</h4><p>Both transports use MCP, but they are designed for different situations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FuecnF_JQuLdEyCu6k8Dg.png" /></figure><h4>Security Considerations</h4><p>Security is important with both transports, but the risks are different.</p><p>With stdio, the MCP Server usually runs with the same access as the local user. If the local machine has access to a Kubernetes cluster, AWS account, or GitHub repository, the MCP Server may be able to use that same access.</p><p>That is why tools should be specific and limited. In the Kubernetes example, we exposed only selected tools. We did not expose arbitrary shell execution.</p><p>With Streamable HTTP, the server is available over the network, so the security design becomes more important. The MCP transport specification recommends security controls for Streamable HTTP, including validating the Origin header, binding local servers only to localhost when appropriate, and implementing proper authentication.</p><p>Authentication and authorization also differ by transport. The MCP authorization specification says HTTP-based transports should follow the authorization specification when supported, while STDIO implementations should retrieve credentials from the environment.</p><p>For Cloud and DevOps use cases, this matters because MCP Servers may interact with production systems, cloud accounts, CI/CD pipelines, and observability platforms. The tools should be designed with least privilege in mind.</p><h4>My Recommendation</h4><p>Start with stdio</p><p>When learning MCP or building your first few tools, stdio is the easiest and most practical option. It works well with local tools and does not require any hosting setup.</p><p>This is also the best way to validate whether the MCP tool is actually useful. Build the tool locally, test it with MCP Inspector, connect it to Claude Desktop, and check whether it improves your workflow.</p><p>Once the tool becomes useful for a wider team, then consider Streamable HTTP.</p><p>For example, if a Kubernetes troubleshooting MCP Server is useful for multiple engineers, it may be better to deploy it centrally. The platform team can manage authentication, authorization, logging, and updates from one place.</p><p>The important point is that you do not need to start with the most complex option. Start locally, prove the value, and then move toward a shared deployment model when needed.</p><h4>Conclusion</h4><p>MCP transports decide how the MCP client and MCP Server communicate.</p><p>The stdio transport is simple and works well for local development, learning, and personal DevOps workflows. It is the best place to start when building your first MCP Server.</p><p>Streamable HTTP is better when the MCP Server needs to be shared, hosted, secured, and managed for a team. It is more suitable for platform engineering use cases where multiple engineers or AI clients need access to the same approved tools.</p><p>For Cloud, DevOps, and Platform Engineers, the choice is practical. Use stdio when building and testing locally. Use Streamable HTTP when the MCP Server becomes part of a shared engineering platform.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd24abd71866" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/mcp-zero-to-hero-stdio-vs-streamable-http-which-mcp-transport-should-you-use-fd24abd71866">MCP Zero to Hero:3. stdio vs Streamable HTTP: Which MCP Transport Should You Use?</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP Zero to Hero: 2.Build Your First MCP Server in 15 Minutes (No AI Background Needed)]]></title>
            <link>https://devopstronaut.com/mcp-zero-to-hero-2-build-your-first-mcp-server-in-15-minutes-no-ai-background-needed-c592834dbdec?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c592834dbdec</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Wed, 08 Jul 2026 15:12:42 GMT</pubDate>
            <atom:updated>2026-07-08T15:12:42.352Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCZwEn5HPd5jW7NSvtMLlQ.png" /></figure><p>In the previous article, we explored what the Model Context Protocol (MCP) is and why it is becoming an important standard for Cloud, DevOps, and Platform Engineers. We discussed how MCP enables AI assistants to interact with external tools through a standard interface instead of relying on custom integrations for every AI application.</p><p>Now it’s time to build one.</p><p>One of the best ways to understand MCP is by creating a simple server yourself. Fortunately, building an MCP Server is much easier than it first appears. You don’t need any AI or machine learning knowledge. If you’re comfortable writing Python scripts and running commands in a terminal, you already have everything you need.</p><p>In this tutorial, we’ll build a Kubernetes MCP Server that interacts with a local Kind cluster. The server will expose two tools:</p><ul><li><strong>get_pod_status: </strong>Returns the status of pods running in the default namespace.</li><li><strong>create_pod: </strong>Creates a Kubernetes pod using the image specified by the user.</li></ul><p>Instead of returning predefined data, both tools use kubectl, so they work with the Kubernetes cluster currently configured on your machine.By the end of this tutorial, you’ll understand how MCP tools are created, how they communicate with Kubernetes, and how to test them using the official MCP Inspector.</p><h4>Prerequisites</h4><p>Before we begin, make sure the following software is installed.</p><ul><li>Python 3.10 or later</li><li>kubectl</li><li>Kind</li><li>Node.js</li></ul><p>If your Kind cluster is already running, verify that everything is working correctly.</p><pre>kubectl cluster-info<br>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CsLokW2oKBHV-C2k3uOcsA.png" /></figure><p>If these commands return information about your cluster, you’re ready to continue.</p><h4>Step 1: Set up the project</h4><p>Create a new project directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oba2kzHL86UGnpOWgNrBlQ.png" /></figure><p>Install mcp using this command</p><pre>pip install mcp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q53v_NJrXVlfWFAyY4O5Pg.png" /></figure><h4>Step 2: Write the server</h4><p>Create a file called server.py. We&#39;ll build a tool that reports real status from your own cluster, by shelling out to kubectl the same command you already run by hand.</p><pre>from mcp.server.fastmcp import FastMCP<br>import subprocess, re<br><br>mcp = FastMCP(&quot;devops-status-server&quot;)<br><br>@mcp.tool()<br>def create_pod(pod_name: str, image: str) -&gt; str:<br>    &quot;&quot;&quot;Creates a Kubernetes pod in the default namespace using the given image.&quot;&quot;&quot;<br>    if not re.fullmatch(r&quot;[a-z0-9]([-a-z0-9]*[a-z0-9])?&quot;, pod_name):<br>        return f&quot;Invalid pod name: &#39;{pod_name}&#39;.&quot;<br>    if not re.fullmatch(r&quot;[a-zA-Z0-9_./:-]+&quot;, image):<br>        return f&quot;Invalid image: &#39;{image}&#39;.&quot;<br><br>    try:<br>        result = subprocess.run(<br>            [&quot;kubectl&quot;, &quot;run&quot;, pod_name, f&quot;--image={image}&quot;, &quot;-n&quot;, &quot;default&quot;, &quot;--restart=Never&quot;],<br>            capture_output=True, text=True, timeout=15,<br>        )<br>    except FileNotFoundError:<br>        return &quot;kubectl not found on PATH.&quot;<br>    except subprocess.TimeoutExpired:<br>        return &quot;kubectl timed out. Is your cluster reachable?&quot;<br><br>    if result.returncode != 0:<br>        return f&quot;Failed to create pod &#39;{pod_name}&#39;: {result.stderr.strip()}&quot;<br>    return f&quot;Pod &#39;{pod_name}&#39; submitted with image &#39;{image}&#39;. Check status: kubectl get pods {pod_name} -n default&quot;<br><br>if __name__ == &quot;__main__&quot;:<br>    mcp.run(transport=&quot;stdio&quot;)</pre><p><strong>Understanding the Code</strong></p><p>The first line imports the FastMCP class.</p><pre>from mcp.server.fastmcp import FastMCP</pre><p>FastMCP provides a simple way to create an MCP Server without implementing the protocol yourself.Next we import two standard Python modules.</p><pre>import subprocess<br>import re</pre><p>The subprocess module executes kubectl commands, while re validates user input before running those commands.Now we create the MCP Server.</p><pre>mcp = FastMCP(&quot;k8s-pod-mcp-server&quot;)</pre><p>This gives the server a name that will appear when an MCP client connects. The most important part of the code is the @mcp.tool() decorator.</p><pre>@mcp.tool()</pre><p>Every function decorated with @mcp.tool() becomes available to MCP clients.When an AI assistant connects to this server, it automatically discovers these tools and understands their input parameters and descriptions.</p><p>The first tool is get_pod_status.</p><p>Instead of using a Kubernetes SDK, it simply executes the same command you would normally run in your terminal.</p><pre>kubectl get pods -n default</pre><p>Inside Python, the same command is executed using subprocess.run().</p><pre>result = subprocess.run(<br>    [&quot;kubectl&quot;, &quot;get&quot;, &quot;pods&quot;, &quot;-n&quot;, &quot;default&quot;],<br>    capture_output=True,<br>    text=True,<br>    timeout=15,<br>)</pre><p>If the command succeeds, the output is returned directly to the MCP client. The second tool, create_pod, accepts two parameters:</p><ul><li>pod_name</li><li>image</li></ul><p>Before creating the pod, the code validates the pod name.</p><pre>if not re.fullmatch(r&quot;[a-z0-9]([-a-z0-9]*[a-z0-9])?&quot;, pod_name):</pre><p>This prevents invalid Kubernetes resource names from being passed to kubectl.The image name is also validated before execution.</p><pre>if not re.fullmatch(r&quot;[a-zA-Z0-9_./:-]+&quot;, image):</pre><p>Once both values are validated, the server executes the following Kubernetes command.</p><pre>kubectl run nginx-demo --image=nginx:latest -n default --restart=Never</pre><p>The equivalent Python code is:</p><pre>result = subprocess.run(<br>    [<br>        &quot;kubectl&quot;,<br>        &quot;run&quot;,<br>        pod_name,<br>        f&quot;--image={image}&quot;,<br>        &quot;-n&quot;,<br>        &quot;default&quot;,<br>        &quot;--restart=Never&quot;,<br>    ],<br>    capture_output=True,<br>    text=True,<br>    timeout=15,<br>)</pre><p>Finally, the server starts using the stdio transport.</p><pre>mcp.run(transport=&quot;stdio&quot;)</pre><p>The stdio transport is commonly used for local MCP Servers because the MCP client launches the server as a child process and communicates through standard input and output.</p><h4>Step 3: Test it with the MCP Inspector</h4><p>Now we need to test the MCP Server. For this, we can use the official MCP Inspector. It provides a browser-based UI to connect to the server, list the tools, and run them manually.</p><p>Run the command below from the same project directory.</p><pre>npx @modelcontextprotocol/inspector python server.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yfRfONBf3iMp9k0CPe8XQQ.png" /></figure><p>This will start the MCP Inspector and open a browser UI (http://127.0.0.1:6274)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-DVnseZpuStCkGMVCNv4w.png" /></figure><p>Copy the session token and paste it to Proxy session Token in Configuration and click Connect</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RvKY0EU8fT8C-gRhnCNpxA.png" /></figure><p>Once the connection is established, navigate to the Tools tab and click List Tools. The create_pod tool will be displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEyepJhuquahd21Wze27Zw.png" /></figure><p>Enter the pod name and container image, then click <em>Run Tool</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjiAL_bG1o3W-EJ4kpUJxQ.png" /></figure><p>The pod will now be created in the default namespace using the specified container image. Open a new terminal and run the following command to verify that the pod has been created successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hoTAJIGlcmQdqY4gBfBltQ.png" /></figure><h4>Step 4: Connect it to Claude Desktop</h4><p>So far, we’ve tested the MCP Server using MCP Inspector. The next step is to connect it to Claude Desktop and let the AI assistant use the tools directly.</p><p>Locate the Claude Desktop configuration file.</p><pre>~/Library/Application Support/Claude/claude_desktop_config.json</pre><p>Open the configuration file and add the following MCP Server configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9g0wVr81OGl-OXDUQ5CZmQ.png" /></figure><p>Once Claude Desktop starts, it automatically launches the MCP Server and discovers the available tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*daNd83nDrZRDRJ-6iGCb4A.png" /></figure><p>To verify the connection, click the + in the chat window and choose connectors and you should see k8s-pod-mcp-server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r0g1jlFnCZ2B09rH-WjLYg.png" /></figure><p>To test it, enter the following prompt</p><p>“Create a pod named <strong>busybox-demo</strong> using the <strong>busybox</strong> image”</p><p>Before the tool is executed, Claude asks for your permission. You can review the request and click <strong>Always allow</strong> or <strong>Allow once</strong> to let Claude invoke the tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnR3zDW4E4up3NcPDg6pwA.png" /></figure><p>Once permission is granted, Claude invokes the MCP tool which executes the corresponding kubectl command and creates the pod in the default namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1cVfwGkaQdSnN_IWm_glkA.png" /></figure><p>You can verify that the pod has been created successfully by opening a new terminal and running the following command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RcbKUI2OGcjMv3w0d3mK6A.png" /></figure><p>You can re-run the same prompt “Create a pod named nginx using the nginx image”</p><p>Since the pod already exists in the default namespace, the MCP Server will return the current status and explain that the pod is already available. This helps avoid duplicate resource creation and gives useful feedback from the cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bxQHN5T_QinBIJDbATLww.png" /></figure><h4>Conclusion</h4><p>In this tutorial, we built our first Kubernetes MCP Server using Python and exposed two simple tools: one to retrieve pod status and another to create a pod in a Kubernetes cluster. We then tested the server using MCP Inspector and integrated it with Claude Desktop to see how an AI assistant can invoke MCP tools to perform real Kubernetes operations.</p><p>Although this example is intentionally simple, it demonstrates the core concepts behind MCP. Instead of relying only on an AI model’s knowledge, the assistant can securely interact with external tools and retrieve live information from your environment. This opens the door to building more powerful MCP Servers for everyday Cloud and DevOps tasks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c592834dbdec" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/mcp-zero-to-hero-2-build-your-first-mcp-server-in-15-minutes-no-ai-background-needed-c592834dbdec">MCP Zero to Hero: 2.Build Your First MCP Server in 15 Minutes (No AI Background Needed)</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MCP Zero to Hero: What Is Model Context Protocol (MCP)?]]></title>
            <link>https://devopstronaut.com/what-is-model-context-protocol-mcp-a-practical-guide-for-cloud-devops-and-platform-engineers-bc7f402f3838?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc7f402f3838</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Tue, 07 Jul 2026 16:22:38 GMT</pubDate>
            <atom:updated>2026-07-07T16:34:33.582Z</atom:updated>
            <content:encoded><![CDATA[<h3>MCP Zero to Hero: What Is Model Context Protocol (MCP)? A Practical Guide for Cloud, DevOps, and Platform Engineers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHb8hyQzCgOs4_z8R1ws4g.png" /></figure><p>Cloud, DevOps, and Platform Engineers spend their day working across multiple tools. A typical workflow might involve reviewing GitHub pull requests, provisioning infrastructure with Terraform, troubleshooting Kubernetes workloads, monitoring applications, and managing cloud resources.</p><p>AI assistants are quickly becoming part of these workflows. They can explain concepts, generate code, and answer questions. But for AI to become a true engineering assistant, it needs access to real engineering tools and live data not just information from its training.</p><p>This is where <strong>Model Context Protocol (MCP)</strong> comes in.</p><p>MCP provides a standard way for AI applications to communicate with external tools and services. Instead of building a separate integration for every AI assistant and every DevOps tool, MCP defines a common protocol that works across different platforms.</p><p>In this article, we’ll explore what MCP is, what a DevOps MCP Server does, why Cloud and DevOps engineers should care, and how it fits into modern engineering workflows.</p><h4>What is Model Context Protocol (MCP)?</h4><p><strong>Model Context Protocol (MCP)</strong> is an open standard that enables AI applications to communicate with external tools, services, and data sources through a consistent interface.</p><p>Think of MCP as a common language between AI assistants and engineering tools.</p><p>Without MCP, every AI application would need its own custom integration for GitHub, Kubernetes, Terraform, AWS, Azure, or any other platform. As more AI assistants and engineering tools are introduced, the number of integrations grows rapidly.</p><p>With MCP, each tool only needs to expose its capabilities once. Any MCP-compatible AI application can then communicate with that tool using the same protocol.</p><p>Instead of building multiple integrations, engineers build one MCP Server that can be reused by different AI clients.</p><h4>Why Do We Need MCP?</h4><p>Let’s consider a common troubleshooting scenario.</p><p>Without MCP, if you ask an AI assistant:</p><pre>Why is my Kubernetes pod restarting?</pre><p>You would typically need to:</p><ul><li>Copy the pod logs</li><li>Run kubectl describe</li><li>Share the deployment YAML</li><li>Paste events</li><li>Repeat the process whenever new information is needed</li></ul><p>The AI has no direct access to your engineering environment.</p><p>With MCP, the workflow becomes much simpler.</p><p>You ask the same question:</p><pre>Why is my Kubernetes pod restarting?</pre><p>The AI can use a Kubernetes MCP Server to:</p><ul><li>Retrieve pod status</li><li>Read Kubernetes events</li><li>View application logs</li><li>Inspect deployment configuration</li><li>Recommend possible solutions</li></ul><p>Instead of manually gathering information, the AI retrieves the required context from your engineering tools.</p><h4>The Integration Problem</h4><p>Without MCP, every AI assistant requires its own integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fSGMcFWjAaMpOoEceQuvA.png" /></figure><p>As more AI applications are introduced, the number of integrations grows rapidly.</p><p>With MCP, every tool exposes a standard interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jGCwoDwwF9Y4hm8GnmkoEw.png" /></figure><p>The same approach works for Terraform, GitHub, AWS, Azure, Docker, Jenkins, Prometheus, Grafana, and many other tools.</p><h3>Simple Architecture</h3><p>At a high level, the architecture is straightforward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*RgSj3oVozrWKMfQn-Z6-ew.png" /></figure><h4>Why Cloud, DevOps, and Platform Engineers Should Care</h4><p>Modern engineering teams constantly switch between multiple tools.</p><p>A typical task may involve:</p><ul><li>Opening documentation</li><li>Running CLI commands</li><li>Searching GitHub</li><li>Checking monitoring dashboards</li><li>Reviewing CI/CD pipelines</li><li>Looking through Kubernetes events</li></ul><p>This context switching consumes valuable time.</p><p>MCP allows AI assistants to retrieve information directly from engineering systems, reducing the need to manually gather and paste information.</p><p>Instead of asking:</p><pre>How do I configure an AWS Application Load Balancer using Terraform?</pre><p>The AI can retrieve the latest Terraform provider documentation before generating the configuration.</p><p>Instead of asking:</p><pre>What does CrashLoopBackOff mean?</pre><p>The AI can inspect the actual workload and provide recommendations based on live cluster data.</p><p>The engineer spends less time switching between tools and more time solving problems.</p><h4>Common DevOps MCP Servers</h4><p>Many engineering platforms now provide MCP Servers or community implementations.</p><p>Some common examples include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qxaWL4rdhvLephTTbRJB7w.png" /></figure><p>These MCP Servers allow AI assistants to retrieve live information instead of relying only on static knowledge.</p><h4>Security Considerations</h4><p>Although MCP simplifies communication between AI assistants and engineering tools, security remains essential.</p><p>A well-designed MCP Server should:</p><ul><li>Follow the principle of least privilege</li><li>Expose only the tools that are required</li><li>Protect credentials and secrets</li><li>Validate all inputs</li><li>Log tool usage where appropriate</li><li>Avoid providing unrestricted shell access</li></ul><p>MCP standardizes communication, it does <strong>not</strong> replace authentication, authorization, or existing security controls.</p><p>Engineers remain responsible for deciding what capabilities an MCP Server exposes.</p><h4>Common Misconceptions</h4><p><strong>MCP is not an AI model: </strong>MCP is simply a communication protocol between AI applications and external tools.</p><p><strong>MCP is not tied to one AI provider: </strong>MCP is an open standard that can be implemented by different AI applications.</p><p><strong>MCP does not replace your existing automation: </strong>Your Terraform code, Kubernetes manifests, CI/CD pipelines, cloud infrastructure, and scripts remain exactly as they are.</p><p>MCP simply provides a standardized way for AI assistants to interact with them.</p><h4>Conclusion</h4><p>Model Context Protocol (MCP) is quickly becoming an important standard for connecting AI assistants with Cloud, DevOps, and Platform Engineering tools.</p><p>Rather than building custom integrations for every AI application, MCP provides a consistent way to interact with infrastructure, cloud platforms, Kubernetes clusters, source code repositories, CI/CD systems, and observability platforms.</p><p>For Cloud, DevOps, and Platform Engineers, this means AI assistants can move beyond answering questions and begin working with live engineering systems in a secure and standardized way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc7f402f3838" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/what-is-model-context-protocol-mcp-a-practical-guide-for-cloud-devops-and-platform-engineers-bc7f402f3838">MCP Zero to Hero: What Is Model Context Protocol (MCP)?</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Terraform MCP Server: Bringing Terraform Context into AI Assistants]]></title>
            <link>https://devopstronaut.com/exploring-terraform-mcp-server-bringing-terraform-context-into-ai-assistants-6c2736a01660?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c2736a01660</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[terraform-mcp-server]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 06:31:00 GMT</pubDate>
            <atom:updated>2026-07-03T06:31:00.892Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*US3XnRZA6wxvS76PyXaodg.png" /></figure><p>Recently, I started exploring the <strong>Terraform MCP Server</strong> and how it can help when working with Terraform and AI-assisted development.</p><p>When we write Terraform code, one common thing we always do is search the Terraform Registry. We check provider documentation, resource arguments, module inputs, outputs, versions, and examples.</p><p>This is useful, but sometimes it takes us away from the actual work. We open the editor, then the browser, then documentation, then come back to the editor again.</p><p>Terraform MCP Server helps reduce that context switching.</p><p>In this blog, I am focusing only on <strong>Terraform MCP Server. </strong>what it is, why it is useful, how to configure it, and how it helps AI assistants understand Terraform better.</p><p>This is where the <strong>Terraform MCP Server</strong> becomes useful.</p><p>The Terraform MCP Server allows AI assistants such as Claude, Cursor, VS Code, and other MCP-compatible tools to connect directly with Terraform Registry information. Instead of manually searching the registry, your AI assistant can look up providers, resources, modules, versions, and policy information for you.</p><p>In this blog, I will walk through how I use the Terraform MCP Server with <strong>Terraform CLI Community Edition</strong> to build AWS infrastructure with AI-assisted development.</p><h4>What is the Terraform MCP Server?</h4><p>The Terraform MCP Server is a Model Context Protocol server built for Terraform. MCP allows AI models to connect with external tools, applications, and data sources securely.</p><p>In simple terms, Terraform MCP Server acts as a bridge between an AI assistant and the Terraform ecosystem.</p><p>Instead of relying only on the AI model’s training data, the assistant can access current Terraform provider documentation, modules, policies, private registry data, workspace details, runs, plans, and configurations. This helps generate more accurate Terraform code and gives engineers better context while working with infrastructure.</p><p>In simple words:</p><p><strong>Terraform MCP Server gives Terraform Registry context to your AI assistant.</strong></p><p>It helps your AI assistant answer questions like:</p><p>Search for the AWS provider in the Terraform Registry.</p><p>Show me the details of the aws_instance resource.</p><p>Search for Terraform modules related to VPC.</p><p>What is the latest version of the hashicorp/aws provider?</p><p>Instead of manually opening the Terraform Registry every time, I can ask my AI assistant directly.</p><h4>Why Terraform MCP Server Matters</h4><p>AI assistants are useful for writing Terraform code, but they can sometimes produce outdated examples or suggest deprecated provider arguments. This is risky in real infrastructure environments.</p><p>Terraform MCP Server helps reduce that risk by giving AI tools access to up-to-date Terraform information.</p><p>It can help with:</p><ul><li>Searching Terraform provider documentation</li><li>Finding public and private Terraform modules</li><li>Understanding provider resources and data sources</li><li>Exploring Sentinel policies</li><li>Accessing HCP Terraform and Terraform Enterprise workspaces</li><li>Reviewing Terraform runs and plans</li><li>Explaining infrastructure changes in natural language</li></ul><p>HashiCorp highlights three major benefits: accelerating infrastructure workflows, generating code using organization-approved standards, and helping teams understand plan changes with context.</p><h4>Why I Started Looking at Terraform MCP Server</h4><p>I work a lot with Terraform, HashiCorp tools, cloud infrastructure, and community learning.</p><p>When preparing demos, blogs, or sessions, I often need to quickly check Terraform provider details or module information.</p><p>Terraform MCP Server is useful because it helps me:</p><ul><li>Save time while searching documentation</li><li>Stay inside the AI assistant or IDE</li><li>Get Terraform Registry information quickly</li><li>Learn new provider resources faster</li><li>Compare Terraform modules easily</li><li>Check latest versions without manual searching</li><li>Improve AI-assisted Terraform suggestions</li></ul><p>It does not replace Terraform knowledge.</p><p>It does not magically make every Terraform code perfect.</p><p>But it gives the AI assistant better context.</p><p>That means the assistant can give more accurate Terraform-related suggestions because it can refer to Terraform Registry information.</p><h4>How Terraform MCP Server Works</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2oR7u-SaTu4QJONZ4pC3ag.png" /></figure><p>The flow works like this:</p><ul><li>The user asks a Terraform-related question in the AI assistant.</li><li>The AI assistant sends the request using MCP.</li><li>Terraform MCP Server receives the request.</li><li>Terraform MCP Server queries Terraform Registry.</li><li>The result is returned back to the AI assistant.</li><li>The assistant uses that context to answer the question.</li></ul><p>This makes the AI assistant more useful for Terraform-related work.</p><h4>What Terraform MCP Server Can Do</h4><p>Terraform MCP Server provides tools for different Terraform Registry use cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7WF-hqxfQh_fZYYbC17Ynw.png" /></figure><p>These tools are helpful because the AI assistant does not need to guess from memory. It can use Terraform MCP Server to retrieve relevant Terraform Registry information.</p><h4>Prerequisites</h4><p>To try Terraform MCP Server, I used the following:</p><ul><li>Docker</li><li>Internet access</li><li>MCP-compatible AI assistant or IDE</li></ul><p>Some MCP-compatible tools include:</p><ul><li>Claude Desktop</li><li>Cursor</li><li>VS Code</li><li>Claude Code CLI</li></ul><h4>Step 1: Clone the Terraform MCP Server Repository</h4><p>The easiest way to start is using Docker.</p><pre>git clone https://github.com/hashicorp/terraform-mcp-server.git<br>cd terraform-mcp-server</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wgLqrI3WNiwcbzS6D1GPTw.png" /></figure><h4>Step 2: Build the Docker Image</h4><p>Now build the Docker image locally using below command</p><pre>make docker-build</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AfBzZ3o9hcqHSOp4PRvriw.png" /></figure><p>This command builds the Terraform MCP Server Docker image locally. After the build is completed, the local Docker image can be used for MCP server configuration and testing.</p><p>The local development image is usually available as terraform-mcp-server:dev</p><h4>Step 3: Running the Server in stdio Mode</h4><p>The Terraform MCP Server can be started in stdio mode by running the following command.</p><pre>docker run -i --rm terraform-mcp-server:dev</pre><p>This starts the Terraform MCP Server using standard input and output communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o32J0n9mX-cEePqpRC9JwQ.png" /></figure><p>This mode is commonly used when the MCP server is connected directly to an AI assistant such as Claude Desktop, Cursor, VS Code, or Claude Code CLI.</p><p>In this setup, the AI assistant starts the Docker container and communicates with the Terraform MCP Server through the MCP protocol.</p><h4>Step 4: Running the Server in Streamable HTTP Mode</h4><p>The Terraform MCP Server can also be started in streamable HTTP mode.</p><pre>docker run -p 8080:8080 --rm \ -e TRANSPORT_MODE=streamable-http \ -e TRANSPORT_HOST=0.0.0.0 \ terraform-mcp-server:dev</pre><p>This command starts the Terraform MCP Server on port 8080.</p><p>The TRANSPORT_MODE environment variable is set to streamable-http so that the server can run using HTTP-based transport.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2A2J7HeXiv0B0OkBGbe7Ug.png" /></figure><p>When running the server inside a Docker container, I set the TRANSPORT_HOST value to 0.0.0.0.</p><p>This is required because the server needs to listen on all network interfaces inside the container. Without this setting, the service may only listen on localhost inside the container, and external clients may not be able to connect to it.</p><p>By setting TRANSPORT_HOST=0.0.0.0, the Terraform MCP Server can accept connections from outside the Docker container, such as from my local machine or an MCP-compatible AI assistant.</p><h4>Step 5:Configuring Terraform MCP Server in Claude Desktop</h4><p>After building the Terraform MCP Server Docker image locally, I configured it in Claude Desktop.</p><p>Claude Desktop uses a JSON configuration file to define local MCP servers. In this case, I added a new MCP server named terraform.</p><p>The configuration looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlsayOolvHr08Sgo1rY5Og.png" /></figure><p>In this configuration, Claude Desktop uses Docker to start the locally built Terraform MCP Server image.</p><p>The command value is set to docker.</p><p>The args section tells Docker to run the container in interactive mode, remove the container after it stops, and use the local image named terraform-mcp-server:dev.</p><p>Here is what each argument means:</p><ul><li>run starts a new Docker container.</li><li>-i keeps standard input open so Claude Desktop can communicate with the MCP server.</li><li>--rm removes the container automatically after it stops.</li><li>terraform-mcp-server:dev is the locally built Terraform MCP Server Docker image.</li></ul><p>After saving this configuration, restart Claude Desktop.</p><p>Then open Claude Desktop settings and go to:</p><p>Settings → Developer → Local MCP servers</p><p>You should see the `terraform` MCP server listed as running.</p><p>This confirms that Claude Desktop successfully started the Terraform MCP Server using the local Docker image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LRE3iY9kq2rSEqFTSQsnYw.png" /></figure><h4>Step 6:Confirming the Output Comes from Terraform MCP Server</h4><p>After configuring the Terraform MCP Server in Claude Desktop, I verified whether Claude was actually using the MCP server.</p><p>I asked Claude the following prompt:</p><pre>Search for the AWS provider in the Terraform Registry</pre><p>Claude started by identifying that it should use the Terraform tool to search the AWS provider in the Terraform Registry.</p><p>In the response, I could see that Claude loaded the available Terraform MCP tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*88JgVFSYsszFyR5lD6Ug8A.png" /></figure><p>This confirmed that the response was not only coming from Claude’s general knowledge. Claude was using the Terraform MCP Server tools to retrieve Terraform Registry information.</p><h4>Conclusion</h4><p>Terraform MCP Server helps bring Terraform context directly into AI assistants like Claude Desktop.</p><p>It reduces context switching by allowing me to search providers, modules, versions, and Terraform Registry details without leaving the AI workflow.</p><p>It does not replace Terraform CLI or Terraform knowledge, but it makes AI-assisted Terraform work more useful and accurate.</p><p>For engineers, learners, and community demos, Terraform MCP Server is definitely worth exploring.</p><p>Happy Terraforming!!!</p><p>📌 Let’s stay connected on LinkedIn: <a href="https://www.linkedin.com/in/mahendran-selvakumar-36444a77/">https://www.linkedin.com/in/mahendran-selvakumar/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c2736a01660" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/exploring-terraform-mcp-server-bringing-terraform-context-into-ai-assistants-6c2736a01660">Exploring Terraform MCP Server: Bringing Terraform Context into AI Assistants</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Argo CD: Install and Deploy Your First GitOps Application on Kubernetes]]></title>
            <link>https://devopstronaut.com/getting-started-with-argo-cd-install-and-deploy-your-first-gitops-application-on-kubernetes-241f0b203522?source=rss-b05127d2ebbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/241f0b203522</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[argo-cd]]></category>
            <dc:creator><![CDATA[Mahendran Selvakumar]]></dc:creator>
            <pubDate>Mon, 29 Jun 2026 03:01:02 GMT</pubDate>
            <atom:updated>2026-06-29T03:01:02.157Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ACAL-QfrtkO3_MHa8snw1A.png" /></figure><p>GitOps has become one of the most practical ways to manage Kubernetes deployments. Instead of manually applying Kubernetes manifests every time, GitOps allows us to use Git as the source of truth for application deployment.</p><p>In this blog, I will install Argo CD on a Kubernetes cluster, access the Argo CD UI, install the Argo CD CLI, and deploy a sample guestbook application from GitHub.</p><h4>What is Argo CD?</h4><p>Argo CD is a declarative GitOps continuous delivery tool for Kubernetes. It continuously monitors applications running in the cluster and compares the live state with the desired state defined in Git.</p><p>When there is a difference between Git and the cluster, Argo CD shows the application as out of sync. We can then sync the application manually or automatically based on our configuration.</p><h4>Step 1: Create a Kind Cluster</h4><p>Create a local Kubernetes cluster using Kind</p><pre>kind create cluster --name argocd</pre><p>This command creates a Kubernetes cluster named argocd and automatically sets the kubectl context to kind-argocd</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*9nYjs-GY17ab1KAtMZyWNw.png" /></figure><p>Check the cluster information to confirm that the Kubernetes control plane is running.</p><pre>kubectl cluster-info --context kind-argocd</pre><p>This confirms that the Kind cluster is active and ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*V6LOZVeXJULyzEzoFd9Lsw.png" /></figure><p>Verify that the Kubernetes node is ready.</p><pre>kubectl get nodes</pre><p>The node should be in Ready status before continuing with the Argo CD installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Rty-J36u_aKIH9vdGA1-cw.png" /></figure><h4>Step 2: Create the Argo CD Namespace</h4><p>Create a dedicated namespace for Argo CD.</p><pre>kubectl create namespace argocd</pre><p>All Argo CD components will be installed inside this namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H8RvcUWGRYiSS1X0B5A9eA.png" /></figure><h4>Step 3: Install Argo CD</h4><p>Install Argo CD using the official installation manifest.</p><pre><br>kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fRJfhjsW32h_nRcy-3Em-g.png" /></figure><p>This command creates the required Argo CD resources such as deployments, services, config maps, secrets, service accounts, roles, and role bindings.</p><h4>Step 4: Verify Argo CD Pods</h4><p>Check whether the Argo CD pods are running and Wait until all pods are in the Running state.</p><pre>kubectl get pods -n argocd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9-CqLn2vzWmA1cVwOvfMw.png" /></figure><h4>Step 5: Access the Argo CD UI</h4><p>The Argo CD server is not exposed outside the cluster by default.Use port forwarding to access the Argo CD UI locally.</p><pre>kubectl port-forward svc/argocd-server -n argocd 8080:443</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N_nO9DMrkUABYj0pWWywlg.png" /></figure><p>This forwards local port 8080 to the Argo CD server service running on port 443.</p><p>Open the following URL in your browser.A browser certificate warning may appear because Argo CD uses a self-signed certificate for local access. Continue to the page for this local demo.</p><pre>https://localhost:8080/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8z-mfUs6tocHnFHId0B-w.png" /></figure><h4>Step 6: Get the Initial Admin Password</h4><p>The default Argo CD username is admin.To get the initial password, retrieve it from the Kubernetes secret.</p><pre>kubectl -n argocd get secret argocd-initial-admin-secret \<br>  -o jsonpath=&quot;{.data.password}&quot; | base64 -d &amp;&amp; echo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0-wiitSOexAvZqxHV9RwA.png" /></figure><p>Use the username admin and the generated password to log in to the Argo CD UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IAz94grgQYp4obySVmP7fw.png" /></figure><p>After logging in, open the user settings page and update the default admin password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RS_pjFtueO1b_rO9xXaA_w.png" /></figure><p>Changing the initial password is recommended because it is automatically generated during installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tGMlECCzrnyjVKT0EZ4lGg.png" /></figure><h4>Step 6: Install Argo CD CLI</h4><p>Install the Argo CD CLI using Homebrew.The CLI helps manage Argo CD applications directly from the terminal.</p><pre>brew install argocd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p5PF_5HwsjdgeKoKAqmoGw.png" /></figure><p>Run the following command to confirm that the Argo CD CLI is installed.This displays the available Argo CD commands and confirms that the CLI is ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yp-XHTLr4T5tfhq9ROfJqA.png" /></figure><p>Make sure the Argo CD port forwarding command is still running.</p><pre>kubectl port-forward svc/argocd-server -n argocd 8080:443</pre><p>Open another terminal and log in using the CLI.If there is a certificate warning, continue for this local demo or use the insecure flag.Replace &lt;ARGOCD_ADMIN_PASSWORD&gt; with the Argo CD admin password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QIhF0qUuSxZKy9pctqWrRg.png" /></figure><p>Check the current list of Argo CD applications using this command “argocd app list”.At this stage, there may not be any applications deployed yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pn4V1mV0eBoHPd5tlbHdUg.png" /></figure><h4>Step 7: Create the Guestbook Application</h4><p>Create a sample Guestbook application using the official Argo CD example repository.This command creates an Argo CD application named guestbook.</p><p>The application source is stored in Git, and the Kubernetes manifests are available inside the guestbook directory.</p><p>Sync the application to deploy the Kubernetes resources into the cluster.During sync, Argo CD applies the manifests from the Git repository to the Kubernetes cluster.</p><pre>argocd app create guestbook \<br>  --repo https://github.com/argoproj/argocd-example-apps.git \<br>  --path guestbook \<br>  --dest-server https://kubernetes.default.svc \<br>  --dest-namespace default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4E9uRmyDnXH5AK2o9KZZPg.png" /></figure><pre>argocd app sync guestbook</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*obzsZPjEa8fsisNlYc89BA.png" /></figure><p>List the Argo CD applications again.The guestbook application should show as Synced,Healthy.This confirms that the application has been successfully deployed.</p><pre>argocd app list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Jr2JG1Y4y8MVoArfBhdXA.png" /></figure><p>Go back to the Argo CD UI.The guestbook application should now be visible on the Applications page.</p><p>Open the application to view details such as sync status, health status, repository, target revision, and deployed resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtWCIvTBwn2hocQJgIUGOg.png" /></figure><p>Open the guestbook application to view the resource tree.Argo CD displays the Kubernetes resources created for the application, such as Service,Deployment,ReplicaSet,Pod</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CAwaZfD3tFJBygLLEHXndA.png" /></figure><p>This view helps understand how Argo CD manages Kubernetes resources from Git.</p><h4>Step 8: Verify Resources in Kubernetes</h4><p>Check the resources created in the default namespace.The output should show the Guestbook pod, service, deployment, and replica set.</p><pre>kubectl get all -n default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMUSeRJ0tx4_lSCoYFnAAQ.png" /></figure><h4>Step 9: Access the Guestbook Application</h4><p>Use port forwarding to access the Guestbook application locally.This forwards local port 8090 to the Guestbook service running on port 80.</p><pre>kubectl port-forward -n default svc/guestbook-ui 8090:80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5fg1qDsj7MQMCxxnYi-xw.png" /></figure><p>Open the following URL in your browser.The Guestbook application should now be accessible locally.</p><p><a href="http://localhost:8090/">http://localhost:8090/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnRRj9v2G2l5eLmWEa80hQ.png" /></figure><h4>Conclusion</h4><p>In this blog, I created a local Kubernetes cluster using Kind, installed Argo CD, accessed the Argo CD UI, configured the Argo CD CLI, and deployed a sample Guestbook application using GitOps.</p><p>This hands-on setup helped me understand how Argo CD works with Kubernetes and Git. Instead of manually applying manifests every time, I can use Argo CD to manage deployments from a Git repository and keep the cluster state aligned with the desired configuration.</p><p>The Guestbook application is a simple example, but the same approach can be extended to real-world applications across development, staging, and production environments.</p><p>Argo CD makes Kubernetes deployments more consistent, visible, and easier to manage through the GitOps model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=241f0b203522" width="1" height="1" alt=""><hr><p><a href="https://devopstronaut.com/getting-started-with-argo-cd-install-and-deploy-your-first-gitops-application-on-kubernetes-241f0b203522">Getting Started with Argo CD: Install and Deploy Your First GitOps Application on Kubernetes</a> was originally published in <a href="https://devopstronaut.com/">Devopstronaut</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>