@teamnetwork-nz/m365-mcp-server 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -228,7 +228,7 @@ Operations always target exactly one mailbox per request, either the default or
228
228
  | `create_folder` | Create a new folder. Requires `create` grant on the parent path |
229
229
  | `delete_drive_item` | Permanently delete a file or folder. Requires `delete` grant |
230
230
  | `move_drive_item` | Move a file or folder, optionally renaming. Requires `update` at source and `create` at destination |
231
- | `search_drive` | Full-text search within a library (only for libraries with `searchAllowed: true`). Results filtered by grants |
231
+ | `search_drive` | Full-text search within a library (only for libraries with `searchAllowed: true`). Only results passing all three grant axes (path + file + operation) are returned — everything else is silently dropped |
232
232
 
233
233
  #### SharePoint grant model
234
234
 
@@ -181,17 +181,6 @@ export function evaluateFolderAccess(library, folderPath, operation) {
181
181
  `folder "${folderPath}". Use check_sharepoint_access to inspect the grant configuration.`,
182
182
  };
183
183
  }
184
- /**
185
- * Check whether a folder path falls within any configured grant's allowedPaths.
186
- * No file or operation check — purely a path scope test.
187
- *
188
- * Used by search_drive to distinguish:
189
- * - Path in scope, file not accessible → restrictedMatchCount (user knows the folder)
190
- * - Path not in scope at all → silent drop (no information revealed)
191
- */
192
- export function pathIsConfigured(library, folderPath) {
193
- return library.grants.some((grant) => pathMatchesGrant(folderPath, grant.allowedPaths));
194
- }
195
184
  // ── Asserting guards (throw on deny) ────────────────────────────────────────
196
185
  /** Throws ToolError('ACCESS_DENIED') if file access is not permitted. */
197
186
  export function assertFileAccess(library, folderPath, filename, operation) {
@@ -1,7 +1,7 @@
1
1
  import { SearchDriveSchema } from '../schemas.js';
2
2
  import { createGraphClient } from '../../graph/clientFactory.js';
3
3
  import { searchDrive } from '../../graph/sharepoint.js';
4
- import { evaluateFileAccess, pathIsConfigured } from '../../middleware/sharepointGuard.js';
4
+ import { evaluateFileAccess } from '../../middleware/sharepointGuard.js';
5
5
  import { ToolError, errorResponse } from '../../utils/errors.js';
6
6
  import { logger } from '../../utils/logger.js';
7
7
  import { resolveSharepointLibrary } from '../../utils/resolveSharepointLibrary.js';
@@ -31,10 +31,8 @@ export function registerSearchDrive(server, config, auth) {
31
31
  server.tool('search_drive', 'Search for files within a SharePoint document library using Microsoft Graph full-text search. ' +
32
32
  'Only available for libraries configured with searchAllowed: true. ' +
33
33
  'Results are filtered by the library grant configuration: ' +
34
- 'files in paths and matching file patterns allowed by grants are returned in results[]; ' +
35
- 'files in configured paths but restricted by file pattern or operation grants contribute to ' +
36
- 'restrictedMatchCount (so you know relevant content exists but is inaccessible); ' +
37
- 'files completely outside all configured allowedPaths are silently dropped. ' +
34
+ 'only files where all three grant axes pass (allowedPaths, allowedFiles, allowedOperations) ' +
35
+ 'are returned. Everything else is silently dropped — no partial matches or hints are revealed. ' +
38
36
  'Use scopePath to limit the search to a specific folder subtree.', SearchDriveSchema.shape, async (params) => {
39
37
  try {
40
38
  const library = resolveSharepointLibrary(config, params.libraryId);
@@ -53,14 +51,14 @@ export function registerSearchDrive(server, config, auth) {
53
51
  const items = await searchDrive(client, library.driveId, params.query, params.scopePath, params.maxResults);
54
52
  // Client-side grant filtering
55
53
  const results = [];
56
- let restrictedMatchCount = 0;
57
54
  for (const item of items) {
58
55
  // Skip folders — we only surface file results from search
59
56
  if (item.folder !== undefined)
60
57
  continue;
61
58
  const folderPath = extractFolderPath(item.parentReference?.path);
62
59
  const filename = item.name;
63
- // Check full read access (path + file + operation)
60
+ // All three axes must pass (path + file + operation) — anything that
61
+ // does not satisfy a full grant match is silently dropped with no hint.
64
62
  const readResult = evaluateFileAccess(library, folderPath, filename, 'read');
65
63
  if (readResult.allowed) {
66
64
  results.push({
@@ -70,21 +68,8 @@ export function registerSearchDrive(server, config, auth) {
70
68
  ...(item.size !== undefined && { size: item.size }),
71
69
  });
72
70
  }
73
- else if (pathIsConfigured(library, folderPath)) {
74
- // Path is within a configured grant's scope, but file or operation
75
- // is restricted — count it without revealing what the file is.
76
- restrictedMatchCount++;
77
- }
78
- // else: path is outside all configured allowedPaths — silently drop
79
- }
80
- const response = { results };
81
- if (restrictedMatchCount > 0) {
82
- response['restrictedMatchCount'] = restrictedMatchCount;
83
- response['restrictedMatchNote'] =
84
- `${restrictedMatchCount} additional matching file${restrictedMatchCount === 1 ? '' : 's'} ` +
85
- 'were found in accessible folders but are not accessible with current permissions.';
86
71
  }
87
- return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }] };
72
+ return { content: [{ type: 'text', text: JSON.stringify({ results }, null, 2) }] };
88
73
  }
89
74
  catch (err) {
90
75
  logger.error('search_drive failed', { libraryId: params.libraryId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnetwork-nz/m365-mcp-server",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "MCP server for Microsoft 365 — Email, Calendar, To Do, and SharePoint document libraries — using client credentials (app-only auth). Supports multiple accounts, shared mailboxes, per-mailbox read-only access, and grant-based SharePoint access control.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",