百度网盘 MCP Server - 通过 Model Context Protocol 提供百度网盘文件上传功能
Project description
Baidu Netdisk MCP Server (Python)
一个通过 Model Context Protocol (MCP) 提供百度网盘文件上传功能的服务器。
特性
- 支持小文件直接上传
- 支持大文件自动分片上传(>4MB)
- 内置重试机制和错误处理
- 通过 MCP 协议与 AI 助手集成
安装
方式一:通过 pip 安装(推荐)
pip install netdisk-mcp-server
方式二:从源码安装
git clone https://github.com/yourusername/netdisk-mcp-server-stdio.git
cd netdisk-mcp-server-stdio
pip install -e .
配置
获取百度网盘 Access Token
- 访问百度开放平台创建应用
- 获取 Access Token
- 设置环境变量:
BAIDU_NETDISK_ACCESS_TOKEN
使用方法
方式一:命令行直接运行
export BAIDU_NETDISK_ACCESS_TOKEN="your_access_token"
netdisk-mcp-server
方式二:搭建 Python 虚拟环境
我们推荐通过uv构建虚拟环境来运行MCP server,关于uv你可以在这里找到一些说明。
按照官方流程,你会安装Python包管理工具uv。除此之外,你也可以尝试其他方法(如Anaconda)来创建你的Python虚拟环境。
在Cursor中使用
打开Cursor配置,在MCP中添加MCP Server
在文件中添加如下内容后保存
配置方式一:使用已安装的包
{
"mcpServers": {
"baidu-netdisk": {
"command": "netdisk-mcp-server",
"env": {
"BAIDU_NETDISK_ACCESS_TOKEN": "<YOUR_ACCESS_TOKEN>"
}
}
}
}
配置方式二:使用 uv 运行
{
"mcpServers": {
"baidu-netdisk-local-uploader": {
"command": "uv的绝对路径,通过which uv命令获取,如/Users/netdisk/.local/bin/uv",
"args": [
"--directory",
"netdisk.py所在的父目录绝对路径,如/Users/netdisk/mcp/netdisk-mcp-server-stdio",
"run",
"netdisk.py"
],
"env": {
"BAIDU_NETDISK_ACCESS_TOKEN": "<YOUR_ACCESS_TOKEN>"
}
}
}
}
回到配置,此时百度网盘MCP Server已经启用
测试
上传文件到网盘测试用例
API 说明
upload_file
上传本地文件到百度网盘
参数:
local_file_path(str): 本地文件路径remote_path(str, 可选): 网盘存储路径,必须以/开头。如不指定,将默认上传到/来自:mcp_server目录下
返回:
status: 上传状态(success/error)message: 状态消息filename: 文件名size: 文件大小remote_path: 远程路径fs_id: 文件系统 ID
开发
构建项目
# 安装开发依赖
pip install build twine
# 构建包
python -m build
# 检查构建结果
twine check dist/*
发布到 PyPI
# 发布到测试 PyPI
twine upload --repository testpypi dist/*
# 发布到正式 PyPI
twine upload dist/*
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netdisk_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: netdisk_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 47.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de9f3b782e38731cde6ff5e217636436e8c05354d7f14ae955a3c7a07e68bf34
|
|
| MD5 |
70c5589a5bb85cac52c49d440f769cad
|
|
| BLAKE2b-256 |
c2a967924be7f536d3ea4fd75c40e5056179bf4f682ed1c8651a81ee58169c1e
|
File details
Details for the file netdisk_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: netdisk_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 69.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f78eac8a44f6bb4363597944c8ac848e2ffbee348cbd19d0de6fa063d70293e
|
|
| MD5 |
ff0c9ed67359d829dd1296a0b35c9504
|
|
| BLAKE2b-256 |
f6e2a76800bc40599c40a32c34dc17080fade3cc0284f5abd4c167f15d0aa2b6
|