MCP server › Sample workflows

Selective OneDrive folder backup

This walkthrough backs up three specific folders from a shared OneDrive drive — then inspects what was collected by browsing the stored files. It uses the DataTap-hosted Enron corpus (a public email and file dataset loaded under a viewer account) as concrete demonstration data. The same pattern applies to any OneDrive source on your own tenant.

Step 1 — Identify connections

Call list_connections to see the sources and destinations already configured for the tenant. Note the Id of the OneDrive source and the Blob destination — both are needed when creating the collector.

// list_connections
[
  { "Id": "<onedrive-conn-id>", "Type": "ONEDRIVE", "Name": "Enron Corpus — OneDrive Source" },
  { "Id": "<blob-conn-id>",     "Type": "BLOB",     "Name": "Enron Corpus — Blob Backup"     }
]

Step 2 — Discover the drive owner

Call discover_users with a nameFilter to narrow down to the account whose drive you want to back up. In this example the account is viewer — the service account that holds the Enron corpus folders.

The Id returned here scopes the collector to that specific drive. Record all four fields (id, name, email, type) — all are required in the next steps.

// discover_users
// connectionId: <onedrive-conn-id>   nameFilter: "viewer"
{ "Id": "<user-id>", "Name": "viewer", "Email": "viewer@<tenant>.onmicrosoft.com", "Type": "OneDriveUser" }

Step 3 — Browse the drive’s top-level folders

Call browse_source_items with nodeId: "-" to list the root of the drive. Each folder’s Name becomes the path value in indexFromPaths; ChildCount gives a rough scope estimate before committing to a run.

The Enron corpus is organised as one top-level folder per corpus persona. The three chosen here — Steve Kean, Joe Parks, and Vince J Kaminski — represent a cross-section of roles from trading analyst to executive.

// browse_source_items
// connectionId: <onedrive-conn-id>   sourceId: <user-id>   nodeId: "-"   pageSize: 50
{ "Name": "Steve Kean",       "Id": "<kean-folder-id>",     "ChildCount": 42 }
{ "Name": "Joe Parks",        "Id": "<parks-folder-id>",    "ChildCount": 28 }
{ "Name": "Vince J Kaminski", "Id": "<kaminski-folder-id>", "ChildCount": 67 }
// … further top-level folders omitted

Step 4 — Create a scoped files collector

Call create_files_collector, passing the user from step 2 in users and the three folder names in indexFromPaths. Only items under those paths are downloaded and stored. Omit indexFromPaths entirely to back up the whole drive.

// create_files_collector
{
  "name":          "Enron Corpus — Steve Kean, Joe Parks, Vince J Kaminski",
  "description":   "Targeted backup of three Enron corpus folders from viewer's OneDrive",
  "sourceId":      "<onedrive-conn-id>",
  "destinationId": "<blob-conn-id>",
  "scheduleType":  "DISABLED",
  "users": [
    {
      "id":    "<user-id>",
      "name":  "viewer",
      "email": "viewer@<tenant>.onmicrosoft.com",
      "type":  "OneDriveUser"
    }
  ],
  "indexFromPaths": [
    { "path": "Steve Kean/",       "type": "INCLUDE" },
    { "path": "Joe Parks/",        "type": "INCLUDE" },
    { "path": "Vince J Kaminski/", "type": "INCLUDE" }
  ]
}

The server returns the new collector object. Record its Id for the next step.

Steps 5 & 6 — Run and monitor

Call run_collector to start the job immediately. It returns a TaskId — pass that to get_collector_status and poll until State reaches READY (success) or FAILED.

The collector provisions a dedicated worker container, so the first poll or two may return STARTING while the container comes up. Once it transitions to RUNNING the agent is actively downloading and indexing content. A run over these three folders typically completes within a few minutes; check list_collector_reports for per-folder detail if it reaches FAILED.

// run_collector → collectorId: <collector-id>
{ "TaskId": "<task-id>", "State": "STARTING" }

// get_collector_status → collectorId: <collector-id>   taskId: <task-id>
// poll until State leaves STARTING / RUNNING
{ "State": "READY" }

Step 7 — Browse collected content

Call browse_source_items again, this time pointing at one of the collected folders by its Id from step 3. Use types: "OneDriveFile" to surface only files. Filter client-side on the Name suffix (e.g. .pdf) to narrow by type.

In the Kaminski folder the corpus contains g052901.pdf — a scanned document characteristic of the research-heavy content in Kaminski’s archive. Pass any item’s Id to preview_item to download or inspect the full content.

// browse_source_items — inspecting the Vince J Kaminski folder
// connectionId: <onedrive-conn-id>   sourceId: <user-id>   nodeId: <kaminski-folder-id>
{ "Name": "g052901.pdf", "Id": "...", "Size": 142336 }
// … pass any item's Id to preview_item to download or inspect its content
What’s next? Once the collection is indexed, switch to the Search tools — search_content, search_attachments, or summarize_content — to query the content of the collected files without downloading anything.

← Back to MCP server · Next sample: Who talked to the outside world? →