Skip to main content
Glama

getSpecFile

Retrieve the contents of a specific file from an API specification. Provide the spec ID and file path to access the file.

Instructions

Gets the contents of an API spec's file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
specIdYesSpec ID
filePathYesPath to the file

Implementation Reference

  • GetSpecFileTool class: the handler that implements the 'getSpecFile' tool logic. Calls GET /apis/{specId}/files/{filePath} via postman_api_call utility and returns the contents of an API spec file.
    class GetSpecFileTool(ToolHandler):
        """Get spec file contents"""
        
        def __init__(self):
            super().__init__("getSpecFile")
        
        def get_tool_description(self) -> Tool:
            return Tool(
                name=self.name,
                description="Gets the contents of an API spec's file.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "specId": {
                            "type": "string",
                            "description": "Spec ID"
                        },
                        "filePath": {
                            "type": "string",
                            "description": "Path to the file"
                        }
                    },
                    "required": ["specId", "filePath"]
                },
            )
        
        async def run_tool(self, args: dict) -> list[TextContent]:
            spec_id = args["specId"]
            file_path = args["filePath"]
            result = await postman_api_call("GET", f"/apis/{spec_id}/files/{file_path}")
            return [TextContent(type="text", text=json.dumps(result, indent=2))]
  • get_tool_description method defines the input schema for getSpecFile, requiring specId (string) and filePath (string) parameters.
    def get_tool_description(self) -> Tool:
        return Tool(
            name=self.name,
            description="Gets the contents of an API spec's file.",
            inputSchema={
                "type": "object",
                "properties": {
                    "specId": {
                        "type": "string",
                        "description": "Spec ID"
                    },
                    "filePath": {
                        "type": "string",
                        "description": "Path to the file"
                    }
                },
                "required": ["specId", "filePath"]
            },
        )
  • Registration of GetSpecFileTool() in the register_all_tools function, making it available as an MCP tool.
    GetSpecFileTool(),
    UpdateSpecFileTool(),
  • postman_api_call helper function: the generic async HTTP client that handles all Postman API calls including the one made by getSpecFile.
    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 are provided, and the description does not disclose behavioral traits such as read-only nature, side effects, or authentication requirements. The agent must infer safety from the name alone.

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?

The description is a single, front-loaded sentence with no fluff. Every word is necessary.

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 is provided, and the description does not explain the return format (e.g., raw text, JSON, binary). For a tool that retrieves file contents, this gap reduces completeness.

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 coverage is 100%, with clear parameter descriptions (specId, filePath). The description adds no additional meaning beyond the schema, earning a baseline 3.

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 clearly states the verb 'Gets' and the resource 'contents of an API spec's file,' which distinguishes it from siblings like getSpec (gets spec metadata) and getSpecFiles (lists files).

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 is provided on when to use this tool versus alternatives such as getSpec or getSpecFiles. An AI agent has no context for selection.

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