Skip to main content
Glama

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
NameRequiredDescriptionDefault
account_idYes
limitNo
pathNo/

Implementation Reference

  • 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 ]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/elyxlz/microsoft-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server