SharePoint MCP Server with Microsoft Graph API
Project description
SharePoint MCP Server - Updated with Modern Authentication
A comprehensive MCP Server for seamless integration with Microsoft SharePoint, now with modern Azure AD authentication support to work with new tenants.
🆕 What's New in v2.0
This is an updated fork of the original mcp-sharepoint that fixes the Acquire app-only access token failed error by implementing modern Azure AD authentication methods.
Key Updates
- ✅ Modern MSAL Authentication: Uses Microsoft Authentication Library (MSAL) for Azure AD
- ✅ Multiple Auth Methods: Supports MSAL, certificate-based, and legacy authentication
- ✅ New Tenant Compatible: Works out-of-the-box with new Microsoft 365 tenants
- ✅ Better Error Messages: Clear guidance when authentication fails
- ✅ Tenant ID Required: Properly implements Azure AD app-only authentication
🔧 The Problem This Fixes
The original mcp-sharepoint used the deprecated ACS (Azure Access Control Service) authentication method with with_client_credentials(). This fails on new tenants with:
ValueError: Acquire app-only access token failed
Why this happens:
- Microsoft disabled ACS app-only authentication by default for new tenants
- The old method doesn't include tenant ID in the authentication flow
- Modern Azure AD authentication requires MSAL or certificate-based auth
This update solves it by:
- Using MSAL (Microsoft Authentication Library) by default
- Properly passing tenant ID to Azure AD
- Supporting multiple modern authentication methods
- Falling back gracefully with helpful error messages
📋 Prerequisites
Azure AD App Registration
You need to register an application in Azure AD with the following:
-
Go to Azure Portal → Azure Active Directory → App registrations
-
Create new registration:
- Name: "SharePoint MCP Server" (or your choice)
- Supported account types: "Accounts in this organizational directory only"
- Redirect URI: Not needed for app-only auth
-
Configure API Permissions:
- Click "API permissions" → "Add a permission"
- Choose "SharePoint" → "Application permissions"
- Add these permissions:
Sites.Read.All(for read operations)Sites.ReadWrite.All(for write operations)
- Important: Click "Grant admin consent" for your organization
-
Create Client Secret:
- Go to "Certificates & secrets"
- Click "New client secret"
- Choose expiration (recommend 24 months)
- Save the secret value immediately (you won't see it again)
-
Note these values:
- Application (client) ID
- Directory (tenant) ID
- Client secret value
Required Information
You'll need:
- Tenant ID: Your Azure AD tenant ID (GUID)
- Client ID: Your Azure AD application ID (GUID)
- Client Secret: The secret value you created
- Site URL: Your SharePoint site URL (e.g.,
https://contoso.sharepoint.com/sites/yoursite)
🚀 Installation
From Source (Recommended for this fork)
# Clone this repository
git clone https://github.com/your-username/mcp-sharepoint-updated.git
cd mcp-sharepoint-updated
# Install in development mode
pip install -e .
Using uv (Alternative)
uv pip install -e .
⚙️ Configuration
Environment Variables
Create a .env file or set these environment variables:
# Required - Modern Authentication
SHP_TENANT_ID=your-tenant-id-guid
SHP_ID_APP=your-client-id-guid
SHP_ID_APP_SECRET=your-client-secret
SHP_SITE_URL=https://your-tenant.sharepoint.com/sites/your-site
# Optional
SHP_DOC_LIBRARY=Shared Documents
SHP_AUTH_METHOD=msal # Options: msal (default), certificate, legacy
# For certificate-based authentication (optional)
# SHP_CERT_PATH=/path/to/certificate.pem
# SHP_CERT_THUMBPRINT=your-cert-thumbprint
Authentication Methods
The server supports three authentication methods:
1. MSAL (Recommended - Default)
Modern Azure AD authentication using MSAL. Works with new tenants.
SHP_AUTH_METHOD=msal
2. Certificate-Based
For organizations requiring certificate authentication.
SHP_AUTH_METHOD=certificate
SHP_CERT_PATH=/path/to/cert.pem
SHP_CERT_THUMBPRINT=your-thumbprint
3. Legacy (Deprecated)
Old ACS authentication. Only use if you have an older tenant with ACS enabled.
SHP_AUTH_METHOD=legacy
🔌 Claude Desktop Integration
Windows
Edit: %APPDATA%\Claude\claude_desktop_config.json
macOS
Edit: ~/Library/Application Support/Claude/claude_desktop_config.json
Configuration
{
"mcpServers": {
"sharepoint": {
"command": "python",
"args": ["-m", "mcp_sharepoint"],
"env": {
"SHP_TENANT_ID": "your-tenant-id",
"SHP_ID_APP": "your-client-id",
"SHP_ID_APP_SECRET": "your-client-secret",
"SHP_SITE_URL": "https://your-tenant.sharepoint.com/sites/your-site",
"SHP_DOC_LIBRARY": "Shared Documents",
"SHP_AUTH_METHOD": "msal"
}
}
}
}
Using uvx (Alternative)
{
"mcpServers": {
"sharepoint": {
"command": "uvx",
"args": ["mcp-sharepoint"],
"env": {
"SHP_TENANT_ID": "your-tenant-id",
"SHP_ID_APP": "your-client-id",
"SHP_ID_APP_SECRET": "your-client-secret",
"SHP_SITE_URL": "https://your-tenant.sharepoint.com/sites/your-site",
"SHP_AUTH_METHOD": "msal"
}
}
}
}
🧪 Testing the Connection
After installation, you can test the connection:
# Set your environment variables first
export SHP_TENANT_ID=your-tenant-id
export SHP_ID_APP=your-client-id
export SHP_ID_APP_SECRET=your-secret
export SHP_SITE_URL=https://your-site.sharepoint.com/sites/yoursite
# Run the server
python -m mcp_sharepoint
In Claude Desktop, you can use the "Test_Connection" tool to verify everything is working.
🛠️ Available Tools
The server provides these tools for SharePoint operations:
Document Management
List_SharePoint_Documents- List all documents in a folderGet_Document_Content- Read document contentUpload_Document- Upload new documentsUpdate_Document- Update existing documentsDelete_Document- Delete documents
Folder Management
List_SharePoint_Folders- List folders in a directoryCreate_Folder- Create new foldersDelete_Folder- Delete empty foldersGet_SharePoint_Tree- Get recursive folder structure
Utilities
Test_Connection- Test authentication and connection
🔍 Troubleshooting
"Acquire app-only access token failed"
This is the error we're fixing! If you still see this:
-
Check you're using MSAL:
SHP_AUTH_METHOD=msal # Make sure this is set
-
Verify tenant ID is correct:
- Go to Azure Portal → Azure Active Directory → Overview
- Copy the "Tenant ID" GUID
- Ensure it matches
SHP_TENANT_ID
-
Check API permissions:
- Azure Portal → Your App → API permissions
- Ensure SharePoint permissions are granted
- Click "Grant admin consent"
-
Wait for permission propagation:
- After granting permissions, wait 5-10 minutes
- Try again
"Authentication failed"
-
Verify credentials:
- Client ID is correct (from App registrations → Overview)
- Client secret is correct and not expired
- Tenant ID is correct
-
Check site URL:
- Must be exact SharePoint site URL
- Should NOT end with a slash
- Example:
https://contoso.sharepoint.com/sites/marketing
-
Verify network access:
- Ensure you can reach
login.microsoftonline.comon port 443 - Check firewall/proxy settings
- Ensure you can reach
"Access denied" / "403 Forbidden"
-
Check SharePoint permissions:
- API permissions must be Application permissions, not Delegated
- Need
Sites.Read.AllorSites.ReadWrite.All - Admin consent must be granted
-
Verify site access:
- The app must have access to the specific SharePoint site
- May need to grant site permissions separately
📚 Migration from Original mcp-sharepoint
If you're migrating from the original version:
-
Add new environment variable:
SHP_TENANT_ID=your-tenant-id # This is new!
-
Optional: Set auth method explicitly:
SHP_AUTH_METHOD=msal # Explicitly use modern auth
-
Update your Claude Desktop config:
- Add
SHP_TENANT_IDto the env section - Optionally add
SHP_AUTH_METHOD: "msal"
- Add
-
Restart Claude Desktop to load the new configuration
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Original mcp-sharepoint by sofias tech
- Office365-REST-Python-Client library
- Microsoft Authentication Library (MSAL) for Python
📞 Support
If you encounter issues:
- Check the Troubleshooting section
- Review Azure AD App Setup
- Open an issue with:
- Error message (sanitize any secrets!)
- Your environment (Python version, OS)
- Authentication method being used
- Whether it's a new or existing tenant
Note: This is an updated version that solves the authentication issues with new Microsoft 365 tenants. The original version can be found at Sofias-ai/mcp-sharepoint.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters