Skip to main content

Microsoft OneDrive MCP Server

Create a powerful Model Context Protocol (MCP) server for Microsoft OneDrive in minutes with our AI Gateway. This guide walks you through setting up seamless cloud storage integration with enterprise-grade security and instant OAuth authentication.

About Microsoft OneDrive API

The Microsoft Graph API provides comprehensive access to OneDrive and SharePoint document libraries, enabling file storage, sharing, synchronization, and collaboration features across the Microsoft 365 ecosystem.

Key Capabilities

  • File Management: Upload, download, move, copy files
  • Folder Operations: Create, organize folder structures
  • Sharing & Permissions: Share files with specific permissions
  • Version Control: Access file version history
  • Search: Find files across OneDrive and SharePoint
  • Sync: Synchronize files across devices
  • Metadata: Manage file properties and tags
  • Thumbnails: Generate and retrieve previews

API Features

  • Microsoft Graph API: Unified endpoint
  • Delta Sync: Track changes efficiently
  • Large File Upload: Resumable sessions
  • OAuth 2.0: Enterprise authentication
  • Webhooks: Real-time notifications
  • Batch Requests: Multiple operations
  • Special Folders: Quick access to Desktop, Documents
  • Cross-tenant: B2B collaboration support

What You Can Do with Microsoft OneDrive MCP Server

The MCP server transforms OneDrive's API into a natural language interface, enabling AI agents to:

File & Folder Management

  • File Operations

    • "Upload quarterly report to Finance folder"
    • "Download all PDFs from Projects folder"
    • "Copy presentation to Shared Documents"
    • "Move old files to Archive folder"
  • Folder Organization

    • "Create folder structure for new project"
    • "Organize files by date modified"
    • "Create subfolders by file type"
    • "Clean up duplicate folders"
  • Bulk Operations

    • "Upload all files from local directory"
    • "Download entire folder as zip"
    • "Delete files older than 1 year"
    • "Rename files with standard format"

Sharing & Collaboration

  • Share Management

    • "Share folder with marketing team"
    • "Create view-only link for document"
    • "Set expiration date for shared link"
    • "Remove external user access"
  • Permission Control

    • "Grant edit access to specific users"
    • "Make folder read-only for guests"
    • "Inherit permissions from parent"
    • "Block download for sensitive files"
  • Collaboration Features

    • "Check who has access to file"
    • "Track shared link usage"
    • "Send sharing invitation email"
    • "Create password-protected link"

Search & Discovery

  • File Search

    • "Find all Excel files modified this week"
    • "Search for documents containing 'budget'"
    • "Locate files shared by John"
    • "Find largest files in my drive"
  • Advanced Search

    • "Search in file contents"
    • "Find files by custom metadata"
    • "Search across shared libraries"
    • "Locate files with specific tags"
  • Smart Filters

    • "Show files I've shared"
    • "List recently accessed documents"
    • "Find files pending my review"
    • "Show files modified by others"

Sync & Version Control

  • Version Management

    • "Show version history of contract"
    • "Restore previous version of file"
    • "Compare versions side by side"
    • "Download specific version"
  • Sync Operations

    • "Sync folder to local machine"
    • "Pause sync for large files"
    • "Force sync of updated files"
    • "Check sync status"
  • Change Tracking

    • "Show recent changes in folder"
    • "Track who modified files"
    • "Get notifications for changes"
    • "Monitor folder activity"

Special Folders & Features

  • Quick Access

    • "Access Desktop folder"
    • "Open Documents folder"
    • "Navigate to Pictures"
    • "Show Recent files"
  • Recycle Bin

    • "Restore deleted files"
    • "Empty recycle bin"
    • "Search in deleted items"
    • "Permanently delete files"
  • Shared Libraries

    • "Access team SharePoint library"
    • "Browse shared with me"
    • "Open group document library"
    • "Navigate to site assets"

Metadata & Properties

  • File Properties

    • "Add tags to documents"
    • "Update file description"
    • "Set custom metadata fields"
    • "Apply retention labels"
  • Content Types

    • "Apply document template"
    • "Set content type properties"
    • "Manage metadata schemas"
    • "Create custom columns"
  • Classification

    • "Mark files as confidential"
    • "Apply sensitivity labels"
    • "Set compliance tags"
    • "Manage retention policies"

Upload & Download

  • Upload Operations

    • "Upload large video file"
    • "Resume interrupted upload"
    • "Upload folder with structure"
    • "Replace existing file"
  • Download Features

    • "Download as different format"
    • "Create download link"
    • "Batch download files"
    • "Download with metadata"
  • Transfer Management

    • "Monitor upload progress"
    • "Queue multiple uploads"
    • "Set bandwidth limits"
    • "Schedule transfers"

Security & Compliance

  • Access Control

    • "Audit file access history"
    • "Block external sharing"
    • "Require authentication"
    • "Set IP restrictions"
  • Data Protection

    • "Enable ransomware detection"
    • "Configure file encryption"
    • "Set up DLP policies"
    • "Monitor suspicious activity"
  • Compliance Features

    • "Apply legal hold"
    • "Export for eDiscovery"
    • "Track compliance status"
    • "Generate audit reports"

Prerequisites

  • Access to Cequence AI Gateway
  • Microsoft 365 subscription
  • Azure AD tenant access
  • App registration permissions

Step 1: Register Azure AD Application

1.1 Access Azure Portal

  1. Go to portal.azure.com
  2. Navigate to Azure Active Directory
  3. Select App registrations
  4. Click New registration

1.2 Configure Application

  1. Basic Information:

    • Name: "AI Gateway OneDrive MCP"
    • Supported account types: Choose based on needs
    • Redirect URI: Web platform
      https://auth.aigateway.cequence.ai/v1/outbound/oauth/callback
  2. Click Register

1.3 Configure API Permissions

  1. Go to API permissions
  2. Click Add a permission
  3. Select Microsoft Graph
  4. Choose Delegated permissions
  5. Add OneDrive-related permissions (see scopes section)
  6. Grant admin consent if required

1.4 Create Client Secret

  1. Go to Certificates & secrets
  2. Click New client secret
  3. Add description and expiry
  4. Copy the secret value immediately

1.5 Note Application Details

  1. Go to Overview
  2. Copy Application (client) ID
  3. Copy Directory (tenant) ID

Step 2-4: Standard Setup

Follow standard steps to access AI Gateway, find Microsoft OneDrive API, and create MCP server.

Step 5: Configure API Endpoints

  1. Base URL: https://graph.microsoft.com/v1.0
  2. Select OneDrive endpoints:
    • Drive endpoints
    • DriveItem endpoints
    • Permission endpoints
    • Share endpoints
  3. Click Next

Step 6: MCP Server Configuration

  1. Name: "Microsoft OneDrive Storage"
  2. Description: "Cloud file storage and sharing"
  3. Configure production mode
  4. Click Next

Step 7: Configure Authentication

  1. Authentication Type: OAuth 2.0
  2. Authorization URL:
    https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize
  3. Token URL:
    https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token
  4. Enter Client ID and Secret
  5. Select required scopes

Available Microsoft OneDrive OAuth Scopes

File Access

  • Files.Read

    • Read user files
    • List folders
    • Download files
    • View metadata
  • Files.ReadWrite

    • Full file access
    • Upload files
    • Create folders
    • Delete items
  • Files.Read.All / Files.ReadWrite.All

    • Access all files user can see
    • SharePoint libraries
    • Shared files
    • Group files

Sharing Permissions

  • Files.Read.Selected / Files.ReadWrite.Selected
    • Access specific files
    • File picker scenarios
    • Limited access
    • App folders

SharePoint Access

  • Sites.Read.All / Sites.ReadWrite.All

    • SharePoint sites
    • Document libraries
    • Team files
    • Lists access
  • Sites.Manage.All

    • Full site control
    • Create libraries
    • Manage permissions
    • Site settings

Offline & User

  • offline_access

    • Refresh tokens
    • Long-term access
    • Background sync
    • Scheduled tasks
  • User.Read

    • User profile
    • Email address
    • Display name
    • Profile photo

For Personal OneDrive:

Files.ReadWrite
User.Read
offline_access

For Business/SharePoint:

Files.ReadWrite.All
Sites.ReadWrite.All
User.Read
offline_access

For Sharing Scenarios:

Files.ReadWrite
Files.ReadWrite.All
User.Read.All
offline_access

Step 8-10: Complete Setup

Configure security, choose deployment, and deploy.

Using Your Microsoft OneDrive MCP Server

With Claude Desktop

{
"servers": {
"onedrive": {
"url": "your-mcp-server-url",
"auth": {
"type": "oauth2",
"client_id": "your-client-id"
}
}
}
}

Natural Language Commands

  • "Upload project files to new folder"
  • "Share presentation with edit permissions"
  • "Find all PDFs modified this week"
  • "Download team meeting recordings"
  • "Organize files by project name"

API Integration Example

// Initialize MCP client
const mcpClient = new MCPClient({
serverUrl: 'your-mcp-server-url',
auth: {
type: 'oauth2',
token: 'access-token'
}
});

// Get user's drive
const drive = await mcpClient.onedrive.drives.get('me');

// Create folder structure
const projectFolder = await mcpClient.onedrive.items.createFolder({
parentId: drive.root.id,
name: 'Project Alpha 2025',
folder: {}
});

const subfolders = ['Documents', 'Images', 'Reports'];
for (const folderName of subfolders) {
await mcpClient.onedrive.items.createFolder({
parentId: projectFolder.id,
name: folderName,
folder: {}
});
}

// Upload file
const fileContent = Buffer.from('Quarterly report content...');
const uploadSession = await mcpClient.onedrive.items.createUploadSession({
parentId: projectFolder.id,
item: {
'@microsoft.graph.conflictBehavior': 'rename',
name: 'Q1_Report_2025.pdf',
description: 'First quarter financial report'
}
});

// Upload in chunks for large files
const uploadUrl = uploadSession.uploadUrl;
const fileSize = fileContent.length;
const chunkSize = 10 * 1024 * 1024; // 10MB chunks

for (let i = 0; i < fileSize; i += chunkSize) {
const chunk = fileContent.slice(i, Math.min(i + chunkSize, fileSize));
await mcpClient.onedrive.upload.chunk({
uploadUrl,
content: chunk,
contentRange: `bytes ${i}-${Math.min(i + chunkSize - 1, fileSize - 1)}/${fileSize}`
});
}

// Share file with link
const shareLink = await mcpClient.onedrive.items.createLink({
itemId: 'uploaded-file-id',
type: 'view',
scope: 'organization',
password: 'SecurePass123',
expirationDateTime: '2025-12-31T23:59:59Z'
});

// Share with specific users
const permission = await mcpClient.onedrive.items.invite({
itemId: projectFolder.id,
requireSignIn: true,
sendInvitation: true,
roles: ['write'],
recipients: [
{ email: 'colleague@company.com' },
{ email: 'manager@company.com' }
],
message: 'Please review the project files'
});

// Search for files
const searchResults = await mcpClient.onedrive.search({
query: 'budget 2025',
select: ['name', 'lastModifiedDateTime', 'size'],
filter: "file ne null and lastModifiedDateTime ge '2025-01-01'"
});

// Get recent files
const recentFiles = await mcpClient.onedrive.drives.recent({
top: 20,
select: ['name', 'lastModifiedBy', 'lastModifiedDateTime']
});

// Download file
const fileStream = await mcpClient.onedrive.items.download({
itemId: 'file-id'
});

// Get versions
const versions = await mcpClient.onedrive.items.versions({
itemId: 'file-id'
});

// Restore previous version
if (versions.value.length > 1) {
await mcpClient.onedrive.versions.restore({
itemId: 'file-id',
versionId: versions.value[1].id
});
}

// Move files
await mcpClient.onedrive.items.move({
itemId: 'file-id',
parentReference: {
id: 'destination-folder-id'
},
name: 'Renamed_File.docx'
});

// Set retention label
await mcpClient.onedrive.items.setRetentionLabel({
itemId: 'file-id',
retentionLabelId: 'label-id'
});

Common Use Cases

Document Management

  • Centralized file storage
  • Document versioning
  • Collaborative editing
  • Template libraries

Project Organization

  • Project file structures
  • Team collaboration
  • Resource sharing
  • Archive management

Backup & Sync

  • Automated backups
  • Cross-device sync
  • Offline access
  • Disaster recovery

Content Distribution

  • Secure file sharing
  • External collaboration
  • Public links
  • Marketing assets

Security Best Practices

  1. OAuth Security:

    • Use minimal scopes
    • Implement token refresh
    • Monitor access logs
    • Regular credential rotation
  2. File Protection:

    • Enable versioning
    • Use sensitivity labels
    • Control external sharing
    • Implement DLP policies
  3. Access Control:

    • Regular permission audits
    • Link expiration dates
    • Password protection
    • Conditional access

Troubleshooting

Common Issues

  1. Authentication Errors

    • Verify app registration
    • Check tenant ID
    • Validate redirect URI
    • Review permissions
  2. Upload Failures

    • Check file size limits
    • Verify quota available
    • Resume failed uploads
    • Check network stability
  3. Sharing Issues

    • Verify sharing policies
    • Check external sharing
    • Review guest access
    • Validate recipients

Getting Help