Skip to main content
Glama

createEnvironment

Create a new Postman environment with name and values, optionally specifying a workspace. If no workspace is provided, the environment is created in your oldest personal workspace.

Instructions

Creates an environment. Max size 30MB. If workspace not specified, creates in oldest personal workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workspaceNoWorkspace ID
environmentNoEnvironment object with name and values

Implementation Reference

  • The CreateEnvironmentTool class implements the 'createEnvironment' tool. It registers with name 'createEnvironment', defines input schema with optional 'workspace' and 'environment' fields, and makes a POST call to /environments endpoint to create a new Postman environment.
    class CreateEnvironmentTool(ToolHandler):
        """Create an environment"""
        
        def __init__(self):
            super().__init__("createEnvironment")
        
        def get_tool_description(self) -> Tool:
            return Tool(
                name=self.name,
                description="Creates an environment. Max size 30MB. If workspace not specified, creates in oldest personal workspace.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "workspace": {
                            "type": "string",
                            "description": "Workspace ID"
                        },
                        "environment": {
                            "type": "object",
                            "description": "Environment object with name and values"
                        }
                    },
                },
            )
        
        async def run_tool(self, args: dict) -> list[TextContent]:
            params = {}
            if args.get("workspace"):
                params["workspace"] = args["workspace"]
            
            body = {"environment": args.get("environment", {})}
            result = await postman_api_call("POST", "/environments", body=body, params=params)
            return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Registration of CreateEnvironmentTool() in the register_all_tools() function that returns all tool handlers.
    CreateEnvironmentTool(),
    GetEnvironmentTool(),
    GetEnvironmentsTool(),
    PutEnvironmentTool(),
  • Input schema for createEnvironment: accepts optional 'workspace' (string) and 'environment' (object with name and values).
    def get_tool_description(self) -> Tool:
        return Tool(
            name=self.name,
            description="Creates an environment. Max size 30MB. If workspace not specified, creates in oldest personal workspace.",
            inputSchema={
                "type": "object",
                "properties": {
                    "workspace": {
                        "type": "string",
                        "description": "Workspace ID"
                    },
                    "environment": {
                        "type": "object",
                        "description": "Environment object with name and values"
                    }
                },
            },
        )
  • Abstract base class ToolHandler that CreateEnvironmentTool inherits from. Defines the interface with get_tool_description() and run_tool() methods.
    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
  • The postman_api_call helper function used by CreateEnvironmentTool.run_tool() to make the actual HTTP POST request to the Postman API.
    async def postman_api_call(
        method: str,
        endpoint: str,
        body: dict | None = None,
        params: dict | None = None,
        headers: dict | None = None
    ) -> dict:
        """Make an API call to Postman API"""
        if not POSTMAN_API_KEY:
            raise RuntimeError("POSTMAN_API_KEY environment variable is not set")
        
        url = f"{POSTMAN_BASE_URL}{endpoint}"
        
        # Prepare headers
        request_headers = {
            "X-Api-Key": POSTMAN_API_KEY,
            "Content-Type": "application/json",
        }
        if headers:
            request_headers.update(headers)
        
        async with httpx.AsyncClient(timeout=30.0) as client:
            try:
                response = await client.request(
                    method=method,
                    url=url,
                    json=body,
                    params=params,
                    headers=request_headers
                )
                response.raise_for_status()
                
                if response.status_code == 204:
                    return {"success": True, "message": "Operation completed successfully"}
                
                return response.json() if response.content else {"success": True}
            
            except httpx.HTTPStatusError as e:
                error_detail = e.response.text
                try:
                    error_json = e.response.json()
                    error_detail = json.dumps(error_json, indent=2)
                except:
                    pass
                raise RuntimeError(f"Postman API error ({e.response.status_code}): {error_detail}")
            except Exception as e:
                raise RuntimeError(f"Request failed: {str(e)}")
Behavior3/5

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

Discloses size limit (30MB) and default workspace behavior, which adds value beyond the input schema. However, with no annotations, it's missing information on mutation effects, permissions, or reversibility. Adequate but not comprehensive.

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?

Two sentences, no fluff. The most important info (creation, size, default) is front-loaded. Every sentence adds value.

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

Completeness3/5

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

For a creation tool with no output schema, the description covers key constraints but omits what the tool returns (e.g., created environment ID or object). The complexity is moderate, so a bit more detail would improve completeness.

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

Parameters4/5

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

Schema coverage is 100%, but the description adds useful extra context: 'Max size 30MB' constrains the environment object, and the workspace default clarifies behavior. This helps the agent understand parameter implications beyond the schema.

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?

Clearly states 'Creates an environment' with specific details (max size 30MB, workspace default). Distinguishes from sibling tools like createCollection or createWorkspace by focusing on environment creation, though no explicit differentiation.

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?

No guidance on when to use this tool vs alternatives (e.g., putEnvironment for updates, or when to specify workspace). The description hints at default behavior but doesn't provide context for decision-making.

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

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