mcp -microsoft365-filesearch
MCP server from godwin3737/mcp-server-microsoft365-filesearch
claude mcp add --transport stdio godwin3737-mcp-server-microsoft365-filesearch uv --directory full_path_to_parent_directory run .\\src\\mcp_m365_filesearch\\server.py \ --env REGION="SEARCH REGION" \ --env CLIENT_ID="MSGraph Client ID" \ --env TENANT_ID="TENANT ID" \ --env CLIENT_SECRET="MS Graph Client Secret"
How to use
This MCP server implements Microsoft 365 File Search for SharePoint and OneDrive. It exposes two core tools: search_m365_files, which searches for files within the Microsoft 365 environment and returns file metadata including drive ID and file ID, and get_file_content, which retrieves the content of a specified file (drive ID and file ID) and serves it from a local cache for faster repeated access. The server caches downloaded files to ./src/mcp_m365_filesearch/.local/downloads, speeding up responses and reducing API calls. To integrate with Claude Desktop, configure your mcpServers entry to point to the Python server script using uv (or uvx) and provide the necessary Azure AD credentials via environment variables (CLIENT_ID, CLIENT_SECRET, TENANT_ID, and REGION) so the server can authenticate to Microsoft Graph and access SharePoint/OneDrive data.
How to install
Prerequisites:
- Python 3.8+ and pip
- Access to a Microsoft 365 tenant with appropriate Graph API permissions (Sites.Read.All, Files.Read.All)
- Optional: uv/uvx runner if you choose to run via the provided wrapper
Installation steps:
-
Clone the repository git clone https://github.com/your-org/mcp-microsoft365-filesearch.git cd mcp-microsoft365-filesearch
-
Set up a Python virtual environment (recommended) python -m venv venv source venv/bin/activate # on Windows use: venv\Scripts\activate
-
Install dependencies pip install -r requirements.txt
If there is no requirements.txt, ensure required packages for Microsoft Graph access are installed as per docs
-
Register an Azure AD app and collect credentials
- Create Client ID (APP_ID), Client Secret, and Tenant ID
- Ensure API permissions include Sites.Read.All and Files.Read.All
-
Run the server (one of the following approaches depending on your setup)
-
Using uv/uvx (as shown in the README example): uv --directory <path_to_parent_directory> run .\src\mcp_m365_filesearch\server.py
-
Or, if you run directly with Python: python -m <module_name> # if your project exposes a module entry point
or
python ./src/mcp_m365_filesearch/server.py
-
-
Export environment variables for Azure Graph authentication export CLIENT_ID=<your_client_id> export CLIENT_SECRET=<your_client_secret> export TENANT_ID=<your_tenant_id> export REGION=<your_region>
On Windows use set instead of export
-
Validate installation
- Send a test search via the MCP interface and verify that results include drive IDs and file IDs
- Attempt get_file_content for a known file to ensure caching works (check ./src/mcp_m365_filesearch/.local/downloads)
Additional notes
Tips and troubleshooting:
- Ensure your Azure AD app has granted admin consent for the required permissions.
- The local cache directory is relative to the project root (./src/mcp_m365_filesearch/.local/downloads); ensure the process has write permissions there.
- If you encounter authentication errors, double-check CLIENT_ID, CLIENT_SECRET, and TENANT_ID, and verify that the app registration includes the proper redirect URIs if using certain auth flows.
- When integrating with Claude Desktop, ensure the command and directory paths match your local environment (adjust --directory and server.py path accordingly).
- If you rotate client secrets, update the environment variables promptly to avoid downtime.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP