---
title: "Connect Pulumi to ChatGPT: Manage Stacks and Deploy Infrastructure"
slug: connect-pulumi-to-chatgpt-manage-stacks-and-deploy-infrastructure
date: 2026-10-16
author: Nachi Raman
categories: ["AI & Agents"]
excerpt: "Learn how to build a secure MCP server to connect ChatGPT to Pulumi Cloud. Automate stack deployments, drift detection, and ESC environments."
tldr: "A complete engineering guide to connecting ChatGPT to Pulumi Cloud via MCP. Automate stack previews, drift detection, and ESC secrets using Truto's dynamically generated MCP servers."
canonical: https://truto.one/blog/connect-pulumi-to-chatgpt-manage-stacks-and-deploy-infrastructure/
---

# Connect Pulumi to ChatGPT: Manage Stacks and Deploy Infrastructure


If you need to connect Pulumi to ChatGPT to automate stack deployments, evaluate infrastructure drift, or manage ESC (Environments, Secrets, and Configuration) workflows via natural language, you need a [Model Context Protocol (MCP) server](https://truto.one/what-is-mcp-model-context-protocol-the-2026-guide-for-saas-pms/). This infrastructure layer translates your LLM's JSON-RPC tool calls into Pulumi Cloud's complex REST API requests. 

If your team uses Claude, check out our guide on [connecting Pulumi to Claude](https://truto.one/connect-pulumi-to-claude-monitor-compliance-and-esc-environments/) or explore our broader architectural overview on [connecting Pulumi to AI Agents](https://truto.one/connect-pulumi-to-ai-agents-automate-secret-ops-and-cloud-resources/).

Giving a Large Language Model (LLM) read and write access to your infrastructure state is a high-stakes engineering challenge. You must handle asynchronous deployment lifecycles, complex graph URNs, and nested schema objects. If you hardcode a custom MCP server, you own the entire integration lifecycle—meaning every time Pulumi updates their deployment settings schema or Insights API, your server code must be updated and redeployed.

This guide breaks down exactly how to use Truto to [generate a secure, managed MCP server](https://truto.one/auto-generated-mcp-tools-for-ai-agents-a-2026-architecture-guide/) for Pulumi, connect it natively to ChatGPT, and execute complex infrastructure operations using natural language.

> Stop writing boilerplate API integration code. Let Truto generate secure, managed MCP servers for your AI agents in seconds.
>
> [Talk to us](https://truto.one/book-a-demo/)

## The Engineering Reality of the Pulumi API

Building a custom MCP server means you own the translation layer between the LLM and the upstream SaaS. While the [open MCP standard](https://truto.one/what-is-mcp-model-context-protocol-the-2026-guide-for-saas-pms/) provides a predictable way for models to discover tools, implementing it against Pulumi's highly sophisticated cloud API is exceptionally painful. 

If you decide to build a custom MCP server for Pulumi, you own the entire API lifecycle. Here are the specific integration challenges that break standard CRUD assumptions when working with Pulumi:

### Asynchronous Stack Operations and Multi-Step Lifecycles
Unlike simple CRUD APIs where a `POST` immediately provisions a resource, Pulumi stack updates involve a multi-step asynchronous dance. To execute an update, your MCP server cannot simply call `create_a_pulumi_stack`. An agent must create the stack, create a deployment update record (`create_a_pulumi_update`), explicitly start the update (`pulumi_updates_start`), poll for engine events (`list_all_pulumi_update_events`), and finally mark the update as complete. If you hand-code this, you must write extensive state-tracking logic to prevent the LLM from hallucinating completion statuses or losing track of the deployment lease token.

### ESC Interpolation and Secret Decryption
Pulumi ESC (Environments, Secrets, and Configuration) is incredibly powerful, but interacting with it via API requires handling dynamic YAML evaluations and nested provider references (`fn::open`). When an LLM wants to read a secret from an environment, the raw environment definition returns encrypted ciphertexts. Your server must route the LLM to the `create_a_pulumi_decrypt_secret` endpoint, passing the exact paths to decrypt. Without dynamically generated schemas that explicitly type these payloads, the LLM will fail to construct the correct rotation or decryption objects.

### Double URL Encoding in the Insights Graph
Pulumi's Insights and resource discovery endpoints use fully qualified URNs (Uniform Resource Names) as identifiers. When querying resource edges or stack references, the Pulumi API strictly requires `resource_type_and_id` to be double-URL-encoded (e.g., `type::id`). When an LLM generates a tool call, it passes raw strings. If your custom server does not perfectly map and encode these arguments before sending them to the upstream Pulumi REST API, the requests will fail with opaque 404 or 400 errors.

### Managing API Rate Limits Programmatically
Pulumi enforces rate limits on its Cloud API. It is critical to note that Truto does not retry, throttle, or apply backoff on rate limit errors. When Pulumi returns an HTTP 429, Truto passes that error directly to the caller. Truto normalizes the upstream rate limit information into standardized headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`) per the IETF spec. Your LLM framework or agent orchestration layer is strictly responsible for interpreting these headers and executing retry/backoff logic. You cannot rely on the proxy to absorb these limits.

## Step 1: Create the Pulumi MCP Server

Before connecting to ChatGPT, you need to generate an MCP server scoped specifically to your authenticated Pulumi account. Truto reads Pulumi's API documentation, [derives the JSON schemas for the endpoints](https://truto.one/how-do-mcp-servers-auto-generate-tools-from-api-documentation/), and exposes them dynamically as MCP tools. 

You can create this server in two ways: via the Truto dashboard or programmatically via the API.

### Method A: Via the Truto UI

1. Log into your Truto account and navigate to **Integrated Accounts**.
2. Select your connected Pulumi account.
3. Click the **MCP Servers** tab.
4. Click **Create MCP Server**.
5. Select your desired configuration. For example, check `read` to prevent the LLM from making destructive changes, and tag filters like `stacks` or `insights` to scope the tools.
6. Copy the generated MCP server URL (e.g., `https://api.truto.one/mcp/a1b2c3d4e5f6...`). Treat this URL as a sensitive credential.

### Method B: Via the API

If you are dynamically provisioning AI agents for your engineering team, you can generate the MCP server programmatically using your Truto API token.

```bash
curl -X POST https://api.truto.one/integrated-account/$INTEGRATED_ACCOUNT_ID/mcp \
  -H "Authorization: Bearer $TRUTO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Pulumi Infra Agent",
    "config": {
      "methods": ["read", "write"],
      "tags": ["stacks", "deployments", "esc"]
    }
  }'
```

The response returns a JSON payload containing the secure routing token URL:

```json
{
  "id": "abc-123",
  "name": "Pulumi Infra Agent",
  "config": { "methods": ["read", "write"] },
  "expires_at": null,
  "url": "https://api.truto.one/mcp/a1b2c3d4e5f6..."
}
```

## Step 2: Connect the MCP Server to ChatGPT

With your secure MCP URL in hand, you can now expose these infrastructure tools to ChatGPT. You can connect it via the ChatGPT desktop/web UI, or locally using a configuration file if you are running a custom agent.

### Method A: Via the ChatGPT UI

For enterprise users leveraging ChatGPT directly:
1. Open ChatGPT and navigate to **Settings -> Apps -> Advanced settings**.
2. Enable **Developer mode** (requires Pro, Plus, Business, Enterprise, or Education tier).
3. Under **MCP servers / Custom connectors**, click **Add a new server**.
4. **Name**: Enter "Pulumi Cloud (Truto)".
5. **Server URL**: Paste the URL generated in Step 1.
6. Click **Save**. ChatGPT will immediately perform the MCP initialization handshake and populate its tool context with the allowed Pulumi operations.

*(Note: If you are using Claude Desktop instead of ChatGPT, the flow is similar: Settings -> Connectors -> Add custom connector.)*

### Method B: Via Manual Config File

If you are running an AI agent framework locally or in CI/CD, you can connect to the Truto MCP server using standard SSE (Server-Sent Events) transports. You can use the official `@modelcontextprotocol/server-sse` CLI wrapper to route standard I/O to the remote URL.

Create an `mcp_config.json` (or add to your framework's connector list):

```json
{
  "mcpServers": {
    "pulumi-truto": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-sse",
        "https://api.truto.one/mcp/a1b2c3d4e5f6..."
      ]
    }
  }
}
```

When your agent boots, it will execute the `npx` command, establish an SSE connection to Truto, and automatically discover the Pulumi tool schemas.

## Hero Tools for Pulumi

Truto automatically generates tools for the entire Pulumi API surface. Instead of exposing generic CRUD operations, you should scope your agent to high-leverage infrastructure workflows. Here are the core tools you should ensure are available to your LLM.

### 1. View Stack Update Summaries (`get_single_pulumi_update_summary_by_id`)
Retrieves a human-readable summary of a specific Pulumi Cloud update. This is crucial for giving the LLM context on exactly what resources were modified, created, or deleted during a deployment run, formatted like the CLI's `pulumi up` output.

> "Fetch the update summary for the latest deployment on the 'production' stack in the 'networking' project. Summarize any resources that were replaced."

### 2. Monitor Infrastructure Drift (`list_all_pulumi_drift_status`)
Gets the current drift detection status for a stack. AI agents can use this tool to determine if manual out-of-band changes have been made to cloud resources that conflict with the Pulumi state.

> "Check the drift status for the 'data-warehouse' stack. If drift is detected, list the specific differences that were found."

### 3. Open Draft Change Requests (`create_a_pulumi_draft_open`)
Opens a draft of a Pulumi ESC environment for a change request. This resolves all dynamic values, provider integrations, and secrets. It is essential when an agent needs to validate a proposed configuration change against live provider constraints before requesting human approval.

> "Open the draft change request for the 'staging-esc' environment. Validate that all dynamic provider integrations resolve correctly and report any errors."

### 4. Query the Resource Graph (`create_a_pulumi_graph_query`)
Executes a graph selection query over the organization's resource graph using Pulumi Insights. Agents can use this to map relationships between cloud components, such as finding all EC2 instances connected to a specific Security Group.

> "Run a graph query to find all resources managed by the 'eks-cluster' stack. Return the nodes and edge relationships so I can see what depends on the primary VPC."

### 5. Inspect Policy Violations (`list_all_pulumi_policyresults_issues`)
Lists policy issues and violations detected by CrossGuard Policy Packs during continuous compliance scans. This tool enables agents to triage security alerts and infrastructure misconfigurations.

> "List all active policy issues for the 'aws-networking' stack. Filter for issues with 'mandatory' enforcement levels and tell me which policies are failing."

### 6. Encrypt ESC Secrets (`create_a_pulumi_encrypt_secret`)
Encrypts plaintext secret values in a Pulumi ESC environment definition using the environment's encryption key. Agents use this when generating new environments to ensure sensitive data is properly encrypted before the YAML is committed.

> "Take this API token and encrypt it for the 'prod-database' ESC environment. Return the ciphertext so I can inject it into the environment definition."

For the complete list of available tools, required parameters, and JSON schemas, view the [Pulumi integration page](https://truto.one/integrations/detail/pulumi).

## Workflows in Action

When you combine ChatGPT's reasoning with Truto's standardized Pulumi MCP tools, you can automate sophisticated infrastructure operations. Here are two real-world workflows.

### Workflow 1: Automated Drift Triage and Remediation
When a developer makes an out-of-band change in the AWS console, the infrastructure state drifts from the Pulumi code. An AI agent can automatically investigate the drift, summarize the impact, and prepare a remediation plan.

> "Check the drift status on the 'production-db' stack. If it has drifted, fetch the latest update summary to compare, and draft a summary of what changed outside of Pulumi."

1. **`list_all_pulumi_drift_status`**: The agent queries the stack to retrieve the `StackDriftStatus` object, identifying that an RDS instance's security group was manually altered.
2. **`list_all_pulumi_updates_latests`**: The agent fetches the most recent legitimate update applied via Pulumi to understand the baseline configuration.
3. **`get_single_pulumi_update_summary_by_id`**: The agent pulls the detailed tree view of the last update to confirm what the security group *should* look like, and outputs a remediation report for the DevOps team.

```mermaid
flowchart TD
    Agent["AI Agent"]
    Drift["Check Drift Status<br>(list_all_pulumi_drift_status)"]
    Latest["Get Latest Update<br>(list_all_pulumi_updates_latests)"]
    Summary["Get Update Summary<br>(get_single_pulumi_update_summary_by_id)"]
    Report["Generate Report"]

    Agent --> Drift
    Drift -->|Drift Detected| Latest
    Latest --> Summary
    Summary --> Report
```

### Workflow 2: CrossGuard Policy Violation Auditing
Compliance teams need to constantly monitor infrastructure for policy violations (e.g., unencrypted S3 buckets). An AI agent can retrieve policy issues, map the violating resources in the graph, and update triage statuses.

> "Find all open policy violations with 'mandatory' enforcement in the 'data-lake' stack. For each issue, query the resource graph to see what it connects to, and update the issue status to 'in_progress'."

1. **`list_all_pulumi_policyresults_issues`**: The agent fetches the violating resources, noting an S3 bucket lacking KMS encryption.
2. **`create_a_pulumi_graph_query`**: The agent uses the URN from the violation to query the Insights graph, discovering that the bucket is actively referenced by an ECS task.
3. **`update_a_pulumi_policyresults_issue_by_id`**: The agent updates the issue's triage status to `in_progress` and alerts the team with the blast radius of the affected ECS task.

## Security and Access Control

Giving an LLM access to your Pulumi Cloud environment requires strict security boundaries. Truto provides several mechanisms to constrain what the MCP server can do:

*   **Method Filtering**: You can limit the MCP server to specific HTTP methods. Passing `methods: ["read"]` ensures the agent can only execute `GET` and `LIST` operations, preventing it from applying stack updates or deleting environments.
*   **Tag Filtering**: By applying tags during server creation (e.g., `tags: ["esc", "insights"]`), you scope the available tools to specific functional areas, hiding core stack deployment endpoints from the agent entirely.
*   **API Token Authentication**: By enabling `require_api_token_auth: true`, possession of the MCP URL is no longer sufficient. The client must also pass a valid Truto API token in the `Authorization` header, adding a mandatory secondary authentication layer.
*   **Automatic Expiration**: Set an `expires_at` ISO datetime when generating the server. Once the timestamp is reached, Truto automatically purges the token from the edge network and database, instantly revoking the LLM's access to Pulumi.

## Moving from Chat to Production Infrastructure

Connecting Pulumi to ChatGPT via MCP transforms how you interact with infrastructure state. Instead of digging through the Pulumi Cloud UI to find drifted stacks, decode ESC environment variables, or trace policy violations, you can simply ask your agent to investigate and orchestrate the data for you.

However, the real power unlocks when you move beyond chat interfaces and integrate these tools into autonomous CI/CD agents. By relying on Truto's [dynamically generated MCP servers](https://truto.one/auto-generated-mcp-tools-for-ai-agents-a-2026-architecture-guide/), your engineering team escapes the burden of maintaining custom schemas, handling pagination quirks, and updating routing logic every time Pulumi ships a new feature. Truto handles the proxy layer, so you can focus on building intelligent deployment pipelines.

> Stop writing boilerplate API integration code. Let Truto generate secure, managed MCP servers for your AI agents in seconds.
>
> [Talk to us](https://truto.one/book-a-demo/)
