createSpecFile
Generate API spec files in Postman by providing the spec ID, file path (supports folder creation with '/'), and stringified content. Files are assigned DEFAULT type and limited to 10MB.
Instructions
Creates an API spec file. Use '/' in path to create folders. File assigned DEFAULT type. Max size 10MB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| specId | Yes | Spec ID | |
| content | Yes | File's stringified contents | |
| path | Yes | File path (JSON or YAML) |
Implementation Reference
- tools/postman_tools.py:1092-1130 (handler)The CreateSpecFileTool class implements the 'createSpecFile' tool. It registers with name 'createSpecFile', defines the input schema requiring specId, content, and path, and executes by making a POST request to /apis/{spec_id}/files to create a new file in an API spec.
class CreateSpecFileTool(ToolHandler): """Create spec file""" def __init__(self): super().__init__("createSpecFile") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Creates an API spec file. Use '/' in path to create folders. File assigned DEFAULT type. Max size 10MB.", inputSchema={ "type": "object", "properties": { "specId": { "type": "string", "description": "Spec ID" }, "content": { "type": "string", "description": "File's stringified contents" }, "path": { "type": "string", "description": "File path (JSON or YAML)" } }, "required": ["specId", "content", "path"] }, ) async def run_tool(self, args: dict) -> list[TextContent]: spec_id = args["specId"] body = { "content": args["content"], "path": args["path"] } result = await postman_api_call("POST", f"/apis/{spec_id}/files", body=body) return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:1870-1870 (registration)The CreateSpecFileTool() is registered in the register_all_tools() function at line 1870, making it available as part of the 41-tool suite.
CreateSpecFileTool(), - tools/toolhandler.py:9-23 (helper)ToolHandler is the abstract base class that CreateSpecFileTool inherits from. It defines the interface with get_tool_description() and run_tool() methods that all tool handlers must implement.
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 - tools/postman_tools.py:1098-1120 (schema)The input schema for createSpecFile defines three required parameters: specId (string), content (string - the file's stringified contents), and path (string - file path as JSON or YAML).
def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Creates an API spec file. Use '/' in path to create folders. File assigned DEFAULT type. Max size 10MB.", inputSchema={ "type": "object", "properties": { "specId": { "type": "string", "description": "Spec ID" }, "content": { "type": "string", "description": "File's stringified contents" }, "path": { "type": "string", "description": "File path (JSON or YAML)" } }, "required": ["specId", "content", "path"] }, )