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!
Metadata
Release files for netdisk-mcp-server 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| netdisk_mcp_server-0.1.0.tar.gz | 47.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| netdisk_mcp_server-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 116.9 kB
Release files / netdisk_mcp_server-0.1.0.tar.gz
| Download URL | netdisk_mcp_server-0.1.0.tar.gz |
|---|---|
| Size | 47.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de9f3b782e38731cde6ff5e217636436e8c05354d7f14ae955a3c7a07e68bf34
|
|
BLAKE2b-256 checksum How to use checksums |
c2a967924be7f536d3ea4fd75c40e5056179bf4f682ed1c8651a81ee58169c1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.5
|
Release files / netdisk_mcp_server-0.1.0-py3-none-any.whl
| Download URL | netdisk_mcp_server-0.1.0-py3-none-any.whl |
|---|---|
| Size | 69.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f78eac8a44f6bb4363597944c8ac848e2ffbee348cbd19d0de6fa063d70293e
|
|
BLAKE2b-256 checksum How to use checksums |
f6e2a76800bc40599c40a32c34dc17080fade3cc0284f5abd4c167f15d0aa2b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.5
|
Security for netdisk-mcp-server 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.