putEnvironment
Replace an entire Postman environment's variables with new values in a single request.
Instructions
Replaces all environment contents. Max size 30MB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environmentId | Yes | Environment ID | |
| environment | No | Environment object with name and values |
Implementation Reference
- tools/postman_tools.py:711-742 (handler)The PutEnvironmentTool class (handler) for the 'putEnvironment' tool. The run_tool method extracts environmentId and environment from args, then calls the Postman API with a PUT request to /environments/{env_id} to replace all environment contents.
class PutEnvironmentTool(ToolHandler): """Replace environment contents""" def __init__(self): super().__init__("putEnvironment") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Replaces all environment contents. Max size 30MB.", inputSchema={ "type": "object", "properties": { "environmentId": { "type": "string", "description": "Environment ID" }, "environment": { "type": "object", "description": "Environment object with name and values" } }, "required": ["environmentId"] }, ) async def run_tool(self, args: dict) -> list[TextContent]: env_id = args["environmentId"] body = {"environment": args.get("environment", {})} result = await postman_api_call("PUT", f"/environments/{env_id}", body=body) return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:717-735 (schema)Input schema definition for putEnvironment tool. Requires environmentId (string), accepts optional environment object with name and values.
def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Replaces all environment contents. Max size 30MB.", inputSchema={ "type": "object", "properties": { "environmentId": { "type": "string", "description": "Environment ID" }, "environment": { "type": "object", "description": "Environment object with name and values" } }, "required": ["environmentId"] }, ) - tools/postman_tools.py:1855-1855 (registration)Registration of PutEnvironmentTool() in the register_all_tools() function, which returns all tool handlers as a list.
PutEnvironmentTool(), - tests/test_postman.py:67-67 (registration)Test file listing 'putEnvironment' among the expected tool names that must be registered.
"putEnvironment", - tools/toolhandler.py:9-24 (helper)The ToolHandler abstract base class that PutEnvironmentTool (and all tools) extend. Provides the interface for get_tool_description() and run_tool().
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