data
Microsoft OneDrive CLI for AI Agents
Use the Microsoft OneDrive CLI from KosmoKrator to call Microsoft OneDrive tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.Microsoft OneDrive CLI Setup
Microsoft OneDrive can be configured headlessly with `kosmokrator integrations:configure one-drive`.
# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash
# Configure and verify this integration.
kosmokrator integrations:configure one-drive --set access_token="$ONE_DRIVE_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor one-drive --json
kosmokrator integrations:status --json Credentials
Authentication type: Bearer token bearer_token. Configure credentials once, then reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
access_token | ONE_DRIVE_ACCESS_TOKEN | Secret secret | yes | Access Token |
url | ONE_DRIVE_URL | URL url | no | Graph API URL |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
kosmo integrations:call one-drive.onedrive_list_files '{"top":1,"skip_token":"example_skip_token"}' --json kosmo integrations:one-drive onedrive_list_files '{"top":1,"skip_token":"example_skip_token"}' --json Discovery
These commands return structured output for coding agents that need to inspect capabilities before choosing a function.
kosmo integrations:docs one-drive --json
kosmo integrations:docs one-drive.onedrive_list_files --json
kosmo integrations:schema one-drive.onedrive_list_files --json
kosmo integrations:search "Microsoft OneDrive" --json
kosmo integrations:list --json Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
one-drive.onedrive_list_files
List files and folders in the root of the user's OneDrive. Returns item names, IDs, sizes, and metadata. Use the item ID with onedrive_get_file or onedrive_download_file for details or content.
read - Parameters
- top, skip_token
kosmo integrations:call one-drive.onedrive_list_files '{"top":1,"skip_token":"example_skip_token"}' --json kosmo integrations:one-drive onedrive_list_files '{"top":1,"skip_token":"example_skip_token"}' --json one-drive.onedrive_get_file
Get detailed metadata for a specific file or folder in OneDrive by its item ID. Returns name, size, dates, MIME type, and download URL.
read - Parameters
- id
kosmo integrations:call one-drive.onedrive_get_file '{"id":"example_id"}' --json kosmo integrations:one-drive onedrive_get_file '{"id":"example_id"}' --json one-drive.onedrive_get_drive
Get metadata for the signed-in user's default OneDrive, including drive ID, owner, quota, and drive type.
read - Parameters
- none
kosmo integrations:call one-drive.onedrive_get_drive '{}' --json kosmo integrations:one-drive onedrive_get_drive '{}' --json one-drive.onedrive_list_children
List files and folders under the root folder or under a specific OneDrive parent item.
read - Parameters
- parent_id, top, skip_token
kosmo integrations:call one-drive.onedrive_list_children '{"parent_id":"example_parent_id","top":1,"skip_token":"example_skip_token"}' --json kosmo integrations:one-drive onedrive_list_children '{"parent_id":"example_parent_id","top":1,"skip_token":"example_skip_token"}' --json one-drive.onedrive_create_folder
Create a folder in OneDrive using the Microsoft Graph DriveItem children endpoint.
write - Parameters
- name, parent_id, conflict_behavior
kosmo integrations:call one-drive.onedrive_create_folder '{"name":"example_name","parent_id":"example_parent_id","conflict_behavior":"example_conflict_behavior"}' --json kosmo integrations:one-drive onedrive_create_folder '{"name":"example_name","parent_id":"example_parent_id","conflict_behavior":"example_conflict_behavior"}' --json one-drive.onedrive_update_item
Update OneDrive file or folder metadata. Use name to rename, parent_reference to move, or payload for official Graph fields.
write - Parameters
- id, name, parent_reference, payload
kosmo integrations:call one-drive.onedrive_update_item '{"id":"example_id","name":"example_name","parent_reference":"example_parent_reference","payload":"example_payload"}' --json kosmo integrations:one-drive onedrive_update_item '{"id":"example_id","name":"example_name","parent_reference":"example_parent_reference","payload":"example_payload"}' --json one-drive.onedrive_delete_item
Delete a OneDrive file or folder by drive item ID.
write - Parameters
- id
kosmo integrations:call one-drive.onedrive_delete_item '{"id":"example_id"}' --json kosmo integrations:one-drive onedrive_delete_item '{"id":"example_id"}' --json one-drive.onedrive_copy_item
Copy a OneDrive file or folder asynchronously. Optionally provide a new name and parentReference.
write - Parameters
- id, name, parent_reference, include_all_version_history, payload
kosmo integrations:call one-drive.onedrive_copy_item '{"id":"example_id","name":"example_name","parent_reference":"example_parent_reference","include_all_version_history":true,"payload":"example_payload"}' --json kosmo integrations:one-drive onedrive_copy_item '{"id":"example_id","name":"example_name","parent_reference":"example_parent_reference","include_all_version_history":true,"payload":"example_payload"}' --json one-drive.onedrive_upload_file
Upload a file to OneDrive. Specify the destination path and file content. Creates the file if it does not exist, or replaces it if it does. Supports files up to 4 MB via the simple upload API.
write - Parameters
- path, content, content_type
kosmo integrations:call one-drive.onedrive_upload_file '{"path":"example_path","content":"example_content","content_type":"example_content_type"}' --json kosmo integrations:one-drive onedrive_upload_file '{"path":"example_path","content":"example_content","content_type":"example_content_type"}' --json one-drive.onedrive_download_file
Download a file's content from OneDrive by its drive item ID. Returns the raw file content. Use onedrive_list_files or onedrive_get_file to find the item ID.
read - Parameters
- id
kosmo integrations:call one-drive.onedrive_download_file '{"id":"example_id"}' --json kosmo integrations:one-drive onedrive_download_file '{"id":"example_id"}' --json one-drive.onedrive_list_shared
List files and folders that have been shared with the current user. Returns item names, IDs, sizes, and metadata for shared content.
read - Parameters
- top, skip_token
kosmo integrations:call one-drive.onedrive_list_shared '{"top":1,"skip_token":"example_skip_token"}' --json kosmo integrations:one-drive onedrive_list_shared '{"top":1,"skip_token":"example_skip_token"}' --json one-drive.onedrive_search
Search files and folders in the signed-in user's OneDrive.
read - Parameters
- query
kosmo integrations:call one-drive.onedrive_search '{"query":"example_query"}' --json kosmo integrations:one-drive onedrive_search '{"query":"example_query"}' --json one-drive.onedrive_delta
List changes in the signed-in user's OneDrive. Continue with @odata.nextLink or @odata.deltaLink values returned by Graph.
read - Parameters
- params
kosmo integrations:call one-drive.onedrive_delta '{"params":"example_params"}' --json kosmo integrations:one-drive onedrive_delta '{"params":"example_params"}' --json one-drive.onedrive_list_thumbnails
List thumbnail sets for a OneDrive file or folder item.
read - Parameters
- id
kosmo integrations:call one-drive.onedrive_list_thumbnails '{"id":"example_id"}' --json kosmo integrations:one-drive onedrive_list_thumbnails '{"id":"example_id"}' --json one-drive.onedrive_create_sharing_link
Create or return a sharing link for a OneDrive file or folder.
write - Parameters
- id, type, scope, expiration_date_time, retain_inherited_permissions, payload
kosmo integrations:call one-drive.onedrive_create_sharing_link '{"id":"example_id","type":"example_type","scope":"example_scope","expiration_date_time":"example_expiration_date_time","retain_inherited_permissions":true,"payload":"example_payload"}' --json kosmo integrations:one-drive onedrive_create_sharing_link '{"id":"example_id","type":"example_type","scope":"example_scope","expiration_date_time":"example_expiration_date_time","retain_inherited_permissions":true,"payload":"example_payload"}' --json one-drive.onedrive_list_permissions
List sharing permissions for a OneDrive file or folder.
read - Parameters
- id
kosmo integrations:call one-drive.onedrive_list_permissions '{"id":"example_id"}' --json kosmo integrations:one-drive onedrive_list_permissions '{"id":"example_id"}' --json one-drive.onedrive_delete_permission
Delete a sharing permission from a OneDrive file or folder.
write - Parameters
- item_id, permission_id
kosmo integrations:call one-drive.onedrive_delete_permission '{"item_id":"example_item_id","permission_id":"example_permission_id"}' --json kosmo integrations:one-drive onedrive_delete_permission '{"item_id":"example_item_id","permission_id":"example_permission_id"}' --json one-drive.onedrive_get_current_user
Get the profile of the currently authenticated Microsoft user. Returns display name, email, job title, and other profile details.
read - Parameters
- none
kosmo integrations:call one-drive.onedrive_get_current_user '{}' --json kosmo integrations:one-drive onedrive_get_current_user '{}' --json one-drive.onedrive_api_get
Call a relative Microsoft Graph GET path such as "/me/drive". Absolute URLs are rejected.
read - Parameters
- path, params
kosmo integrations:call one-drive.onedrive_api_get '{"path":"example_path","params":"example_params"}' --json kosmo integrations:one-drive onedrive_api_get '{"path":"example_path","params":"example_params"}' --json one-drive.onedrive_api_post
Call a relative Microsoft Graph POST path with a JSON body. Absolute URLs are rejected.
write - Parameters
- path, payload
kosmo integrations:call one-drive.onedrive_api_post '{"path":"example_path","payload":"example_payload"}' --json kosmo integrations:one-drive onedrive_api_post '{"path":"example_path","payload":"example_payload"}' --json one-drive.onedrive_api_patch
Call a relative Microsoft Graph PATCH path with a JSON body. Absolute URLs are rejected.
write - Parameters
- path, payload
kosmo integrations:call one-drive.onedrive_api_patch '{"path":"example_path","payload":"example_payload"}' --json kosmo integrations:one-drive onedrive_api_patch '{"path":"example_path","payload":"example_payload"}' --json one-drive.onedrive_api_delete
Call a relative Microsoft Graph DELETE path. Absolute URLs are rejected.
write - Parameters
- path, payload
kosmo integrations:call one-drive.onedrive_api_delete '{"path":"example_path","payload":"example_payload"}' --json kosmo integrations:one-drive onedrive_api_delete '{"path":"example_path","payload":"example_payload"}' --json Function Schemas
Use these parameter tables when building CLI payloads without calling integrations:schema first.
one-drive.onedrive_list_files 2 parameters
kosmo integrations:schema one-drive.onedrive_list_files --json | Parameter | Type | Required | Description |
|---|---|---|---|
top | integer | no | Maximum number of items to return (default: 100, max: 999). |
skip_token | string | no | Pagination token from a previous response to fetch the next page of results. |
one-drive.onedrive_get_file 1 parameters
kosmo integrations:schema one-drive.onedrive_get_file --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The unique identifier of the drive item (obtained from onedrive_list_files or onedrive_list_shared). |
one-drive.onedrive_get_drive 0 parameters
kosmo integrations:schema one-drive.onedrive_get_drive --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
one-drive.onedrive_list_children 3 parameters
kosmo integrations:schema one-drive.onedrive_list_children --json | Parameter | Type | Required | Description |
|---|---|---|---|
parent_id | string | no | Optional parent folder item ID. Omit to list root children. |
top | integer | no | Maximum number of items to return (default: 100, max: 999). |
skip_token | string | no | Pagination token from a previous response. |
one-drive.onedrive_create_folder 3 parameters
kosmo integrations:schema one-drive.onedrive_create_folder --json | Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | Folder name. |
parent_id | string | no | Optional parent folder item ID. Omit to create in root. |
conflict_behavior | string | no | Conflict behavior. Defaults to rename. |
one-drive.onedrive_update_item 4 parameters
kosmo integrations:schema one-drive.onedrive_update_item --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | Drive item ID. |
name | string | no | New item name. |
parent_reference | object | no | Graph parentReference object for moving an item. |
payload | object | no | Additional Graph DriveItem update fields. |
one-drive.onedrive_delete_item 1 parameters
kosmo integrations:schema one-drive.onedrive_delete_item --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | Drive item ID to delete. |
one-drive.onedrive_copy_item 5 parameters
kosmo integrations:schema one-drive.onedrive_copy_item --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | Drive item ID to copy. |
name | string | no | Optional new name for the copy. |
parent_reference | object | no | Optional Graph parentReference object for the destination folder. |
include_all_version_history | boolean | no | Whether to include full version history when supported. |
payload | object | no | Additional official Graph copy request fields. |
one-drive.onedrive_upload_file 3 parameters
kosmo integrations:schema one-drive.onedrive_upload_file --json | Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | The destination path in OneDrive, relative to the root (e.g., "Documents/report.txt" or "photos/image.png"). |
content | string | yes | The content of the file to upload. |
content_type | string | no | The MIME type of the file (e.g., "text/plain", "application/json", "image/png"). Defaults to "application/octet-stream". |
one-drive.onedrive_download_file 1 parameters
kosmo integrations:schema one-drive.onedrive_download_file --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | The unique identifier of the drive item to download. |
one-drive.onedrive_search 1 parameters
kosmo integrations:schema one-drive.onedrive_search --json | Parameter | Type | Required | Description |
|---|---|---|---|
query | string | yes | Search text. |
one-drive.onedrive_delta 1 parameters
kosmo integrations:schema one-drive.onedrive_delta --json | Parameter | Type | Required | Description |
|---|---|---|---|
params | object | no | Optional delta query parameters. For exact nextLink URLs, use onedrive_api_get with the relative path from the link. |
one-drive.onedrive_list_thumbnails 1 parameters
kosmo integrations:schema one-drive.onedrive_list_thumbnails --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | Drive item ID. |
one-drive.onedrive_create_sharing_link 6 parameters
kosmo integrations:schema one-drive.onedrive_create_sharing_link --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | Drive item ID. |
type | string | no | Link type. Defaults to view. |
scope | string | no | Link scope. Defaults to organization. |
expiration_date_time | string | no | Optional ISO 8601 expiration date-time. |
retain_inherited_permissions | boolean | no | Whether inherited permissions are retained when first sharing. |
payload | object | no | Additional official Graph createLink fields. |
one-drive.onedrive_list_permissions 1 parameters
kosmo integrations:schema one-drive.onedrive_list_permissions --json | Parameter | Type | Required | Description |
|---|---|---|---|
id | string | yes | Drive item ID. |
one-drive.onedrive_delete_permission 2 parameters
kosmo integrations:schema one-drive.onedrive_delete_permission --json | Parameter | Type | Required | Description |
|---|---|---|---|
item_id | string | yes | Drive item ID. |
permission_id | string | yes | Permission ID to delete. |
one-drive.onedrive_get_current_user 0 parameters
kosmo integrations:schema one-drive.onedrive_get_current_user --json | Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
one-drive.onedrive_api_get 2 parameters
kosmo integrations:schema one-drive.onedrive_api_get --json | Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative Graph path, with or without leading slash. |
params | object | no | Query parameters. |
one-drive.onedrive_api_post 2 parameters
kosmo integrations:schema one-drive.onedrive_api_post --json | Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative Graph path, with or without leading slash. |
payload | object | no | JSON request body. |
one-drive.onedrive_api_patch 2 parameters
kosmo integrations:schema one-drive.onedrive_api_patch --json | Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative Graph path, with or without leading slash. |
payload | object | no | JSON request body. |
one-drive.onedrive_api_delete 2 parameters
kosmo integrations:schema one-drive.onedrive_api_delete --json | Parameter | Type | Required | Description |
|---|---|---|---|
path | string | yes | Relative Graph path, with or without leading slash. |
payload | object | no | Optional JSON request body. |
Permissions
Headless calls still follow the integration read/write permission policy. Configure read/write defaults with
integrations:configure. Add --force only for trusted automation that should bypass that policy.