list_docs_in_folder
Retrieve a formatted list of Google Docs within a specified Drive folder using the Google Workspace MCP Server. Streamline document organization and access with straightforward folder queries.
Instructions
Lists Google Docs within a specific Drive folder.
Returns:
str: A formatted list of Google Docs in the specified folder.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder_id | No | root | |
| page_size | No | ||
| service | Yes | ||
| user_google_email | Yes |
Implementation Reference
- gdocs/docs_tools.py:253-282 (handler)The core handler function that executes the tool logic: lists Google Docs files in a specified Drive folder using the Google Drive API, formats the results, and returns a string summary.async def list_docs_in_folder( service: Any, user_google_email: str, folder_id: str = 'root', page_size: int = 100 ) -> str: """ Lists Google Docs within a specific Drive folder. Returns: str: A formatted list of Google Docs in the specified folder. """ logger.info(f"[list_docs_in_folder] Invoked. Email: '{user_google_email}', Folder ID: '{folder_id}'") rsp = await asyncio.to_thread( service.files().list( q=f"'{folder_id}' in parents and mimeType='application/vnd.google-apps.document' and trashed=false", pageSize=page_size, fields="files(id, name, modifiedTime, webViewLink)", supportsAllDrives=True, includeItemsFromAllDrives=True ).execute ) items = rsp.get('files', []) if not items: return f"No Google Docs found in folder '{folder_id}'." out = [f"Found {len(items)} Docs in folder '{folder_id}':"] for f in items: out.append(f"- {f['name']} (ID: {f['id']}) Modified: {f.get('modifiedTime')} Link: {f.get('webViewLink')}") return "\n".join(out)
- gdocs/docs_tools.py:250-250 (registration)Registers the 'list_docs_in_folder' tool with the MCP server using the @server.tool() decorator.@server.tool()