createSpec
Upload API spec files to Postman's Spec Hub with support for OpenAPI, AsyncAPI, protobuf, and GraphQL. Specify workspace, name, and type to organize your specs.
Instructions
Creates an API spec in Postman's Spec Hub. Supports OpenAPI 2.0/3.0/3.1, AsyncAPI 2.0, protobuf 2/3, GraphQL. Max file size 10MB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | Yes | List of spec files with path and content. Use '/' in path to create folders. | |
| name | Yes | Specification name | |
| type | Yes | Spec type (openapi, asyncapi, proto, graphql) | |
| workspaceId | Yes | Workspace ID |
Implementation Reference
- tools/postman_tools.py:914-957 (handler)The CreateSpecTool class that implements the 'createSpec' tool. It extends ToolHandler, registers with name 'createSpec', and on execution sends a POST request to /apis with files, name, type, and workspaceId.
class CreateSpecTool(ToolHandler): """Create API specification""" def __init__(self): super().__init__("createSpec") def get_tool_description(self) -> Tool: return Tool( name=self.name, description="Creates an API spec in Postman's Spec Hub. Supports OpenAPI 2.0/3.0/3.1, AsyncAPI 2.0, protobuf 2/3, GraphQL. Max file size 10MB.", inputSchema={ "type": "object", "properties": { "files": { "type": "array", "description": "List of spec files with path and content. Use '/' in path to create folders." }, "name": { "type": "string", "description": "Specification name" }, "type": { "type": "string", "description": "Spec type (openapi, asyncapi, proto, graphql)" }, "workspaceId": { "type": "string", "description": "Workspace ID" } }, "required": ["files", "name", "type", "workspaceId"] }, ) async def run_tool(self, args: dict) -> list[TextContent]: body = { "files": args["files"], "name": args["name"], "type": args["type"], "workspaceId": args["workspaceId"] } result = await postman_api_call("POST", "/apis", body=body) return [TextContent(type="text", text=json.dumps(result, indent=2))] - tools/postman_tools.py:1865-1865 (registration)The tool is registered in the register_all_tools() function as one of the Spec tools.
CreateSpecTool(), - tools/toolhandler.py:9-23 (helper)The abstract base class ToolHandler that CreateSpecTool inherits from, providing the contract with get_tool_description() and run_tool() methods.
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