Uses environment variables for configuration management, loading settings from .env files to configure the RustFS connection and server parameters
Supports testing framework integration for running automated tests on the file upload and download functionality
Built as a Python-based MCP server providing file management capabilities through Python asyncio operations
Integrates with Ruff for code quality checking and linting during development
Integrates with RustFS storage service through the RustFS SDK, enabling file upload to RustFS endpoints and retrieval of file information
Uses TOML format for project configuration through pyproject.toml file
FS MCP Server
基于FastMCP构建的文件上传/下载MCP服务,集成RustFS SDK实现AI自动调用文件存储和下载功能。
功能特性
文件上传: 支持上传本地文件到RustFS存储服务
文件下载: 支持从任意HTTP/HTTPS URL下载文件到本地
异步处理: 基于asyncio的异步文件操作
错误处理: 完善的错误处理和异常管理
配置验证: 启动时验证必需的环境变量配置
安装
1. 克隆项目
2. 安装依赖
或安装开发依赖:
3. 配置环境变量
复制环境变量模板并配置:
编辑 .env
文件:
使用方法
启动服务
MCP工具
1. upload_file
上传本地文件到RustFS存储服务。
参数:
file_path
(string): 本地文件的绝对路径
返回值:
2. download_file
从指定URL下载文件到本地路径。
参数:
url
(string): 要下载的文件URLdownload_path
(string): 本地保存路径
返回值:
使用示例
文件上传示例
文件下载示例
错误处理
服务提供详细的错误信息:
常见错误类型
FileNotFoundError
: 文件不存在ValueError
: 参数无效或URL格式错误RuntimeError
: 上传/下载操作失败ConfigurationError
: 环境变量配置错误
错误示例
开发
项目结构
运行测试
代码格式化
配置说明
必需环境变量
FS_URL
: RustFS服务端点URLFS_AK
: RustFS访问密钥FS_SK
: RustFS密钥
可选环境变量
TIMEOUT
: 请求超时时间(秒),默认30
RustFS API要求
本服务假设RustFS提供以下API端点:
POST /api/upload
: 文件上传GET /api/files/{file_id}
: 获取文件信息
上传请求格式:
Method: POST
Content-Type: multipart/form-data
Headers: Authorization: Bearer {access_key}:{secret_key}
Files: file (文件内容)
Data: filename (文件名), size (文件大小)
许可证
MIT License
贡献
欢迎提交Issue和Pull Request来改进这个项目。
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI to upload local files to RustFS storage service and download files from HTTP/HTTPS URLs to local paths. Built with FastMCP and RustFS SDK for seamless file operations through natural language.