updateWorkspace
Update workspace name or visibility, with restrictions: some visibility changes are not allowed, and public names must be unique.
Instructions
Updates a workspace property (name, visibility, etc.). Some visibility changes not allowed. Public names must be unique.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspaceId | Yes | Workspace ID | |
| workspace | No | Workspace updates |
Implementation Reference
- tools/postman_tools.py:1631-1662 (handler)The UpdateWorkspaceTool class is the handler for the 'updateWorkspace' tool. It extends ToolHandler, defines the tool schema (requiring workspaceId and optional workspace object), and executes a PUT request to /workspaces/{workspace_id} on the Postman API.
class UpdateWorkspaceTool(ToolHandler): """Update workspace""" def __init__(self): super().__init__("updateWorkspace") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Updates a workspace property (name, visibility, etc.). Some visibility changes not allowed. Public names must be unique.", inputSchema={ "type": "object", "properties": { "workspaceId": { "type": "string", "description": "Workspace ID" }, "workspace": { "type": "object", "description": "Workspace updates" } }, "required": ["workspaceId"] }, ) async def run_tool(self, args: dict) -> list[TextContent]: workspace_id = args["workspaceId"] body = {"workspace": args.get("workspace", {})} result = await postman_api_call("PUT", f"/workspaces/{workspace_id}", body=body) return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:1641-1655 (schema)Input schema for updateWorkspace: requires workspaceId (string) and accepts workspace (object) for updates.
inputSchema={ "type": "object", "properties": { "workspaceId": { "type": "string", "description": "Workspace ID" }, "workspace": { "type": "object", "description": "Workspace updates" } }, "required": ["workspaceId"] }, ) - tools/postman_tools.py:1887-1887 (registration)UpdateWorkspaceTool() is registered in the register_all_tools() function at line 1887, which returns a list of all ToolHandler instances for MCP.
UpdateWorkspaceTool(), - tools/postman_tools.py:21-67 (helper)The postman_api_call helper function is used by the handler to make HTTP requests 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)}")