upload_document
Upload a document file to get a task ID for processing. Supports .pptx, .ppt, .docx, .doc, .xlsx, .pdf files.
Instructions
Upload a document file and return the task_id for processing.
Supported file types: .pptx, .ppt, .docx, .doc, .xlsx, .pdfInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Implementation Reference
- slidespeak.py:404-435 (handler)Handler function for the upload_document MCP tool. It takes a file_path parameter, reads the file from disk, and uploads it via a POST multipart request to the SlideSpeak API's /document/upload endpoint. Returns the JSON response from the API.
@mcp.tool() async def upload_document(file_path: str) -> str: """ Upload a document file and return the task_id for processing. Supported file types: .pptx, .ppt, .docx, .doc, .xlsx, .pdf """ if not API_KEY: return "API Key is missing. Cannot process any requests." url = f"{API_BASE}/document/upload" headers = { "User-Agent": USER_AGENT, "X-API-Key": API_KEY, } if not os.path.isfile(file_path): return f"File not found: {file_path}" try: async with httpx.AsyncClient(timeout=DEFAULT_TIMEOUT) as client: with open(file_path, "rb") as f: files = {"file": (os.path.basename(file_path), f)} response = await client.post(url, headers=headers, files=files) response.raise_for_status() data = response.json() return json.dumps(data) except httpx.HTTPStatusError as e: logging.error(f"HTTP error uploading document: {e.response.status_code} - {e.response.text}") return f"Upload failed: {e.response.status_code} {e.response.text}" except Exception as e: logging.error(f"Unexpected error uploading document: {str(e)}") return f"Upload failed: {str(e)}" - slidespeak.py:404-404 (registration)Registration of upload_document as an MCP tool via the @mcp.tool() decorator.
@mcp.tool()