Skip to main content
Glama

getEnvironments

Read-onlyIdempotent

Retrieve details for all environments in a Postman workspace, including variables and values. Specify a workspace ID to filter results.

Instructions

Gets information about all of your environments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceNoThe workspace's ID.

Implementation Reference

  • The main implementation file for the getEnvironments tool. Exports the method name ('getEnvironments'), description, Zod schema (with optional 'workspace' param), annotations, and the async handler function that calls GET /environments via the PostmanAPIClient.
    import { z } from 'zod';
    import { PostmanAPIClient } from '../clients/postman.js';
    import { IsomorphicHeaders, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
    import { ServerContext, asMcpError, McpError } from './utils/toolHelpers.js';
    
    export const method = 'getEnvironments';
    export const description =
      'Gets information about all of your [environments](https://learning.postman.com/docs/sending-requests/managing-environments/).';
    export const parameters = z.object({
      workspace: z.string().describe("The workspace's ID.").optional(),
    });
    export const annotations = {
      title:
        'Gets information about all of your [environments](https://learning.postman.com/docs/sending-requests/managing-environments/).',
      readOnlyHint: true,
      destructiveHint: false,
      idempotentHint: true,
    };
    
    export async function handler(
      args: z.infer<typeof parameters>,
      extra: { client: PostmanAPIClient; headers?: IsomorphicHeaders; serverContext?: ServerContext }
    ): Promise<CallToolResult> {
      try {
        const endpoint = `/environments`;
        const query = new URLSearchParams();
        if (args.workspace !== undefined) query.set('workspace', String(args.workspace));
        const url = query.toString() ? `${endpoint}?${query.toString()}` : endpoint;
        const options: any = {
          headers: extra.headers,
        };
        const result = await extra.client.get(url, options);
        return {
          content: [
            {
              type: 'text',
              text: `${typeof result === 'string' ? result : JSON.stringify(result, null, 2)}`,
            },
          ],
        };
      } catch (e: unknown) {
        if (e instanceof McpError) {
          throw e;
        }
        throw asMcpError(e);
      }
    }
  • Zod schema for the getEnvironments tool: accepts an optional 'workspace' string parameter describing the workspace ID.
    export const parameters = z.object({
      workspace: z.string().describe("The workspace's ID.").optional(),
    });
  • Registration of 'getEnvironments' in the 'full' resource list (line 75).
    'getEnvironments',
  • Registration of 'getEnvironments' in the 'minimal' resource list (line 177).
    'getEnvironments',
  • Registration of 'getEnvironments' in the 'code' resource list (line 218).
    'getEnvironments',
Behavior2/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. The description adds no further behavioral context (e.g., pagination, ordering, or authentication details).

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?

Single sentence with no extraneous information. The action is front-loaded and efficient.

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

Completeness4/5

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

For a simple list operation with good annotations, the description is adequate. It could elaborate on response format or the effect of the workspace parameter, but it covers the essential purpose.

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?

Schema coverage is 100% with a clear description for the workspace parameter. The description adds no additional meaning beyond the schema, but the baseline is 3 due to high coverage.

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

Purpose5/5

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

The description clearly states the tool retrieves information about all environments. The verb 'Gets information' and resource 'environments' are specific. It distinguishes from sibling 'getEnvironment' (singular) by implying a list operation.

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

Usage Guidelines3/5

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

Usage context is implied: use this to list all environments, while getEnvironment targets a single one. However, no explicit when-not or alternative guidance is provided beyond sibling names.

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

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/postmanlabs/postman-mcp-server'

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