Skip to main content
Glama

putCollection

Replaces an existing Postman collection's contents with a new collection in v2.1.0 format. Include ID values to avoid recreation; supports async updates with 'respond-async'.

Instructions

Replaces collection contents using Postman Collection v2.1.0 format. Include ID values or they'll be removed and recreated. Max size 100MB.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdYesCollection ID in format <OWNER_ID>-<COLLECTION_ID>
PreferNoUse 'respond-async' for async update (returns 202)
collectionNoCollection object in Postman Collection v2.1.0 format

Implementation Reference

  • The PutCollectionTool class with its run_tool method that replaces collection contents via a PUT request to /collections/{collectionId}. This is the core handler for the 'putCollection' tool.
    class PutCollectionTool(ToolHandler):
        """Replace collection contents"""
        
        def __init__(self):
            super().__init__("putCollection")
        
        def get_tool_description(self) -> Tool:
            return Tool(
                name=self.name,
                description="Replaces collection contents using Postman Collection v2.1.0 format. Include ID values or they'll be removed and recreated. Max size 100MB.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "collectionId": {
                            "type": "string",
                            "description": "Collection ID in format <OWNER_ID>-<COLLECTION_ID>"
                        },
                        "Prefer": {
                            "type": "string",
                            "description": "Use 'respond-async' for async update (returns 202)"
                        },
                        "collection": {
                            "type": "object",
                            "description": "Collection object in Postman Collection v2.1.0 format"
                        }
                    },
                    "required": ["collectionId"]
                },
            )
        
        async def run_tool(self, args: dict) -> list[TextContent]:
            collection_id = args["collectionId"]
            collection = args.get("collection", {})
            headers = {}
            if args.get("Prefer"):
                headers["Prefer"] = args["Prefer"]
            
            body = {"collection": collection}
            result = await postman_api_call("PUT", f"/collections/{collection_id}", body=body, headers=headers)
            return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • The inputSchema definition for putCollection, defining parameters: collectionId (required), Prefer (optional, for async update), and collection (Postman Collection v2.1.0 object).
    def get_tool_description(self) -> Tool:
        return Tool(
            name=self.name,
            description="Replaces collection contents using Postman Collection v2.1.0 format. Include ID values or they'll be removed and recreated. Max size 100MB.",
            inputSchema={
                "type": "object",
                "properties": {
                    "collectionId": {
                        "type": "string",
                        "description": "Collection ID in format <OWNER_ID>-<COLLECTION_ID>"
                    },
                    "Prefer": {
                        "type": "string",
                        "description": "Use 'respond-async' for async update (returns 202)"
                    },
                    "collection": {
                        "type": "object",
                        "description": "Collection object in Postman Collection v2.1.0 format"
                    }
                },
                "required": ["collectionId"]
            },
        )
  • The register_all_tools function that instantiates and registers all tool handlers, including PutCollectionTool() on line 1842.
    def register_all_tools() -> list[ToolHandler]:
        """Register all Postman tool handlers"""
        return [
            # User Info
            GetAuthenticatedUserTool(),
            GetEnabledToolsTool(),
            
            # Collections
            CreateCollectionTool(),
            GetCollectionTool(),
            GetCollectionsTool(),
            PutCollectionTool(),
            DuplicateCollectionTool(),
  • The postman_api_call helper that handles HTTP communication with the Postman API. Used by PutCollectionTool to make the PUT request.
    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)}")
Behavior4/5

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

Discloses that operation replaces contents, requires ID preservation to avoid recreation, and has 100MB size limit. No annotations to contradict; description carries burden well.

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 succinct sentences conveying essence upfront. Every word contributes: action, format, ID warning, size limit.

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?

Covers key behavioral aspects for a replacement operation with three parameters and no output schema. Sufficient for an agent to use correctly.

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 covers 100% of parameters with basic descriptions; adds value with ID warning and size constraint, enhancing understanding beyond schema fields.

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?

Clearly states 'Replaces collection contents' with specific format and size constraint, distinguishing it from siblings like createCollection or getCollection.

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?

Provides important usage warning about ID values but does not explicitly state when to use vs. alternatives (e.g., putCollection vs. updateCollectionRequest). Implies usage context.

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