Set up sensitivity labels for SharePoint
Let AI agents read the Microsoft Purview sensitivity label on every SharePoint file they list, search, or open through Mintive's labels-enabled SharePoint server. Mintive manages the Entra app, so there's nothing to register: an admin installs the server, consents for the organization, and attaches the read gate.
The server reads labels only: agents can't apply, change, or remove a label through it, and the server never decrypts a file. The standard SharePoint server from the Microsoft 365 setup doesn't read labels.
Prerequisites
- A Mintive admin account
- Microsoft 365 work or school accounts, and a Global Administrator or Cloud Application Administrator to grant admin consent
- Sensitivity labels published in Microsoft Purview and enabled for files in SharePoint and OneDrive
How it works
Listings and search read the label from a column SharePoint keeps on each file, which can lag a change by a few minutes. Opening a file is when content leaves SharePoint, so the server confirms the label with Microsoft Graph at that point and, for an encrypted file, checks that the user holds the EXTRACT right (the right to copy content out, which Viewer lacks and Co-Author and Owner have). The server reports; the read gate on the gateway decides.
Add the server to Mintive
- In Mintive, go to MCP store > Manage store, find SharePoint (filtered by Labels), and click to install it.
- Have a Global Administrator or Cloud Application Administrator connect first and check Consent on behalf of your organization on the Microsoft consent screen.
SensitivityLabel.Readand the SharePoint scopes need org-wide consent, so until this is done other users see Approval required instead of signing in. The Microsoft 365 guide covers how consent requests reach admins and how to revoke consent later.
Each user then signs in with their Microsoft 365 account on first use and lands back in Mintive without a consent prompt. The server requests the standard SharePoint scopes plus SensitivityLabel.Read, which reads the tenant's labels and the user's rights on each one.
Read labels from agents
Every file returned by list_drive_items, search_items, and get_drive_item carries a sensitivityLabel, and the same labels sit in the result's _meta.sensitivityLabels for middleware, one entry per file with driveId and itemId. Rows are never dropped from listings or search. An agent opening an encrypted file it may not extract from gets this:
{
"item": {
"name": "Q3 board pack.docx",
"sensitivityLabel": {
"status": "labelled",
"id": "4b1f0000-0000-0000-0000-000000000000",
"name": "Highly Confidential",
"priority": 3,
"isEncrypted": true,
"source": "extract"
}
},
"contentWithheld": "no_extract_right"
}
| Field | Description |
|---|---|
status | labelled, none, unsupported_type (Purview labels Office and PDF files only), protected (SharePoint can't open the file), or unknown (the label couldn't be read or isn't in your tenant's catalog) |
id, name | The label's GUID and display name. Match rules on the GUID: it survives renames and tells sublabels with the same name apart. |
priority | The label's priority in Purview; a higher number is a more sensitive label |
isEncrypted | Whether the label encrypts the file |
source | column on listings and search, extract on opens |
contentWithheld | Set by get_drive_item when content or the download link is withheld: no_extract_right (encrypted, and the user lacks EXTRACT), protected, or label_unverified (the label is unknown). The agent still gets the file's details and its Office link. |
Block files by label
Use the SharePoint labels read gate middleware template to stop agents from receiving files that carry a restricted label.
-
In Mintive, go to Guardrails > Middleware and click New middleware.
-
Find SharePoint labels read gate in the templates and click Use template. The template is post-phase and fails closed.
-
Edit the settings at the top of the file:
// Labels to restrict, by GUID: the `id` on any file the server returns
const RESTRICTED_LABEL_IDS = [
"4b1f0000-0000-0000-0000-000000000000", // Highly Confidential
];
// Also restrict every label at or above this priority; null for GUIDs only
const RESTRICTED_PRIORITY_AT_LEAST = null;
// Drop restricted files from listings and search instead of removing their snippet
const HIDE_RESTRICTED_IN_LISTINGS = false;
// Treat a label the server couldn't verify as restricted
const BLOCK_WHEN_LABELS_UNVERIFIED = true; -
Test it with the built-in harness, using a sample result that carries
_meta.sensitivityLabels. -
Save it, attach it to the SharePoint (filtered by Labels) connector only, and turn on enforcement.
| Result | Decision |
|---|---|
get_drive_item on a file with a restricted label | Blocked, with the label in the reason |
list_drive_items or search_items with restricted files | Masked: the files stay listed with their label and lose their search snippet. HIDE_RESTRICTED_IN_LISTINGS drops them instead. |
A file whose label is unknown | Blocked, since an unread label could be restricted. BLOCK_WHEN_LABELS_UNVERIFIED set to false allows these. |
| A result with no label data (another connector) | Blocked |
| Everything else | Allowed |
Security considerations
- Mintive's verified app is the OAuth client, so there's no app registration or secret to rotate. Consent installs it into your tenant, and you can review or revoke it under Enterprise applications in the Entra admin center.
- Every read runs as the signed-in user, and labels are read live on each call, so a change in Purview applies on the next read.
- The gate checks reads only: writes to a restricted file still run under the user's SharePoint permissions, and a labelled file's text pasted into a
.txtfile carries no label.
Next steps
- Set up the Microsoft 365 MCP servers: The standard SharePoint server and the other Microsoft 365 connectors
- Gateway middleware: Create, test, and attach middleware, including the other starter templates