Modal卷管理服务器

一个用于在Cursor中管理Modal卷和部署Modal应用的MCP服务器实现。

  • by smehmood
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 smehmood/modal-mcp-server

使用说明

模态MCP服务器

用于与Modal卷交互并从Cursor内部部署Modal应用程序的MCP服务器实现。

安装

  1. 克隆此存储库:
git clone https://github.com/smehmood/modal-mcp-server.git
cd modal-mcp-server
  1. 使用安装依赖项 uv:
uv sync

配置

要在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 包管理器
  • 配置了有效凭据的Modal CLI
  • 对于Modal部署支持:
    • 正在部署的项目必须使用 uv 用于依赖关系管理
    • Modal必须安装在项目的虚拟环境中

支持的工具

模态体积操作

  1. 列出模态体积 (list_modal_volumes)

    • 列出环境中的所有模态卷
    • 返回JSON格式的卷信息
    • 参数:无
  2. 列出卷目录 (list_modal_volume_contents)

    • 列出Modal卷中的文件和目录
    • 参数:
      • volume_name:模态体积的名称
      • path:卷内路径(默认值:“/”)
  3. 复制文件 (copy_modal_volume_files)

    • 复制Modal卷内的文件
    • 参数:
      • volume_name:模态体积的名称
      • paths:最后一条路径为目标的路径列表
    • 例子: ["source.txt", "dest.txt"] 或 ["file1.txt", "file2.txt", "dest_dir/"]
  4. 删除文件 (remove_modal_volume_file)

    • 从Modal卷中删除文件或目录
    • 参数:
      • volume_name:模态体积的名称
      • remote_path:要删除的文件/目录的路径
      • recursive:用于递归删除的布尔标志(默认值:false)
  5. 上传文件 (put_modal_volume_file)

    • 将文件或目录上传到Modal卷
    • 参数:
      • volume_name:模态体积的名称
      • local_path:要上传的本地文件/目录的路径
      • remote_path:要上传到的卷中的路径(默认值:“/”)
      • force:覆盖现有文件的布尔标志(默认值:false)
  6. 下载文件 (get_modal_volume_file)

    • 从Modal卷下载文件
    • 参数:
      • volume_name:模态体积的名称
      • remote_path:要下载的卷中的文件/目录的路径
      • local_destination:保存下载文件的本地路径(默认:当前目录)
      • force:覆盖现有文件的布尔标志(默认值:false)
    • 注:使用“-”作为 local_destination 将文件内容写入stdout

模态部署

  1. 部署Modal应用程序 (deploy_modal_app)
    • 部署Modal应用程序
    • 参数:
      • absolute_path_to_app:模态应用程序文件的绝对路径
    • 注意:包含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
}

贡献

欢迎投稿!请随时提交拉取请求。

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。