baidudisk-mcp
Use this skill to run Baidu Netdisk tools through mcporter.
1) Enable server in mcporter
Run:
bash scripts/baidudisk_mcporter.sh register
This writes a baidudisk stdio server entry into config/mcporter.json with:
- command:
/home/linuxbrew/.linuxbrew/bin/uv
- args:
--directory <workspace>/skills/baidudisk-mcp/server run netdisk.py
- env:
BAIDU_NETDISK_TOKEN_FILE=~/.openclaw/credentials/baidudisk.json
Check status:
bash scripts/baidudisk_mcporter.sh check
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json list baidudisk
2) Credential file and hot update
Credential file (local only):
~/.openclaw/credentials/baidudisk.json
Expected keys:
access_token (required)
default_dir (recommended)
Example (do not commit real token):
{
"access_token": "<redacted>",
"default_dir": "/Openclaw/baidudisk"
}
The MCP server reads this file on every tool call.
So token rotation only needs editing this file; no server restart is required.
3) 2.0 tools
3.1 Official-aligned tools (主推)
四个基础列表接口与 MCP tool 对应关系:
/rest/2.0/xpan/file?method=list → file_list(dir?, limit?, order?, desc?, start?)
/rest/2.0/xpan/file?method=imagelist → file_image_list(parent_path?, recursion?, page?, num?, order?, desc?, web=1)
/rest/2.0/xpan/file?method=doclist → file_doc_list(parent_path?, recursion?, page?, num?, order?, desc?)
/rest/2.0/xpan/file?method=videolist → file_video_list_api(parent_path?, recursion?, page?, num?, order?, desc?, web=1)
另保留一个历史兼容视频工具(非官方 videolist 参数模型):
file_video_list(dir?, recursion?, start?, limit?, order?, desc?)(基于 xpanfilelistall 过滤视频)
其他工具:
category_info(category, parent_path='/', recursion=1)
category_info_multi(categories, parent_path='/', recursion=1)
image_gettags(type=1)
image_gettags_summary(type=1, top=50)
image_search(search_type, keyword, start=0, limit=100, size?)
recent_list(category=3, start=0, limit=100, sortby?, order?, stime?, etime?, resolution='off')
file_meta(fsids, dlink?, thumb?, extra?, needmedia?, path?)
make_dir(path, parent_dir?)
file_copy(src_path, dest_dir, new_name?, ondup?)
file_copy_batch(items, async_mode=1, chunk_size=100, dry_run=false, allow_dest_prefixes=['/Openclaw'])
file_del(path, confirm)
file_move(src_path, dest_dir, new_name?, ondup?)
file_move_batch(items, async_mode=1, chunk_size=100, dry_run=false, allow_dest_prefixes=['/Openclaw'])
file_rename(path, new_name)
file_rename_batch(items, async_mode=1, chunk_size=100, dry_run=false)
file_upload_stdio(local_file_path, remote_dir?, remote_name?)
file_upload_by_url(url, remote_dir?, remote_name?, timeout_s?, max_bytes?)
file_upload_by_text(text, remote_dir?, remote_name?, max_chars?, max_bytes?)
file_keyword_search(keyword, dir?, recursion?, num?, page?)
file_semantics_search(...)(当前 unsupported stub)
file_sharelink_set(...)(当前 unsupported stub)
user_info()
get_quota(checkexpire?, checkfree?)
3.2 Legacy aliases (兼容保留)
list
search
mkdir
move
rename
delete
upload
download
4) mcporter examples
# 对齐 list:/rest/2.0/xpan/file?method=list
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_list dir=/ limit=3
# 对齐 imagelist:/rest/2.0/xpan/file?method=imagelist
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_image_list parent_path='/来自:iPhone' recursion=0 page=1 num=3 order=time desc=1
# 对齐 doclist:/rest/2.0/xpan/file?method=doclist
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_doc_list parent_path='/Openclaw' recursion=1 page=1 num=3 order=time desc=1
# 对齐 videolist:/rest/2.0/xpan/file?method=videolist
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_video_list_api parent_path='/' recursion=1 page=1 num=3 order=time desc=1
# 若根目录返回 count=0,可改 parent_path='/来自:iPhone' 或 '/Openclaw'
# 官方同名:关键词搜索
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_keyword_search keyword=invoice num=20
# 分类统计(单分类:图片=3)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.category_info category=3 parent_path=/ recursion=1
# 分类统计(多分类:JSON array)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.category_info_multi categories='[1,3,4,6]' parent_path=/ recursion=1
# 图片智能标签
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.image_gettags type=1
# 图片智能标签摘要(按 count 取前 20)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.image_gettags_summary type=1 top=20
# 图片关键字检索(search_type=2 表示汉字)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.image_search \
search_type=2 keyword=截图 limit=20 size='c256_u256,c512_u512'
# 图片列表(imagelist,默认 web=1 返回缩略图字段)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_image_list \
parent_path='/Openclaw' recursion=1 page=1 num=10 order=time desc=1
# 按上传时间拉取最近图片
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.recent_list \
category=3 limit=20 resolution=off
# 官方同名:创建目录
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.make_dir path=reports/2026
# 批量移动(默认 限制在 /Openclaw)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_move_batch \
items='[{"src_path":"/Openclaw/inbox/a.txt","dest_dir":"/Openclaw/archive"},{"src_path":"/Openclaw/inbox/b.txt","dest_dir":"/Openclaw/archive"}]' \
chunk_size=100 async_mode=1
# 批量复制(显式冲突策略 newcopy:冲突时自动副本,不覆盖原文件)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_copy_batch \
items='[{"src_path":"/Openclaw/inbox/a.txt","dest_dir":"/Openclaw/archive"}]' \
async_mode=1
# 批量重命名(dry_run 先演练)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_rename_batch \
items='[{"path":"/Openclaw/archive/a.txt","new_name":"a-20260228.txt"}]' \
dry_run=true
# 官方同名:本地文件上传
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_upload_stdio local_file_path=/tmp/demo.txt
# 官方同名:按 URL 上传(HTTP/HTTPS,带大小/超时限制)
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_upload_by_url url=https://example.com/demo.txt remote_dir=/Openclaw/baidudisk
# 官方同名:文本上传
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_upload_by_text text='hello world' remote_name=hello.txt
# 官方同名:配额
mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.get_quota
5) Batch return envelope(8.2)
file_move_batch / file_copy_batch / file_rename_batch 统一返回:
status, tool, dry_run, async_mode, ondup, chunk_size
total_items, chunks
summary(ok_chunks/failed_chunks/ok_items_est/failed_items_est)
results(每个 chunk:chunk_index/items/request_preview/response(errno/taskid/info))
errors(失败 chunk 的 chunk_index/message/items_preview)
6) Minimal self-check(不含 delete)
请不要直接用 python3(容易缺 mcp 依赖)。
cd /home/ubuntu/.openclaw/workspace/skills/baidudisk-mcp
server/.venv/bin/python server/selfcheck_batch_filemanager.py
server/.venv/bin/python server/selfcheck_misc_readonly.py
# 下两项为真实只读联网检查(需要 token)
BAIDU_NETDISK_TOKEN_FILE=~/.openclaw/credentials/baidudisk.json server/.venv/bin/python server/selfcheck_image_recent_readonly.py
BAIDU_NETDISK_TOKEN_FILE=~/.openclaw/credentials/baidudisk.json server/.venv/bin/python server/selfcheck_lists_readonly.py
# 等价写法(如果你用 uv)
# uv run --directory server python selfcheck_batch_filemanager.py
# uv run --directory server python selfcheck_misc_readonly.py
覆盖点:
file_move_batch(10 条 + 分片降级)
file_copy_batch(ondup=fail 与 ondup=newcopy)
file_rename_batch
category_info(category=3, parent_path='/', recursion=1)
image_gettags(type=1)
- 四个列表基础能力(只读):
file_list(dir='/', limit=3)
file_image_list(parent_path='/来自:iPhone', recursion=0, page=1, num=3, order='time', desc=1)
file_doc_list(parent_path='/Openclaw', recursion=1, page=1, num=3, order='time', desc=1)
file_video_list_api(parent_path='/', recursion=1, page=1, num=3, order='time', desc=1)(根目录为空时回退 /来自:iPhone / /Openclaw)
7) Safety defaults
- Never store
access_token in repo files.
- Error messages sanitize
access_token patterns.
delete/file_del rejects by default unless confirm="DELETE".
- Batch move/copy restricts destination by
allow_dest_prefixes(默认 ['/Openclaw'])。
file_move_batch 默认 ondup=fail(不覆盖);file_copy_batch 默认 ondup=newcopy(冲突产出副本,不覆盖)。
file_upload_by_url only allows http(s) and rejects localhost / 内网 / 保留地址;并限制下载大小与超时。
1---2name: baidudisk-mcp3description: Use Baidu Netdisk via mcporter + stdio MCP server with hot-reload token file credentials. Triggers when you need Baidu Netdisk operations (official 2.0 toolset + legacy aliases) from OpenClaw without storing access_token in repo files.4---56# baidudisk-mcp78Use this skill to run Baidu Netdisk tools through `mcporter`.910## 1) Enable server in mcporter1112Run:1314```bash15bash scripts/baidudisk_mcporter.sh register16```1718This writes a `baidudisk` stdio server entry into `config/mcporter.json` with:1920- command: `/home/linuxbrew/.linuxbrew/bin/uv`21- args: `--directory <workspace>/skills/baidudisk-mcp/server run netdisk.py`22- env: `BAIDU_NETDISK_TOKEN_FILE=~/.openclaw/credentials/baidudisk.json`2324Check status:2526```bash27bash scripts/baidudisk_mcporter.sh check28mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json list baidudisk29```3031## 2) Credential file and hot update3233Credential file (local only):3435`~/.openclaw/credentials/baidudisk.json`3637Expected keys:3839- `access_token` (required)40- `default_dir` (recommended)4142Example (do not commit real token):4344```json45{46 "access_token": "<redacted>",47 "default_dir": "/Openclaw/baidudisk"48}49```5051The MCP server reads this file on **every tool call**.52So token rotation only needs editing this file; no server restart is required.5354## 3) 2.0 tools5556### 3.1 Official-aligned tools (主推)5758四个基础列表接口与 MCP tool 对应关系:5960- `/rest/2.0/xpan/file?method=list` → `file_list(dir?, limit?, order?, desc?, start?)`61- `/rest/2.0/xpan/file?method=imagelist` → `file_image_list(parent_path?, recursion?, page?, num?, order?, desc?, web=1)`62- `/rest/2.0/xpan/file?method=doclist` → `file_doc_list(parent_path?, recursion?, page?, num?, order?, desc?)`63- `/rest/2.0/xpan/file?method=videolist` → `file_video_list_api(parent_path?, recursion?, page?, num?, order?, desc?, web=1)`6465另保留一个历史兼容视频工具(非官方 videolist 参数模型):6667- `file_video_list(dir?, recursion?, start?, limit?, order?, desc?)`(基于 `xpanfilelistall` 过滤视频)6869其他工具:7071- `category_info(category, parent_path='/', recursion=1)`72- `category_info_multi(categories, parent_path='/', recursion=1)`73- `image_gettags(type=1)`74- `image_gettags_summary(type=1, top=50)`75- `image_search(search_type, keyword, start=0, limit=100, size?)`76- `recent_list(category=3, start=0, limit=100, sortby?, order?, stime?, etime?, resolution='off')`77- `file_meta(fsids, dlink?, thumb?, extra?, needmedia?, path?)`78- `make_dir(path, parent_dir?)`79- `file_copy(src_path, dest_dir, new_name?, ondup?)`80- `file_copy_batch(items, ondup='newcopy', async_mode=1, chunk_size=100, dry_run=false, allow_dest_prefixes=['/Openclaw'])`81- `file_del(path, confirm)`82- `file_move(src_path, dest_dir, new_name?, ondup?)`83- `file_move_batch(items, ondup='fail', async_mode=1, chunk_size=100, dry_run=false, allow_dest_prefixes=['/Openclaw'])`84- `file_rename(path, new_name)`85- `file_rename_batch(items, async_mode=1, chunk_size=100, dry_run=false)`86- `file_upload_stdio(local_file_path, remote_dir?, remote_name?)`87- `file_upload_by_url(url, remote_dir?, remote_name?, timeout_s?, max_bytes?)`88- `file_upload_by_text(text, remote_dir?, remote_name?, max_chars?, max_bytes?)`89- `file_keyword_search(keyword, dir?, recursion?, num?, page?)`90- `file_semantics_search(...)`(当前 `unsupported` stub)91- `file_sharelink_set(...)`(当前 `unsupported` stub)92- `user_info()`93- `get_quota(checkexpire?, checkfree?)`9495### 3.2 Legacy aliases (兼容保留)9697- `list`98- `search`99- `mkdir`100- `move`101- `rename`102- `delete`103- `upload`104- `download`105106## 4) mcporter examples107108```bash109# 对齐 list:/rest/2.0/xpan/file?method=list110mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_list dir=/ limit=3111112# 对齐 imagelist:/rest/2.0/xpan/file?method=imagelist113mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_image_list parent_path='/来自:iPhone' recursion=0 page=1 num=3 order=time desc=1114115# 对齐 doclist:/rest/2.0/xpan/file?method=doclist116mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_doc_list parent_path='/Openclaw' recursion=1 page=1 num=3 order=time desc=1117118# 对齐 videolist:/rest/2.0/xpan/file?method=videolist119mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_video_list_api parent_path='/' recursion=1 page=1 num=3 order=time desc=1120# 若根目录返回 count=0,可改 parent_path='/来自:iPhone' 或 '/Openclaw'121122# 官方同名:关键词搜索123mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_keyword_search keyword=invoice num=20124125# 分类统计(单分类:图片=3)126mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.category_info category=3 parent_path=/ recursion=1127128# 分类统计(多分类:JSON array)129mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.category_info_multi categories='[1,3,4,6]' parent_path=/ recursion=1130131# 图片智能标签132mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.image_gettags type=1133134# 图片智能标签摘要(按 count 取前 20)135mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.image_gettags_summary type=1 top=20136137# 图片关键字检索(search_type=2 表示汉字)138mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.image_search \139 search_type=2 keyword=截图 limit=20 size='c256_u256,c512_u512'140141# 图片列表(imagelist,默认 web=1 返回缩略图字段)142mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_image_list \143 parent_path='/Openclaw' recursion=1 page=1 num=10 order=time desc=1144145# 按上传时间拉取最近图片146mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.recent_list \147 category=3 limit=20 resolution=off148149# 官方同名:创建目录150mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.make_dir path=reports/2026151152# 批量移动(默认 ondup=fail,不覆盖;dest 限制在 /Openclaw)153mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_move_batch \154 items='[{"src_path":"/Openclaw/inbox/a.txt","dest_dir":"/Openclaw/archive"},{"src_path":"/Openclaw/inbox/b.txt","dest_dir":"/Openclaw/archive"}]' \155 chunk_size=100 async_mode=1156157# 批量复制(显式冲突策略 newcopy:冲突时自动副本,不覆盖原文件)158mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_copy_batch \159 items='[{"src_path":"/Openclaw/inbox/a.txt","dest_dir":"/Openclaw/archive"}]' \160 ondup=newcopy async_mode=1161162# 批量重命名(dry_run 先演练)163mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_rename_batch \164 items='[{"path":"/Openclaw/archive/a.txt","new_name":"a-20260228.txt"}]' \165 dry_run=true166167# 官方同名:本地文件上传168mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_upload_stdio local_file_path=/tmp/demo.txt169170# 官方同名:按 URL 上传(HTTP/HTTPS,带大小/超时限制)171mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_upload_by_url url=https://example.com/demo.txt remote_dir=/Openclaw/baidudisk172173# 官方同名:文本上传174mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.file_upload_by_text text='hello world' remote_name=hello.txt175176# 官方同名:配额177mcporter --config /home/ubuntu/.openclaw/workspace/config/mcporter.json call baidudisk.get_quota178```179180## 5) Batch return envelope(8.2)181182`file_move_batch / file_copy_batch / file_rename_batch` 统一返回:183184- `status`, `tool`, `dry_run`, `async_mode`, `ondup`, `chunk_size`185- `total_items`, `chunks`186- `summary`(`ok_chunks/failed_chunks/ok_items_est/failed_items_est`)187- `results`(每个 chunk:`chunk_index/items/request_preview/response(errno/taskid/info)`)188- `errors`(失败 chunk 的 `chunk_index/message/items_preview`)189190## 6) Minimal self-check(不含 delete)191192> 请不要直接用 `python3`(容易缺 `mcp` 依赖)。193194```bash195cd /home/ubuntu/.openclaw/workspace/skills/baidudisk-mcp196server/.venv/bin/python server/selfcheck_batch_filemanager.py197server/.venv/bin/python server/selfcheck_misc_readonly.py198# 下两项为真实只读联网检查(需要 token)199BAIDU_NETDISK_TOKEN_FILE=~/.openclaw/credentials/baidudisk.json server/.venv/bin/python server/selfcheck_image_recent_readonly.py200BAIDU_NETDISK_TOKEN_FILE=~/.openclaw/credentials/baidudisk.json server/.venv/bin/python server/selfcheck_lists_readonly.py201202# 等价写法(如果你用 uv)203# uv run --directory server python selfcheck_batch_filemanager.py204# uv run --directory server python selfcheck_misc_readonly.py205```206207覆盖点:208209- `file_move_batch`(10 条 + 分片降级)210- `file_copy_batch`(`ondup=fail` 与 `ondup=newcopy`)211- `file_rename_batch`212- `category_info(category=3, parent_path='/', recursion=1)`213- `image_gettags(type=1)`214- 四个列表基础能力(只读):215 - `file_list(dir='/', limit=3)`216 - `file_image_list(parent_path='/来自:iPhone', recursion=0, page=1, num=3, order='time', desc=1)`217 - `file_doc_list(parent_path='/Openclaw', recursion=1, page=1, num=3, order='time', desc=1)`218 - `file_video_list_api(parent_path='/', recursion=1, page=1, num=3, order='time', desc=1)`(根目录为空时回退 `/来自:iPhone` / `/Openclaw`)219220## 7) Safety defaults221222- Never store `access_token` in repo files.223- Error messages sanitize `access_token` patterns.224- `delete/file_del` rejects by default unless `confirm="DELETE"`.225- Batch move/copy restricts destination by `allow_dest_prefixes`(默认 `['/Openclaw']`)。226- `file_move_batch` 默认 `ondup=fail`(不覆盖);`file_copy_batch` 默认 `ondup=newcopy`(冲突产出副本,不覆盖)。227- `file_upload_by_url` only allows `http(s)` and rejects localhost / 内网 / 保留地址;并限制下载大小与超时。