---
name: sharepoint-pptx
description: Edit SharePoint/OneDrive presentations via Playwright or download/upload
metadata:
  activation:
    keywords: [sharepoint presentation, onedrive presentation, sharepoint pptx, online presentation]
    patterns:
      - "(?i)https?://[\\w-]+\\.sharepoint\\.com/.+\\.pptx"
      - "(?i)https?://[\\w-]+-my\\.sharepoint\\.com/.+\\.pptx"
      - "(?i)https?://1drv\\.ms/p/"
      - "(?i)\\b(edit|update|modify)\\b.{0,30}\\b(sharepoint|onedrive)\\b.{0,20}\\b(presentation|pptx|slides|deck)\\b"
  requires:
    tools: [browser]
---

# SharePoint/OneDrive Presentations

Use this guide when the user provides a SharePoint or OneDrive URL pointing to a `.pptx` file.

## Two Modes

| | Mode 1 — Online (default) | Mode 2 — Download/Upload (fallback) |
|---|---|---|
| How | Playwright → PowerPoint Online | Download → edit locally → upload |
| Co-authoring safe | Yes | **No — last writer wins** |
| Text edits, titles, bullets | ✓ | ✓ |
| Add/remove/reorder slides | Limited | ✓ |
| Complex formatting, images | Not reliable | ✓ |
| Create from scratch | ✗ | ✓ |

**Always start with Mode 1.** Only use Mode 2 when Mode 1 cannot do what's needed — and warn the user first.

## Mode 1: Online Editing (Default)

PowerPoint Online opens `.pptx` files directly in the browser. Use Playwright to interact.

### Prerequisites

- Browser tool (Playwright) must be available
- User must be signed into Microsoft 365 in the browser

### Opening

```
# Navigate to the SharePoint URL
browser_navigate → <sharepoint_url>

# Wait for PowerPoint Online to load
browser_wait_for → text: "Home"  (the ribbon tab)
```

If the URL opens a file preview instead of the editor, look for and click **"Edit"** or **"Open in Browser"**.

### Navigating Slides

Click slide thumbnails in the left panel to navigate:

```
browser_snapshot    # See current state
browser_click → ref: <slide_thumbnail_ref>
```

### Editing Text

1. Click the text box
2. Select all with Ctrl+A, then type replacement — or click to position cursor

```
browser_click → ref: <text_box_ref>
browser_press_key → key: "Control+a"
browser_type → ref: <text_box_ref>, text: "New text here"
```

Changes auto-save — no manual save needed.

### Mode 1 Limitations

Switch to Mode 2 (with co-authoring warning) when the user needs:
- Adding, deleting, or reordering slides
- Inserting images, charts, or tables
- Changing slide layouts or themes
- Creating a presentation from scratch

## Mode 2: Download / Upload (Fallback)

> ⚠️ **Always warn the user before proceeding:**
> "Downloading and re-uploading will overwrite the current version. If anyone else is editing, their changes will be lost."

### Download

1. Navigate to the SharePoint URL in the browser
2. Click the "..." (more options) menu → Download
3. Locate the most recently modified `.pptx` in the user's downloads folder

### Edit Locally

Use the standard `pptx` skill workflows for local editing:
- Read content with `python-pptx` or `markitdown`
- Edit with `python-pptx`
- Create from scratch with `python-pptx`

### Upload Back

General path (works for SharePoint sites and personal OneDrive — pass the drive id from metadata as `documentLibraryId`):

```
MCP_sharepoint_createSmallBinaryFile:
  documentLibraryId: "<driveId>"
  fileName: "modified.pptx"
  fileContent: <base64-encoded content>
  conflictBehavior: "replace"   # required when overwriting
```

Shortcut for personal OneDrive (`*-my.sharepoint.com/personal/` · `1drv.ms`) when you already know the file is in `/me/drive` — no `documentLibraryId`:

```
MCP_onedrive_createSmallBinaryFileInMyOnedrive:
  filename: "modified.pptx"
  base64Content: <base64-encoded content>
  parentFolderId: "<folder_id>"  # optional, defaults to "root"
```

Size caps:
- MCP `createSmall*File`: ~4 MB write cap
- Graph PUT to `/content` direct: 4 MB
- Larger files: use Graph upload session (no example shown — see Graph docs)

If MCP tools are not available, use Playwright:

1. Navigate to the SharePoint folder containing the file
2. Use the Upload button or drag-and-drop to replace the file
3. Confirm overwrite when prompted

### Upload via Graph API (alternative)

`$TOKEN` is bash syntax; in PowerShell use `$env:TOKEN`.

```bash
# Get drive item info
curl -H "Authorization: Bearer $TOKEN" \
  "https://graph.microsoft.com/v1.0/me/drive/root:/<path>/<file>.pptx"

# Upload (< 4MB)
curl -X PUT \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @modified.pptx \
  "https://graph.microsoft.com/v1.0/me/drive/root:/<path>/<file>.pptx:/content"
```

## Best Practices

- **Default to Mode 1** — preserves co-authoring, no data loss risk
- **Warn before Mode 2** — always inform the user about overwrite risk
- **Verify after upload** — open the SharePoint URL and confirm changes rendered correctly
- **Check file locks** — if upload fails with 423, the file is open in someone's browser
- **Cross-tenant links** — may fail; ask the owner to reshare if access is denied
