模态 MCP 服务器
用于与 Modal 卷交互并从 Cursor 内部部署 Modal 应用程序的 MCP 服务器实现。
安装
- 克隆此存储库:
git clone https://github.com/smehmood/modal-mcp-server.git
cd modal-mcp-server
- 使用
uv
安装依赖项:
配置
要在 Cursor 中使用此 MCP 服务器,请将以下配置添加到您的~/.cursor/mcp.json
:
{
"mcpServers": {
"modal-mcp-server": {
"command": "uv",
"args": [
"--project", "/path/to/modal-mcp-server",
"run", "/path/to/modal-mcp-server/src/modal_mcp/server.py"
]
}
}
}
将/path/to/modal-mcp-server
替换为克隆存储库的绝对路径。
要求
- Python 3.11 或更高版本
uv
包管理器- 使用有效凭证配置的模态 CLI
- 对于模态部署支持:
- 正在部署的项目必须使用
uv
进行依赖管理 - Modal 必须安装在项目的虚拟环境中
支持的工具
模态体积操作
- 列出模态体积(
list_modal_volumes
)- 列出您环境中的所有 Modal 卷
- 返回 JSON 格式的卷信息
- 参数:无
- 列出卷内容(
list_modal_volume_contents
)- 列出 Modal 卷中的文件和目录
- 参数:
volume_name
:Modal卷的名称path
:卷内的路径(默认值:“/”)
- 复制文件(
copy_modal_volume_files
)- 复制 Modal 卷内的文件
- 参数:
volume_name
:Modal卷的名称paths
:最后一条路径为目的地的路径列表
- 例如:
["source.txt", "dest.txt"]
或["file1.txt", "file2.txt", "dest_dir/"]
- 删除文件(
remove_modal_volume_file
)- 从 Modal 卷中删除文件或目录
- 参数:
volume_name
:Modal卷的名称remote_path
:要删除的文件/目录的路径recursive
:递归删除的布尔标志(默认值:false)
- 上传文件(
put_modal_volume_file
)- 将文件或目录上传到 Modal 卷
- 参数:
volume_name
:Modal卷的名称local_path
:要上传的本地文件/目录的路径remote_path
:要上传到的卷路径(默认值:“/”)force
:布尔标志,用于覆盖现有文件(默认值:false)
- 下载文件(
get_modal_volume_file
)- 从 Modal 卷下载文件
- 参数:
volume_name
:Modal卷的名称remote_path
:要下载的卷中的文件/目录的路径local_destination
:保存下载文件的本地路径(默认值:当前目录)force
:布尔标志,用于覆盖现有文件(默认值:false)
- 注意:使用“-”作为
local_destination
将文件内容写入 stdout
模态部署
- 部署模态应用程序(
deploy_modal_app
)- 部署一个 Modal 应用程序
- 参数:
absolute_path_to_app
:Modal 应用程序文件的绝对路径
- 注意:包含 Modal 应用的项目必须:
- 使用
uv
进行依赖管理 - 在其虚拟环境中安装
modal
CLI
响应格式
所有工具都以标准化格式返回响应,但根据操作类型的不同略有不同:
# JSON operations (list volumes, list contents):
{
"success": True,
"data": {...} # JSON data from Modal CLI
}
# File operations (put, get, copy, remove):
{
"success": True,
"message": "Operation successful message",
"command": "executed command string",
"stdout": "command output", # if any
"stderr": "error output" # if any
}
# Error case (all operations):
{
"success": False,
"error": "Error message describing what went wrong",
"command": "executed command string", # for file operations
"stdout": "command output", # if available
"stderr": "error output" # if available
}
贡献
欢迎贡献代码!欢迎提交 Pull 请求。
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。