File Downloader MCP Server
一个简单而强大的文件下载MCP(Model Context Protocol)服务器,支持从URL下载文件到指定目录并自定义文件名。
功能特性
- 🌐 支持HTTP/HTTPS URL下载
- 📁 自定义保存目录
- 📝 自定义文件名
- 🔄 自动创建目录
- 📊 显示下载进度和文件信息
- 🛡️ 错误处理和重试机制
- 📋 自动文件类型检测
- 🔒 文件名冲突处理
安装
使用uv(推荐)
# 克隆或创建项目
cd file-downloader-mcp
# 安装依赖
uv sync
# 运行服务器
uv run file-downloader-mcp
开发模式
# 开发模式运行(支持热重载)
uv run python -m file_downloader_mcp.server
# 或者直接运行
uv run src/file_downloader_mcp/server.py
MCP客户端配置
Claude Desktop配置
在Claude Desktop的配置文件中添加:
{
"mcpServers": {
"file-downloader": {
"command": "uv",
"args": ["run", "file-downloader-mcp"],
"cwd": "/path/to/file-downloader-mcp"
}
}
}
Cursor IDE配置
在.cursor/mcp.json中添加:
{
"mcpServers": {
"file-downloader": {
"command": "uv",
"args": ["run", "file-downloader-mcp"],
"cwd": "/path/to/file-downloader-mcp"
}
}
}
使用方法
工具:download_file
下载文件的主要工具,支持以下参数:
参数
url(必需): 要下载的文件URLsave_path(可选): 保存目录路径,默认为./downloadsfilename(可选): 自定义文件名,默认从URL提取
使用示例
- 基本下载
{
"url": "https://example.com/image.jpg"
}
- 指定保存目录
{
"url": "https://example.com/document.pdf",
"save_path": "/Users/username/Downloads"
}
- 自定义文件名
{
"url": "https://example.com/file.zip",
"save_path": "./my_files",
"filename": "custom_name.zip"
}
- 完整参数示例
{
"url": "https://github.com/user/repo/archive/main.zip",
"save_path": "./projects",
"filename": "repo_backup.zip"
}
特性说明
自动文件类型检测
服务器会根据HTTP响应的Content-Type自动为文件添加合适的扩展名:
image/jpeg→.jpgimage/png→.pngapplication/pdf→.pdfapplication/zip→.zip- 等等...
文件名冲突处理
如果目标文件已存在,会自动添加数字后缀:
file.txt→file_1.txtimage.jpg→image_1.jpg
错误处理
- 网络错误自动重试
- 无效URL检测
- 权限错误提示
- HTTP状态码错误处理
开发
项目结构
file-downloader-mcp/
├── pyproject.toml # 项目配置
├── README.md # 说明文档
├── src/
│ └── file_downloader_mcp/
│ ├── __init__.py # 包初始化
│ └── server.py # 主服务器代码
└── tests/ # 测试文件(可选)
运行测试
uv run pytest
代码格式化
uv run ruff format .
uv run ruff check .
许可证
MIT License
Metadata
Release files for file-downloader-mcp 0.1.1
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 | Actions |
|---|---|---|---|---|
| file_downloader_mcp-0.1.1.tar.gz | 4.2 kB | Without provenance | Details for file_downloader_mcp-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| file_downloader_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for file_downloader_mcp-0.1.1-py3-none-any.whl |
Total release size: 9.3 kB
Release files / file_downloader_mcp-0.1.1.tar.gz
| Download URL | file_downloader_mcp-0.1.1.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b23b84d6545d2a2646691d18ac6c27666ff40ef3ea197736b99362c1a71c884
|
|
BLAKE2b-256 checksum How to use checksums |
cf96ec005700c0ff5ab5c77ce13a58ff4f2df3134c28859d9c66d0ae7acf9e41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.4
|
Release files / file_downloader_mcp-0.1.1-py3-none-any.whl
| Download URL | file_downloader_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92e37e927f9ce5655c9be4028215ad5437ee80cb34d52b25d3ece5485e085ed4
|
|
BLAKE2b-256 checksum How to use checksums |
cb715a4d6cb032c1a4d49d9b653cfb995fb61c17801fcff354ce87272d996029
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.4
|
Security for file-downloader-mcp 0.1.1
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.