Skip to main content
Glama
pulumi

@pulumi/mcp-server

Official
by pulumi

pulumi-cli-stack-output

Retrieve specific output values from a Pulumi stack by specifying the working directory and optional stack or output name.

Instructions

Get the output value(s) of a given stack

Input Schema

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

Implementation Reference

  • The core implementation of the 'stack-output' command, including schema validation with Zod and the handler function that executes Pulumi automation to retrieve stack outputs. This is used as the basis for the 'pulumi-cli-stack-output' tool.
      'stack-output': {
        description: 'Get the output value(s) of a given stack',
        schema: {
          workDir: z.string().describe('The working directory of the program.'),
          stackName: z.string().optional().describe("The associated stack name. Defaults to 'dev'."),
          outputName: z.string().optional().describe('The specific stack output name to retrieve.')
        },
        handler: async (args: { workDir: string; stackName?: string; outputName?: string }) => {
          const stackArgs: automation.LocalProgramArgs = {
            stackName: args.stackName ?? 'dev',
            workDir: args.workDir
          };
    
          const stack = await automation.LocalWorkspace.selectStack(stackArgs);
    
          // Get stack outputs
          const outputs = await stack.outputs();
    
          let description: string;
          let outputContent: string;
    
          if (args.outputName) {
            // Return a specific output
            const specificOutput = outputs[args.outputName];
            if (specificOutput) {
              description = `Pulumi Stack Output: ${args.outputName}`;
              outputContent = `${args.outputName}: ${JSON.stringify(specificOutput.value)}`;
            } else {
              description = `Pulumi Stack Output: ${args.outputName}`;
              outputContent = `Output '${args.outputName}' not found.`;
            }
          } else {
            // Return all outputs
            description = 'Pulumi Stack Outputs';
            outputContent = Object.entries(outputs)
              .map(([key, value]) => `${key}: ${JSON.stringify(value.value)}`)
              .join('\\n');
            if (!outputContent) {
              outputContent = 'No outputs found';
            }
          }
    
          return {
            description: description,
            content: [
              {
                type: 'text' as const,
                text: `
    Stack: ${stack.name}
    
    ${outputContent}
    `
              }
            ]
          };
        }
      },
  • Registration of all CLI commands as MCP tools, dynamically naming them 'pulumi-cli-{commandName}', including 'pulumi-cli-stack-output', by wrapping the handler from cliCommands 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);
        }
      });
    });
  • Zod schema defining the input parameters for the pulumi-cli-stack-output tool: workDir (required), stackName (optional, defaults to 'dev'), outputName (optional).
    schema: {
      workDir: z.string().describe('The working directory of the program.'),
      stackName: z.string().optional().describe("The associated stack name. Defaults to 'dev'."),
      outputName: z.string().optional().describe('The specific stack output name to retrieve.')
    },
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 states the tool retrieves output values but fails to mention critical behaviors like whether it requires authentication, how it handles errors, if it returns structured data, or any rate limits. For a read operation with zero annotation coverage, this is a significant gap, warranting a score of 2.

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 any unnecessary words. It is appropriately sized and front-loaded, making it easy to understand quickly. This earns a score of 5 for conciseness.

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 tool's complexity (3 parameters, no output schema, and no annotations), the description is incomplete. It does not explain what the return values look like, how outputs are formatted, or any dependencies like stack state. For a tool that retrieves data, this lack of output information and behavioral context results in a score of 2.

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 schema description coverage is 100%, meaning all parameters are documented in the input schema. The description adds no additional meaning beyond what the schema provides, such as explaining the relationship between parameters or usage examples. According to the rules, with high schema coverage, the baseline is 3, so this scores a 3.

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 tool's purpose as 'Get the output value(s) of a given stack,' which specifies the verb ('Get') and resource ('output value(s) of a given stack'). It distinguishes from siblings like 'pulumi-cli-preview' or 'pulumi-cli-up' by focusing on retrieval rather than deployment actions. However, it doesn't explicitly differentiate from other read operations like 'pulumi-registry-get-resource,' keeping it at a 4.

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. It lacks context about prerequisites, such as needing an initialized stack, or comparisons to other tools like 'pulumi-registry-get-resource' for different resource types. This absence of usage instructions results in a score of 2.

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