Token导航 LogoToken导航TokenDH.com
AI Workspace MCP Server logo
运维云端stdio官方级别未说明来源级核验

AI Workspace MCP Server

MCP Server

一个提供AI安全文件管理和Python脚本执行的服务器,支持在Vercel上作为无服务器功能运行。

工具数

7

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude云端部署Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

A-Proof

提供方

A-Proof

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt

详细介绍

AI工作区MCP服务器

一种模型上下文协议(MCP)服务器,为AI提供了一个用于文件管理和Python脚本执行的安全工作区。设计为在Vercel上作为无服务器功能运行。

特性

文件管理工具

  • 创建文件 -创建包含内容的新文件
  • read_file -读取文件内容
  • update_file -更新现有文件
  • 删除文件 -删除文件
  • 列表文件 -列出文件和目录
  • create_directory -创建新目录

代码执行

  • execute_python -执行带参数的Python脚本(超时30秒)

Vercel上的设置

1.安装Vercel CLI(可选)

npm install -g vercel

2.项目结构

你的项目应该是这样的:

ai-workspace-mcp/
├── api/
│   └── mcp.py          # Serverless function
├── vercel.json         # Vercel configuration
├── requirements.txt    # Python dependencies
└── README.md          # This file

3.部署到Vercel

选项A:通过Vercel仪表板进行部署

  1. 首选 vercel.com
  2. 点击“添加新”→ “项目”
  3. 导入Git仓库(或上传文件)
  4. Vercel将自动检测Python并部署

选项B:通过CLI部署

# Login to Vercel
vercel login

# Deploy
vercel

# Deploy to production
vercel --prod

4.获取您的部署URL

部署后,Vercel将为您提供一个URL,如下所示: https://your-project-name.vercel.app

API终点

部署后,您的服务器将具有以下端点:

得到/

返回服务器信息和状态

curl https://your-project.vercel.app/

GET/健康

健康检查端点

curl https://your-project.vercel.app/health

GET/工具

列出所有可用工具

curl https://your-project.vercel.app/tools

POST/执行

执行工具

curl -X POST https://your-project.vercel.app/execute \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "create_file",
    "arguments": {
      "filepath": "hello.py",
      "content": "print(\"Hello World!\")"
    }
  }'

与AI客户端一起使用

Claude桌面配置

将此添加到您的Claude Desktop配置中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 视窗: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "ai-workspace": {
      "command": "curl",
      "args": [
        "-X", "POST",
        "https://your-project.vercel.app/execute",
        "-H", "Content-Type: application/json",
        "-d", "@-"
      ]
    }
  }
}

直接使用API

您可以将其与任何支持HTTP工具调用的AI集成:

import requests

# Create a file
response = requests.post(
    "https://your-project.vercel.app/execute",
    json={
        "tool": "create_file",
        "arguments": {
            "filepath": "script.py",
            "content": "print('Hello from AI!')"
        }
    }
)
print(response.json())

# Execute the file
response = requests.post(
    "https://your-project.vercel.app/execute",
    json={
        "tool": "execute_python",
        "arguments": {
            "filepath": "script.py"
        }
    }
)
print(response.json())

安全功能

  • 沙盒工作区:所有文件操作仅限于 /tmp/workspace
  • 路径验证:防止目录遍历攻击
  • 执行超时:Python脚本限制为30秒
  • CORS已启用:允许跨源请求
  • 无服务器隔离:每个请求都在隔离的环境中运行

工具示例

创建并执行Python脚本

# Create a file
curl -X POST https://your-project.vercel.app/execute \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "create_file",
    "arguments": {
      "filepath": "hello.py",
      "content": "print(\"Hello from Vercel!\")"
    }
  }'

# Execute it
curl -X POST https://your-project.vercel.app/execute \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "execute_python",
    "arguments": {
      "filepath": "hello.py"
    }
  }'

列出文件

curl -X POST https://your-project.vercel.app/execute \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "list_files",
    "arguments": {}
  }'

创建目录结构

curl -X POST https://your-project.vercel.app/execute \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "create_directory",
    "arguments": {
      "dirpath": "scripts"
    }
  }'

响应格式

所有工具执行都返回JSON:

成功响应:

{
  "success": true,
  "message": "Successfully created file: hello.py\nSize: 26 bytes"
}

错误响应:

{
  "success": false,
  "error": "File not found: nonexistent.py"
}

执行Python响应:

{
  "success": true,
  "exit_code": 0,
  "stdout": "Hello from Vercel!\n",
  "stderr": ""
}

重要说明

Vercel限制

  • 临时存储:文件在 /tmp 是短暂的,在调用之间清除
  • 10秒超时:免费版Vercel功能在10秒后超时(专业版为25秒)
  • 冷启动:由于冷启动,第一次请求可能会变慢
  • 无持久状态:每次函数调用都会重新开始

用于持久存储

如果您需要持久文件存储,请考虑:

  1. 使用Vercel KV、Postgres或Blob存储
  2. 与AWS S3、谷歌云存储等集成。
  3. 使用数据库存储文件内容

环境变量(可选)

您可以在Vercel仪表板中设置环境变量:

  • WORKSPACE_PATH -自定义工作区路径(默认: /tmp/workspace)
  • EXECUTION_TIMEOUT -Python执行超时(秒)(默认值:30)

本地开发

部署前进行本地测试:

# Install dependencies
pip install -r requirements.txt

# Run with Python's built-in server
cd api
python -m http.server 8000

# Or use Vercel CLI
vercel dev

然后用以下方法进行测试:

curl http://localhost:8000/health

故障排除

“找不到模块”错误

确保 requirements.txt 位于项目根目录中,包含所有依赖项。

超时错误

  • 降低Python脚本的复杂性
  • 升级到Vercel Pro以获得更长的超时时间
  • 尽可能使用异步操作

文件未持久化

记得: /tmp Vercel上的存储是短暂的。文件在调用之间不会持久。

高级用法

自定义MCP客户端

class VercelMCPClient:
    def __init__(self, base_url):
        self.base_url = base_url
    
    def call_tool(self, tool_name, arguments):
        response = requests.post(
            f"{self.base_url}/execute",
            json={"tool": tool_name, "arguments": arguments}
        )
        return response.json()
    
    def list_tools(self):
        response = requests.get(f"{self.base_url}/tools")
        return response.json()

# Usage
client = VercelMCPClient("https://your-project.vercel.app")
result = client.call_tool("create_file", {
    "filepath": "test.py",
    "content": "print('test')"
})

贡献

请随时使用其他工具扩展此服务器:

  1. 将工具定义添加到 get_tools()
  2. 在中实现处理程序 execute_tool()
  3. 更新文档

许可证

MIT许可证-根据需要进行修改和使用。

支持

目录标签

目录标签

PythonClaude云端部署文件管理本地部署Python脚本执行无服务器功能AI工作区

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

session

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

7

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiosessionremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP