download_presentation
Retrieve a temporary download URL for a generated presentation using the request ID from a completed task.
Instructions
Get the download URL for a generated presentation.
Use the request_id returned by getTaskStatus (from a completed generation task)
to get a temporary download link.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request_id | Yes |
Implementation Reference
- slidespeak.py:387-401 (handler)The `download_presentation` tool handler function. It takes a `request_id`, makes a GET request to `/presentation/download/{request_id}` via `_make_api_request`, and returns the download URL from the API response.
@mcp.tool() async def download_presentation(request_id: str) -> str: """ Get the download URL for a generated presentation. Use the request_id returned by getTaskStatus (from a completed generation task) to get a temporary download link. """ if not API_KEY: return "API Key is missing. Cannot process any requests." result = await _make_api_request("GET", f"/presentation/download/{request_id}", timeout=DEFAULT_TIMEOUT) if not result: return f"Failed to get download URL for request {request_id}." return f"Make sure to return the download URL to the user. Result: {json.dumps(result)}" - slidespeak.py:387-401 (registration)The `@mcp.tool()` decorator on line 387 registers `download_presentation` as an MCP tool with the FastMCP server. This is the registration point.
@mcp.tool() async def download_presentation(request_id: str) -> str: """ Get the download URL for a generated presentation. Use the request_id returned by getTaskStatus (from a completed generation task) to get a temporary download link. """ if not API_KEY: return "API Key is missing. Cannot process any requests." result = await _make_api_request("GET", f"/presentation/download/{request_id}", timeout=DEFAULT_TIMEOUT) if not result: return f"Failed to get download URL for request {request_id}." return f"Make sure to return the download URL to the user. Result: {json.dumps(result)}" - slidespeak.py:389-393 (schema)The tool's docstring serves as the schema/description: accepts a single `request_id: str` parameter (from a completed generation task) and returns a download URL string.
""" Get the download URL for a generated presentation. Use the request_id returned by getTaskStatus (from a completed generation task) to get a temporary download link. """ - slidespeak.py:28-78 (helper)The `_make_api_request` helper function used by `download_presentation` to make the actual HTTP GET request to the SlideSpeak API.
async def _make_api_request( method: Literal["GET", "POST"], endpoint: str, payload: Optional[dict[str, Any]] = None, timeout: float = DEFAULT_TIMEOUT ) -> Optional[dict[str, Any]]: """ Makes an HTTP request to the SlideSpeak API. Args: method: HTTP method ('GET' or 'POST'). endpoint: API endpoint path (e.g., '/presentation/templates'). payload: JSON payload for POST requests. Ignored for GET. timeout: Request timeout in seconds. Returns: The parsed JSON response as a dictionary on success, None on failure. """ if not API_KEY: logging.error("API Key is missing. Cannot make API request.") return None headers = { "User-Agent": USER_AGENT, "Accept": "application/json", "X-API-Key": API_KEY, } url = f"{API_BASE}{endpoint}" req_start = time.time() async with httpx.AsyncClient() as client: try: if method == "POST": response = await client.post(url, json=payload, headers=headers, timeout=timeout) else: response = await client.get(url, headers=headers, timeout=timeout) elapsed = time.time() - req_start logging.info(f"{method} {url} | status={response.status_code} | elapsed={elapsed:.2f}s") response.raise_for_status() return response.json() except httpx.HTTPStatusError as e: logging.error(f"HTTP error {method} {url}: {e.response.status_code} - {e.response.text}") except httpx.RequestError as e: logging.error(f"Request error {method} {url}: {str(e)}") except Exception as e: logging.error(f"Unexpected error {method} {url}: {str(e)}") return None