Project Introduction
Capability Overview
The core API of Baidu Netdisk is now fully compatible with the MCP protocol. It covers upload, download, file management, file search, etc. Developers only need simple configuration to quickly access Baidu Netdisk services, enabling file upload, download, and management within AI applications, significantly lowering the threshold for calling cloud storage services and greatly improving development efficiency.
Preparation Before Use
Core Capabilities
Basic File Information - Get File List
- Description: Retrieve the file list under a specified directory in the user's cloud storage. The returned file list supports sorting, pagination, etc.
- Input:
- dir: Directory name, an absolute path starting with /, default is /. Paths containing Chinese characters require UrlEncode encoding.
- order: Sorting field: Default is name; time sorts by modification time; name sorts by file name.
- desc: Default is ascending order; set to 1 for descending order (Note: Sorting applies to all files in the current directory, not just the current page).
- limit: Number of items to query, default is 1000, recommended maximum is 1000.
- folder: Whether to return only folders. 0 returns all; 1 returns only folders, and only the path field is included in the attributes.
- Output:
- list (array): File information list. Includes: file type, file fs_id (unique identifier in the cloud), whether it is a directory, client creation time, server creation and modification time, cloud hash value (not the actual file md5), file size, thumbnail URL.
Basic File Information - Get Document List
- Description: Retrieve the document list under a specified directory in the user's cloud storage.
- Input:
- parent_path: Directory name, an absolute path starting with /, default is /. Paths containing Chinese characters require UrlEncode encoding.
- page: Page number, starting from 1. If not specified, all results are returned in non-paginated mode. If the page parameter is specified, results are sorted by modification time in descending order.
- num: Number of documents per page, default is 1000, recommended maximum is 1000.
- order: Sorting field: time sorts by modification time, name sorts by file name, size sorts by file size, default is time.
- desc: 0 for ascending, 1 for descending, default is 1.
- recursion: Whether recursion is needed. 0 for no, 1 for yes, default is 0. Recursion means: when a directory contains subfolders, this parameter allows retrieving files under those subfolders.
- folder: Whether to return only folders. 0 returns all; 1 returns only folders, and only the path field is included in the attributes.
- Output:
- info (array): Document list. Includes: file type, file fs_id (unique identifier in the cloud), whether it is a directory, client creation time, server creation and modification time, cloud hash value (not the actual file md5), file size.
Basic File Information - Get Image List
- Description: Retrieve the image list under a specified directory in the user's cloud storage.
- Input:
- parent_path: Directory name, an absolute path starting with /, default is /. Paths containing Chinese characters require UrlEncode encoding.
- page: Page number, starting from 1. If not specified, all results are returned in non-paginated mode. If the page parameter is specified, results are sorted by modification time in descending order.
- num: Number of documents per page, default is 1000, recommended maximum is 1000.
- order: Sorting field: time sorts by modification time, name sorts by file name, size sorts by file size, default is time.
- desc: 0 for ascending, 1 for descending, default is 1.
- recursion: Whether recursion is needed. 0 for no, 1 for yes, default is 0. Recursion means: when a directory contains subfolders, this parameter allows retrieving files under those subfolders.
- web: If web is 1, image thumbnails are returned.
- folder: Whether to return only folders. 0 returns all; 1 returns only folders, and only the path field is included in the attributes.
- Output:
- info (array): Image list. Includes: file type, file fs_id (unique identifier in the cloud), whether it is a directory, client creation time, server creation and modification time, cloud hash value (not the actual file md5), file size, thumbnails (three sizes).
Basic File Information - Get Video List
- Description: Retrieve the video list under a specified directory in the user's cloud storage.
- Input:
- parent_path: Directory name, an absolute path starting with /, default is /. Paths containing Chinese characters require UrlEncode encoding.
- page: Page number, starting from 1. If not specified, all results are returned in non-paginated mode. If the page parameter is specified, results are sorted by modification time in descending order.
- num: Number of documents per page, default is 1000, recommended maximum is 1000.
- order: Sorting field: time sorts by modification time, name sorts by file name, size sorts by file size, default is time.
- desc: 0 for ascending, 1 for descending, default is 1.
- recursion: Whether recursion is needed. 0 for no, 1 for yes, default is 0. Recursion means: when a directory contains subfolders, this parameter allows retrieving files under those subfolders.
- web: If web is 1, video preview thumbnails are returned.
- folder: Whether to return only folders. 0 returns all; 1 returns only folders, and only the path field is included in the attributes.
- Output:
- info (array): Video list. Includes: file type, file fs_id (unique identifier in the cloud), whether it is a directory, client creation time, server creation and modification time, cloud hash value (not the actual file md5), file size, thumbnails (three sizes).
File Management - Create Folder
- Description: Create a folder.
- Input:
- path: Path of the folder to be created.
- Output:
- fs_id: Unique identifier ID of the file in the cloud.
- category: Classification type, 6 for folder.
- path: Absolute path of the file after upload.
- ctime: File creation time.
- mtime: File modification time.
- isdir: Whether it is a directory. 0 for file, 1 for directory.
File Management - Copy
- Description: Copy specified files.
- Input:
- async: 0 for synchronous, 1 for adaptive, 2 for asynchronous.
- ondup: Global ondup, handling strategy for duplicate files: fail (default, returns failure directly), newcopy (rename file), overwrite, skip.
- filelist (json array): Example: [{"path":"/test/123456.docx","dest":"/test/abc","newname":"11223.docx"}]
- path: Absolute path of the source file.
- dest: Target directory.
- newname: Target file name.
- Output:
- taskid: Asynchronous task ID, returned when async=2.
File Management - Delete
- Description: Delete specified files.
- Input:
- async: 0 for synchronous, 1 for adaptive, 2 for asynchronous.
- ondup: Global ondup, handling strategy for duplicate files: fail (default, returns failure directly), newcopy (rename file), overwrite, skip.
- filelist (json array): Absolute paths of files to be deleted. Example: ["/test/123456.docx"]
- Output:
- taskid: Asynchronous task ID, returned when async=2.
File Management - Move
- Description: Move specified files.
- Input:
- async: 0 for synchronous, 1 for adaptive, 2 for asynchronous.
- ondup: Global ondup, handling strategy for duplicate files: fail (default, returns failure directly), newcopy (rename file), overwrite, skip.
- filelist (json array): Example: [{"path":"/test/123456.docx","dest":"/test/abc","newname":"11223.docx"}]
- path: Absolute path of the source file.
- dest: Target directory.
- newname: Target file name.
- Output:
- taskid: Asynchronous task ID, returned when async=2.
- info (array): File information.
File Management - Rename
- Description: Rename specified files.
- Input:
- async: 0 for synchronous, 1 for adaptive, 2 for asynchronous.
- ondup: Global ondup, handling strategy for duplicate files: fail (default, returns failure directly), newcopy (rename file), overwrite, skip.
- filelist (json array): Example: [{"path":"/test/123456.docx","newname":"123.docx"}]
- path: Absolute path of the source file.
- newname: New file name.
- Output:
- taskid: Asynchronous task ID, returned when async=2.
- info (array): File information.
File Upload
- Description: Upload local files to the cloud storage of Baidu Netdisk. Since local files need to be read, the upload tool only supports stdio mode.
- Input:
- local_file_path: Local file path.
- remote_path: (Optional) Cloud storage path, must start with /. If not specified, files will be uploaded to the "/来自:mcp_server" directory by default.
- Output:
- filename: File name.
- size: File size in bytes.
- remote_path: Path of the file in the cloud storage.
- fs_id: File fsid.
- status: Upload status: success for success, error for failure.
- message: Prompt message.
File Download
- Description: Download files stored in the cloud storage of Baidu Netdisk to the local device.
- Input:
- fsid: File fsid.
- Output:
- dlink: File download link.
File Search
- Description: Retrieve the file list under a specified directory in the user's cloud storage where the file name contains the specified keyword.
- Input:
- key: File search keyword.
- Output:
- list: File information list.
- fsid: File ID.
- path: File path.
- server_filename: File name.
- size: File size in bytes.
- isdir: Whether it is a directory. 1 for directory, 0 for non-directory.
- md5: File md5.
- category: File type: 1 for video, 2 for music, 3 for image, 4 for document, 5 for application, 6 for others, 7 for torrent.