- Home
- MCP servers
- M365 File Search
M365 File Search
- python
8
GitHub Stars
python
Language
4 months ago
First Indexed
3 weeks ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"godwin3737-mcp-server-microsoft365-filesearch": {
"command": "uv",
"args": [
"--directory",
"full_path_to_parent_directory",
"run",
".\\\\src\\\\mcp_m365_filesearch\\\\server.py"
],
"env": {
"REGION": "SEARCH REGION",
"CLIENT_ID": "MSGraph Client ID",
"TENANT_ID": "TENANT ID",
"CLIENT_SECRET": "MS Graph Client Secret"
}
}
}
}You can run an MCP server that provides advanced Microsoft 365 file search across SharePoint and OneDrive. It exposes two core tools—searching for files and fetching file contents—while leveraging a local cache to speed repeated access and respect API rate limits.
How to use
You interact with the MCP server through your MCP client. Use the search_m365_files tool to query for files using a search term or criteria. The tool returns a list of file metadata objects that include details like drive and file IDs. Then, use get_file_content to retrieve the actual content of a specific file by providing its drive ID and file ID. The server benefits from a local cache, so repeated access to the same file will often load from disk rather than hitting the remote API.
How to install
Prerequisites you need before installation: Node.js is not required for this Python-based server when using the provided runtime shown in the usage example; instead, you will run the server through the MCP runtime interface as described below.
-
Prepare your environment with the required credentials for Microsoft Graph access (see Microsoft Graph App Registration guidance). You will need a Client ID, a Client Secret, a Tenant ID, and a region for search operations.
-
Ensure you have the MCP runtime available. The usage example shows running the server via a runtime command that launches the Python-based server script located at .\src\mcp_m365_filesearch\server.py.
-
Create a configuration for your MCP client to point to the server. A concrete example is provided to run the server as a local stdio MCP endpoint.
Additional configuration and notes
Caching is enabled to speed up repeated access. Cached files are stored under ./src/mcp_m365_filesearch/.local/downloads relative to the project root. When a file is requested, the server checks the cache first and serves from disk if available, reducing API calls and improving response times.
The server requires a Microsoft Graph app registration with Sites.Read.All and Files.Read.All permissions. You must supply the corresponding credentials in your MCP client configuration.
Example usage snippet
{
"mcpServers": {
"M365 File Search (SharePoint/OneDrive)": {
"command": "uv",
"args": [
"--directory",
"full_path_to_parent_directory",
"run",
".\\src\\mcp_m365_filesearch\\server.py"
],
"env": {
"CLIENT_ID": "MSGraph Client ID",
"CLIENT_SECRET": "MS Graph Client Secret",
"TENANT_ID": "TENANT ID",
"REGION": "SEARCH REGION"
}
}
}
}
Troubleshooting tips
If you encounter authentication errors, double-check the Client ID, Client Secret, and Tenant ID. Ensure the registered app has the required API permissions and that admin consent has been granted. If the server cannot reach Microsoft Graph, verify network access and the REGION setting in your environment configuration.
Available tools
search_m365_files
Searches Microsoft 365 files within SharePoint/OneDrive based on a query. Returns an array of file metadata objects including drive ID and file ID.
get_file_content
Fetches the content of a specific file given its drive ID and file ID. Returns the file as a binary stream and utilizes a local cache for faster subsequent access.