update_gdrive_source
Update a Google Drive source connector in the Unstructured API MCP Server by specifying the source ID, remote URL, and recursive access for subfolders, returning the updated connector details.
Instructions
Update an gdrive source connector.
Args:
source_id: ID of the source connector to update
remote_url: The gdrive URI to the bucket or folder
recursive: Whether to access subfolders within the bucket
Returns:
String containing the updated source connector information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| drive_id | No | ||
| extensions | No | ||
| recursive | No | ||
| source_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"drive_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Drive Id"
},
"extensions": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Extensions"
},
"recursive": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Recursive"
},
"source_id": {
"title": "Source Id",
"type": "string"
}
},
"required": [
"source_id"
],
"title": "update_gdrive_sourceArguments",
"type": "object"
}
Implementation Reference
- The core handler function implementing the update logic for Google Drive source connectors. It retrieves the current configuration, applies optional updates to drive_id, recursive, and extensions, and calls the Unstructured API to update the source.async def update_gdrive_source( ctx: Context, source_id: str, drive_id: Optional[str] = None, recursive: Optional[bool] = None, extensions: OptionalNullable[List[str]] = UNSET, ) -> str: """Update an gdrive source connector. Args: source_id: ID of the source connector to update remote_url: The gdrive URI to the bucket or folder recursive: Whether to access subfolders within the bucket Returns: String containing the updated source connector information """ client = ctx.request_context.lifespan_context.client # Get the current source connector configuration try: get_response = await client.sources.get_source_async( request=GetSourceRequest(source_id=source_id), ) current_config = get_response.source_connector_information.config except Exception as e: return f"Error retrieving source connector: {str(e)}" # Update configuration with new values config = dict(current_config) if drive_id is not None: config["drive_id"] = drive_id if recursive is not None: config["recursive"] = recursive if extensions is not None: config["extensions"] = extensions source_connector = UpdateSourceConnector(config=config) try: response = await client.sources.update_source_async( request=UpdateSourceRequest( source_id=source_id, update_source_connector=source_connector, ), ) result = create_log_for_created_updated_connector( response, connector_name="GoogleDrive", connector_type="Source", created_or_updated="Updated", ) return result except Exception as e: return f"Error updating gdrive source connector: {str(e)}"
- uns_mcp/connectors/source/source_tool.py:140-146 (registration)Registers update_gdrive_source as the handler for 'gdrive' source type within the higher-level update_source_connector tool dispatcher."azure": update_azure_source, "gdrive": update_gdrive_source, "onedrive": update_onedrive_source, "s3": update_s3_source, "salesforce": update_salesforce_source, "sharepoint": update_sharepoint_source, }
- Helper function to prepare Google Drive source configuration, used in create but pattern similar for update.def _prepare_gdrive_source_config( drive_id: str, recursive: Optional[bool], extensions: OptionalNullable[List[str]] = UNSET, ) -> GoogleDriveSourceConnectorConfigInput: """Prepare the gdrive source connector configuration.""" return GoogleDriveSourceConnectorConfigInput( drive_id=drive_id, recursive=recursive, extensions=extensions, service_account_key=os.getenv("GOOGLEDRIVE_SERVICE_ACCOUNT_KEY"), )