list_files
Retrieve a list of files and folders from a specified path in OneDrive using the Microsoft MCP server. Input the account ID, path, and optional limit to manage file access efficiently.
Instructions
List files and folders in OneDrive
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | Yes | ||
| limit | No | ||
| path | No | / |
Implementation Reference
- src/microsoft_mcp/tools.py:716-746 (handler)The handler function for the 'list_files' tool. It lists files and folders in a OneDrive path using Microsoft Graph API, with pagination support.@mcp.tool def list_files( account_id: str, path: str = "/", limit: int = 50 ) -> list[dict[str, Any]]: """List files and folders in OneDrive""" endpoint = ( "/me/drive/root/children" if path == "/" else f"/me/drive/root:/{path}:/children" ) params = { "$top": min(limit, 100), "$select": "id,name,size,lastModifiedDateTime,folder,file,@microsoft.graph.downloadUrl", } items = list( graph.request_paginated(endpoint, account_id, params=params, limit=limit) ) return [ { "id": item["id"], "name": item["name"], "type": "folder" if "folder" in item else "file", "size": item.get("size", 0), "modified": item.get("lastModifiedDateTime"), "download_url": item.get("@microsoft.graph.downloadUrl"), } for item in items ]