Skip to main content
Glama
pulumi

@pulumi/mcp-server

Official
by pulumi

pulumi-cli-preview

Executes Pulumi preview to analyze infrastructure changes in a specified project and stack, ensuring configurations are updated correctly before deployment.

Instructions

Run pulumi preview for a given project and stack

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stackNameNoThe associated stack name. Defaults to 'dev'.
workDirYesThe working directory of the program.

Implementation Reference

  • Executes Pulumi preview using the automation API, formats and returns the change summary and stdout.
        handler: async (args: PreviewArgs) => {
          const stackArgs: automation.LocalProgramArgs = {
            stackName: args.stackName ?? 'dev',
            workDir: args.workDir
          };
    
          const stack = await automation.LocalWorkspace.createOrSelectStack(stackArgs);
    
          // Run preview
          const previewResult = await stack.preview({ diff: true });
    
          // Format the changes
          const changes = previewResult.changeSummary;
          const changesSummary = [
            `Create: ${changes.create}`,
            `Update: ${changes.update}`,
            `Delete: ${changes.delete}`,
            `Same: ${changes.same}`
          ].join('\n');
    
          return {
            description: 'Pulumi Preview Results',
            content: [
              {
                type: 'text' as const,
                text: `
    Preview Results for stack: ${stack.name}
    
    Changes:
    ${changesSummary}
    
    ${previewResult.stdout || 'No additional output'}
    `
              }
            ]
          };
        }
  • Input schema using Zod for workDir (required) and stackName (optional, defaults to 'dev').
    schema: {
      workDir: z.string().describe('The working directory of the program.'),
      stackName: z.string().optional().describe("The associated stack name. Defaults to 'dev'.")
    },
  • Registers all Pulumi CLI commands, including 'preview' as 'pulumi-cli-preview', in the MCP server with error handling.
    Object.entries(cliCommands).forEach(([commandName, command]) => {
      const toolName = `pulumi-cli-${commandName}`;
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      this.tool(toolName, command.description, command.schema, async (args: any) => {
        try {
          return await command.handler(args);
        } catch (error) {
          return handleError(error, toolName);
        }
      });
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'preview' but doesn't clarify that this is a read-only, non-destructive operation that simulates changes without applying them, nor does it address potential side effects like network calls, authentication needs, or output format. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action ('Run pulumi preview') and avoids redundancy, making it highly concise and well-structured for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a CLI tool for infrastructure previews, the description is incomplete. With no annotations and no output schema, it fails to explain critical aspects like the non-destructive nature of previews, authentication requirements, error handling, or what the output entails (e.g., a summary of planned changes). This makes it inadequate for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting both parameters ('stackName' and 'workDir') with their types and defaults. The description adds no additional parameter semantics beyond implying the tool uses these for the preview, so it meets the baseline of 3 without compensating for any schema gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Run pulumi preview') and specifies the target ('for a given project and stack'), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'pulumi-cli-up' (which applies changes) or 'pulumi-cli-stack-output' (which retrieves outputs), leaving room for ambiguity in tool selection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as 'pulumi-cli-up' for applying changes or 'pulumi-cli-stack-output' for viewing outputs. It lacks context on prerequisites (e.g., needing a Pulumi project setup) or typical use cases (e.g., before applying infrastructure changes), offering only a basic functional statement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pulumi/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server