mcp-sharepoint-us 2.0.16__py3-none-any.whl → 2.0.17__py3-none-any.whl
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.
Potentially problematic release.
This version of mcp-sharepoint-us might be problematic. Click here for more details.
- mcp_sharepoint/__init__.py +4 -1
- mcp_sharepoint/graph_api.py +34 -9
- {mcp_sharepoint_us-2.0.16.dist-info → mcp_sharepoint_us-2.0.17.dist-info}/METADATA +1 -1
- mcp_sharepoint_us-2.0.17.dist-info/RECORD +10 -0
- mcp_sharepoint_us-2.0.16.dist-info/RECORD +0 -10
- {mcp_sharepoint_us-2.0.16.dist-info → mcp_sharepoint_us-2.0.17.dist-info}/WHEEL +0 -0
- {mcp_sharepoint_us-2.0.16.dist-info → mcp_sharepoint_us-2.0.17.dist-info}/entry_points.txt +0 -0
- {mcp_sharepoint_us-2.0.16.dist-info → mcp_sharepoint_us-2.0.17.dist-info}/licenses/LICENSE +0 -0
- {mcp_sharepoint_us-2.0.16.dist-info → mcp_sharepoint_us-2.0.17.dist-info}/top_level.txt +0 -0
mcp_sharepoint/__init__.py
CHANGED
|
@@ -43,11 +43,13 @@ def ensure_context(func):
|
|
|
43
43
|
client_id = os.getenv("SHP_ID_APP")
|
|
44
44
|
client_secret = os.getenv("SHP_ID_APP_SECRET")
|
|
45
45
|
tenant_id = os.getenv("SHP_TENANT_ID")
|
|
46
|
+
document_library = os.getenv("SHP_DOC_LIBRARY", "Shared Documents")
|
|
46
47
|
cloud = "government" if ".sharepoint.us" in site_url else "commercial"
|
|
47
48
|
|
|
48
49
|
logger.info(f"Site URL: {site_url}")
|
|
49
50
|
logger.info(f"Tenant ID: {tenant_id}")
|
|
50
51
|
logger.info(f"Client ID: {client_id}")
|
|
52
|
+
logger.info(f"Document Library: {document_library}")
|
|
51
53
|
logger.info(f"Cloud: {cloud}")
|
|
52
54
|
|
|
53
55
|
# Create shared authenticator
|
|
@@ -70,7 +72,8 @@ def ensure_context(func):
|
|
|
70
72
|
|
|
71
73
|
graph_client = GraphAPIClient(
|
|
72
74
|
site_url=site_url,
|
|
73
|
-
token_callback=get_token
|
|
75
|
+
token_callback=get_token,
|
|
76
|
+
document_library_name=document_library
|
|
74
77
|
)
|
|
75
78
|
logger.info("Graph API client initialized successfully")
|
|
76
79
|
|
mcp_sharepoint/graph_api.py
CHANGED
|
@@ -23,16 +23,18 @@ class GraphAPIClient:
|
|
|
23
23
|
where SharePoint REST API may not support app-only authentication.
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
def __init__(self, site_url: str, token_callback):
|
|
26
|
+
def __init__(self, site_url: str, token_callback, document_library_name: str = "Documents"):
|
|
27
27
|
"""
|
|
28
28
|
Initialize Graph API client.
|
|
29
29
|
|
|
30
30
|
Args:
|
|
31
31
|
site_url: SharePoint site URL (e.g., https://tenant.sharepoint.us/sites/SiteName)
|
|
32
32
|
token_callback: Function that returns access token
|
|
33
|
+
document_library_name: Name of the document library to use (e.g., "Shared Documents1")
|
|
33
34
|
"""
|
|
34
35
|
self.site_url = site_url.rstrip("/")
|
|
35
36
|
self.token_callback = token_callback
|
|
37
|
+
self.document_library_name = document_library_name
|
|
36
38
|
self._site_id = None
|
|
37
39
|
self._drive_id = None # Cache drive ID to avoid repeated API calls
|
|
38
40
|
|
|
@@ -297,7 +299,8 @@ class GraphAPIClient:
|
|
|
297
299
|
|
|
298
300
|
def _get_drive_id(self) -> str:
|
|
299
301
|
"""
|
|
300
|
-
Get the
|
|
302
|
+
Get the document library drive ID by name.
|
|
303
|
+
Fetches all drives and finds the one matching self.document_library_name.
|
|
301
304
|
Caches the result for reuse.
|
|
302
305
|
"""
|
|
303
306
|
if self._drive_id:
|
|
@@ -305,9 +308,10 @@ class GraphAPIClient:
|
|
|
305
308
|
return self._drive_id
|
|
306
309
|
|
|
307
310
|
site_id = self._get_site_id()
|
|
308
|
-
url = f"{self.graph_endpoint}/sites/{site_id}/
|
|
311
|
+
url = f"{self.graph_endpoint}/sites/{site_id}/drives"
|
|
309
312
|
|
|
310
|
-
logger.info(f"Fetching
|
|
313
|
+
logger.info(f"Fetching all drives from: {url}")
|
|
314
|
+
logger.info(f"Looking for document library named: '{self.document_library_name}'")
|
|
311
315
|
|
|
312
316
|
try:
|
|
313
317
|
logger.debug(f"Sending GET request to: {url}")
|
|
@@ -316,16 +320,37 @@ class GraphAPIClient:
|
|
|
316
320
|
logger.debug(f"Response received - Status: {response.status_code}")
|
|
317
321
|
self._handle_response(response)
|
|
318
322
|
|
|
319
|
-
|
|
320
|
-
logger.info(f"
|
|
321
|
-
|
|
323
|
+
drives = response.json().get("value", [])
|
|
324
|
+
logger.info(f"Found {len(drives)} drives in site")
|
|
325
|
+
|
|
326
|
+
# Log all available drives for debugging
|
|
327
|
+
for drive in drives:
|
|
328
|
+
drive_name = drive.get("name", "Unknown")
|
|
329
|
+
drive_id = drive.get("id", "Unknown")
|
|
330
|
+
logger.debug(f" Drive: '{drive_name}' (ID: {drive_id})")
|
|
331
|
+
|
|
332
|
+
# Find the drive matching the configured document library name
|
|
333
|
+
for drive in drives:
|
|
334
|
+
if drive.get("name") == self.document_library_name:
|
|
335
|
+
self._drive_id = drive["id"]
|
|
336
|
+
logger.info(f"✓ Found matching drive '{self.document_library_name}' with ID: {self._drive_id}")
|
|
337
|
+
return self._drive_id
|
|
338
|
+
|
|
339
|
+
# If no match found, raise an error with helpful message
|
|
340
|
+
available_drives = [d.get("name", "Unknown") for d in drives]
|
|
341
|
+
error_msg = (
|
|
342
|
+
f"Could not find document library named '{self.document_library_name}'. "
|
|
343
|
+
f"Available drives: {', '.join(available_drives)}"
|
|
344
|
+
)
|
|
345
|
+
logger.error(error_msg)
|
|
346
|
+
raise ValueError(error_msg)
|
|
322
347
|
|
|
323
348
|
except requests.exceptions.ConnectionError as e:
|
|
324
|
-
logger.error(f"✗ ConnectionError getting
|
|
349
|
+
logger.error(f"✗ ConnectionError getting drives: {e}", exc_info=True)
|
|
325
350
|
raise
|
|
326
351
|
|
|
327
352
|
except requests.exceptions.RequestException as e:
|
|
328
|
-
logger.error(f"✗ Network error getting
|
|
353
|
+
logger.error(f"✗ Network error getting drives: {type(e).__name__}: {e}", exc_info=True)
|
|
329
354
|
raise
|
|
330
355
|
|
|
331
356
|
def list_folders(self, folder_path: str = "") -> List[Dict[str, Any]]:
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
mcp_sharepoint/__init__.py,sha256=pwdrY0tUpeq0y5o233sgAz-rpWqRe7ay92_j6lNx-8E,21182
|
|
2
|
+
mcp_sharepoint/__main__.py,sha256=4iVDdDZx4rQ4Zo-x0RaCrT-NKeGObIz_ks3YF8di2nA,132
|
|
3
|
+
mcp_sharepoint/auth.py,sha256=fwOCsg1pv0cN26hNlsHhJhGckeDkJCiXZrMmiBn9jf4,18156
|
|
4
|
+
mcp_sharepoint/graph_api.py,sha256=36o0YPCgpjs_XTIohaxwgEg6i4wuYMpwO-lZC9SPz3I,24813
|
|
5
|
+
mcp_sharepoint_us-2.0.17.dist-info/licenses/LICENSE,sha256=SRM8juGH4GjIqnl5rrp-P-S5mW5h2mINOPx5-wOZG6s,1112
|
|
6
|
+
mcp_sharepoint_us-2.0.17.dist-info/METADATA,sha256=VkWwO9m1T5Qyl0tpal-inHPn4PVMJ3qq1Bnst-F6vT8,11402
|
|
7
|
+
mcp_sharepoint_us-2.0.17.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
mcp_sharepoint_us-2.0.17.dist-info/entry_points.txt,sha256=UZOa_7OLI41rmsErbvnSz9RahPMGQVcqZUFMphOcjbY,57
|
|
9
|
+
mcp_sharepoint_us-2.0.17.dist-info/top_level.txt,sha256=R6mRoWe61lz4kUSKGV6S2XVbE7825xfC_J-ouZIYpuo,15
|
|
10
|
+
mcp_sharepoint_us-2.0.17.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
mcp_sharepoint/__init__.py,sha256=sSJtlX91mBQ4fM12R8XK7Vrkkr3YPJqriE8LZP157vM,20969
|
|
2
|
-
mcp_sharepoint/__main__.py,sha256=4iVDdDZx4rQ4Zo-x0RaCrT-NKeGObIz_ks3YF8di2nA,132
|
|
3
|
-
mcp_sharepoint/auth.py,sha256=fwOCsg1pv0cN26hNlsHhJhGckeDkJCiXZrMmiBn9jf4,18156
|
|
4
|
-
mcp_sharepoint/graph_api.py,sha256=KxKQNafkOJDY312nNMFAUKrsjFIUppMkX--0mFdog9Q,23402
|
|
5
|
-
mcp_sharepoint_us-2.0.16.dist-info/licenses/LICENSE,sha256=SRM8juGH4GjIqnl5rrp-P-S5mW5h2mINOPx5-wOZG6s,1112
|
|
6
|
-
mcp_sharepoint_us-2.0.16.dist-info/METADATA,sha256=qYGUEmc8mv05PW7Ainq-Pp5LB-xWv_fjLpv8Y2ZUbtE,11402
|
|
7
|
-
mcp_sharepoint_us-2.0.16.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
-
mcp_sharepoint_us-2.0.16.dist-info/entry_points.txt,sha256=UZOa_7OLI41rmsErbvnSz9RahPMGQVcqZUFMphOcjbY,57
|
|
9
|
-
mcp_sharepoint_us-2.0.16.dist-info/top_level.txt,sha256=R6mRoWe61lz4kUSKGV6S2XVbE7825xfC_J-ouZIYpuo,15
|
|
10
|
-
mcp_sharepoint_us-2.0.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|