MCP server › Sample workflows

List files in a OneDrive folder

A common e-discovery starting point: given a folder name, list every file it contains — optionally filtered to a specific document type. The workflow bridges two tool families: Discovery tools to resolve the folder's index ID, and Search tools to query the index. The sample runs against the DataTap-hosted Enron corpus (Vince J Kaminski's OneDrive folder, 33 files of mixed type).

The tool sequence

Steps 1–3 use Discovery tools to navigate the drive tree and get the folder's opaque index ID (parentId). Steps 4–5 use Search tools to query the index by that ID, with an optional contentType filter to narrow to a specific file format. In step 3, nameFilter performs a case-insensitive prefix match on folder names — useful when the drive has many top-level folders and you already know the name you're looking for:

// 1 · Find the OneDrive connection ID.
{"tool": "list_connections", "arguments": {}}
// → pick the connection whose Type is "ONEDRIVE"

// 2 · Discover which users own a drive — needed to browse.
{"tool": "discover_users", "arguments": {
  "connectionId": "<onedrive-connection-id>"
}}
// → returns Sources[].Id — the sourceId for the next step.
//   Note: in a shared-drive setup (e.g. multiple Enron persona folders
//   all uploaded under one licensed account) discover_users returns only
//   the account owners, not the sub-folders. Browse reveals the folders.

// 3 · Browse the root of the target user's drive to list top-level folders.
//   Use nameFilter to narrow to a specific folder by name (case-insensitive
//   prefix match). Omit it to list all top-level folders.
{"tool": "browse_source_items", "arguments": {
  "connectionId": "<onedrive-connection-id>",
  "sourceId": "<source-id-from-step-2>",
  "nodeId": "-",
  "nameFilter": "Kaminski"
}}
// → Items[]: entries matching the name filter, each with Id (the parentId
//   used by the index) and Name (human-readable). Pick the folder you want.

// 4 · Search the index for all files in that folder.
{"tool": "search_content_advanced", "arguments": {
  "filter": "parentId eq '<folder-id-from-step-3>'",
  "select": "fileName,contentType,size",
  "top": 100
}}

// 5 · (Optional) Narrow to a specific file type using contentType.
{"tool": "search_content_advanced", "arguments": {
  "filter": "parentId eq '<folder-id>' and contentType eq 'application/msword'",
  "select": "fileName,contentType,size",
  "top": 100
}}

Results — Kaminski folder, .doc files

The Vince J Kaminski folder holds 33 files across 8 types (Excel, Word, PowerPoint, PDF, images, video, a VCard, and a raw binary). Filtering to contentType eq 'application/msword' returns the 12 .doc files:

// Vince J Kaminski folder (parentId = 01745MNQFLTYG3YFK2WJDI3EKJLWCVEAAT)
// filter: parentId eq '…' and contentType eq 'application/msword'
// totalCount: 12

 81,920  Amend to PPA v2 (bl) 032801.doc
 65,536  085conf(slater steel).doc
 56,832  TGP LEASE AGREEMENT.doc
 55,808  Oneok issues August 2001.doc
 49,152  Utility Comparison Table.doc
 35,328  Project Raptor 1.doc
 34,304  ExImMcDonald.doc
 33,280  viol11162000.doc
 27,136  Crescendo-agency.doc
 26,112  Purchase Option Notice(CAED II)executioncopy.doc
 22,016  Flow Gate vs LMP with R Berry's comments 2 2 2001.doc
 19,968  MEETING AGENDA FOR HOUSTON.doc

The full folder breakdown by type:

contentTypeExtensionFiles
application/msword.doc12
application/vnd.ms-excel.xls11
application/vnd.ms-powerpoint.ppt3
image/jpeg.jpg3
application/pdf.pdf1
video/mpeg.mpg1
text/x-vcard.vcf1
application/octet-stream.dat1
Next step. Once you have a file's uniqueKey from step 4, pass it to get_item for the full document record, or to preview_item with format="json" to inspect its content and metadata before deciding whether to restore it.

← Previous sample: Selective OneDrive folder backup · Back to MCP server →