getEnvironments
Retrieve all Postman environments, with optional filtering by workspace ID.
Instructions
Gets all environments. Optionally filter by workspace.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace | No | Workspace ID (optional) |
Implementation Reference
- tools/postman_tools.py:681-708 (handler)The GetEnvironmentsTool class implements the 'getEnvironments' tool handler. It extends ToolHandler, registers with name 'getEnvironments' in __init__, defines the input schema (with optional workspace filter) in get_tool_description, and executes the logic in run_tool by making a GET request to /environments with optional workspace query parameter.
class GetEnvironmentsTool(ToolHandler): """Get all environments""" def __init__(self): super().__init__("getEnvironments") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Gets all environments. Optionally filter by workspace.", inputSchema={ "type": "object", "properties": { "workspace": { "type": "string", "description": "Workspace ID (optional)" } }, }, ) async def run_tool(self, args: dict) -> list[TextContent]: params = {} if args.get("workspace"): params["workspace"] = args["workspace"] result = await postman_api_call("GET", "/environments", params=params) return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:687-700 (schema)Input schema for getEnvironments: defines an optional 'workspace' property (type string, description 'Workspace ID (optional)'). No required fields.
def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Gets all environments. Optionally filter by workspace.", inputSchema={ "type": "object", "properties": { "workspace": { "type": "string", "description": "Workspace ID (optional)" } }, }, ) - tools/postman_tools.py:1816-1816 (registration)The GetEnvironmentsTool() is registered in register_all_tools() on line 1854 within the environments section, creating an instance that gets returned in the list of all tool handlers.
"environments": 4, - tools/toolhandler.py:1-23 (helper)ToolHandler is the abstract base class that GetEnvironmentsTool extends. It provides the __init__ (setting self.name), get_tool_description abstract method, and run_tool abstract method used by all tool implementations.
""" Abstract base class for Postman MCP tool handlers """ from abc import ABC, abstractmethod from typing import Any from mcp.types import Tool, TextContent, ImageContent, EmbeddedResource class ToolHandler(ABC): """Base class for all Postman tool handlers""" def __init__(self, name: str): self.name = name @abstractmethod def get_tool_description(self) -> Tool: """Return the MCP Tool description for this handler""" pass @abstractmethod async def run_tool(self, arguments: dict) -> list[TextContent | ImageContent | EmbeddedResource]: """Execute the tool with the given arguments""" pass