Skip to main content
Glama

getSpecCollections

Retrieve all collections created from an API specification by providing the spec ID and element type.

Instructions

Gets all collections generated from an API spec.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
specIdYesSpec ID
elementTypeYesCollection element type
cursorNoPagination cursor
limitNoMax rows

Implementation Reference

  • GetSpecCollectionsTool class - the handler that implements the 'getSpecCollections' tool logic. Makes a GET request to /apis/{specId}/collections with optional pagination params.
    class GetSpecCollectionsTool(ToolHandler):
        """Get spec's generated collections"""
        
        def __init__(self):
            super().__init__("getSpecCollections")
        
        def get_tool_description(self) -> Tool:
            return Tool(
                name=self.name,
                description="Gets all collections generated from an API spec.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "specId": {
                            "type": "string",
                            "description": "Spec ID"
                        },
                        "elementType": {
                            "type": "string",
                            "description": "Collection element type"
                        },
                        "cursor": {
                            "type": "string",
                            "description": "Pagination cursor"
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Max rows"
                        }
                    },
                    "required": ["specId", "elementType"]
                },
            )
        
        async def run_tool(self, args: dict) -> list[TextContent]:
            spec_id = args["specId"]
            params = {"elementType": args["elementType"]}
            if args.get("cursor"):
                params["cursor"] = args["cursor"]
            if args.get("limit"):
                params["limit"] = args["limit"]
            
            result = await postman_api_call("GET", f"/apis/{spec_id}/collections", params=params)
            return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • Input schema for getSpecCollections tool, requiring specId and elementType, with optional cursor and limit for pagination.
    class GetSpecCollectionsTool(ToolHandler):
        """Get spec's generated collections"""
        
        def __init__(self):
            super().__init__("getSpecCollections")
        
        def get_tool_description(self) -> Tool:
            return Tool(
                name=self.name,
                description="Gets all collections generated from an API spec.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "specId": {
                            "type": "string",
                            "description": "Spec ID"
                        },
                        "elementType": {
                            "type": "string",
                            "description": "Collection element type"
                        },
                        "cursor": {
                            "type": "string",
                            "description": "Pagination cursor"
                        },
                        "limit": {
                            "type": "integer",
                            "description": "Max rows"
                        }
                    },
                    "required": ["specId", "elementType"]
                },
            )
  • Registration of GetSpecCollectionsTool() in the register_all_tools() function, making it available as an MCP tool.
    GenerateCollectionTool(),
    GetSpecCollectionsTool(),
  • Helper function postman_api_call used by GetSpecCollectionsTool.run_tool() to make the actual GET 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)}")
Behavior2/5

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

No annotations provided, and the description does not disclose behavioral traits like pagination (cursor/limit), error handling, or side effects. The input schema implies pagination but description does not explain behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One-sentence description is concise but lacks necessary detail for a tool with 4 parameters. Not overly verbose, but could be more informative without being longer.

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

Completeness2/5

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

No output schema and minimal description. Missing details on pagination behavior, return format, meaning of elementType, and what 'collections generated from an API spec' entails. Inadequate for making informed invocation decisions.

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

Parameters3/5

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

Schema description coverage is 100% (all 4 parameters have descriptions). The tool description adds no additional meaning beyond the schema; e.g., does not explain how cursor/limit affect pagination or what elementType values are valid. Baseline 3 due to high coverage.

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?

The description 'Gets all collections generated from an API spec' clearly states the verb 'Gets' and resource 'collections', specifying the source 'from an API spec'. This distinguishes it from siblings like getCollections (all collections) and createCollection (creation).

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 versus alternatives such as getCollections or getTaggedEntities. Absence of context on prerequisites, exclusions, or use cases.

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