A simple MCP server for downloading files from URLs
Project description
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
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 file_downloader_mcp-0.1.1.tar.gz.
File metadata
- Download URL: file_downloader_mcp-0.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b23b84d6545d2a2646691d18ac6c27666ff40ef3ea197736b99362c1a71c884
|
|
| MD5 |
70ca75f7d94444d92c405c0a2e1bc9eb
|
|
| BLAKE2b-256 |
cf96ec005700c0ff5ab5c77ce13a58ff4f2df3134c28859d9c66d0ae7acf9e41
|
File details
Details for the file file_downloader_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: file_downloader_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e37e927f9ce5655c9be4028215ad5437ee80cb34d52b25d3ece5485e085ed4
|
|
| MD5 |
7e86529993880e2ddea7e2cf50eb4bec
|
|
| BLAKE2b-256 |
cb715a4d6cb032c1a4d49d9b653cfb995fb61c17801fcff354ce87272d996029
|