AI Workspace MCP Server

Secure workspace for AI-driven file management and Python script execution.

README.md

AI Workspace MCP Server

A Model Context Protocol (MCP) server that provides AI with a secure workspace for file management and Python script execution. Designed to run on Vercel as a serverless function.

Features

File Management Tools

  • create_file - Create new files with content
  • read_file - Read file contents
  • update_file - Update existing files
  • delete_file - Delete files
  • list_files - List files and directories
  • create_directory - Create new directories

Code Execution

  • execute_python - Execute Python scripts with arguments (30-second timeout)

Setup on Vercel

1. Install Vercel CLI (Optional)

npm install -g vercel

2. Project Structure

Your project should look like this:

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

3. Deploy to Vercel

Option A: Deploy via Vercel Dashboard
  1. Go to vercel.com
  2. Click "Add New" → "Project"
  3. Import your Git repository (or upload files)
  4. Vercel will auto-detect Python and deploy
Option B: Deploy via CLI
# Login to Vercel
vercel login

# Deploy
vercel

# Deploy to production
vercel --prod

4. Get Your Deployment URL

After deployment, Vercel will give you a URL like: https://your-project-name.vercel.app

API Endpoints

Once deployed, your server will have these endpoints:

GET /

Returns server information and status

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

GET /health

Health check endpoint

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

GET /tools

List all available tools

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

POST /execute

Execute a tool

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!\")"
    }
  }'

Using with AI Clients

Claude Desktop Configuration

Add this to your Claude Desktop config:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %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", "@-"
      ]
    }
  }
}

Using the API Directly

You can integrate this with any AI that supports HTTP tool calling:

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())

Security Features

  • Sandboxed Workspace: All file operations are restricted to /tmp/workspace
  • Path Validation: Prevents directory traversal attacks
  • Execution Timeout: Python scripts are limited to 30 seconds
  • CORS Enabled: Allows cross-origin requests
  • Serverless Isolation: Each request runs in an isolated environment

Tool Examples

Create and Execute a Python Script

# 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"
    }
  }'

List Files

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

Create Directory Structure

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

Response Format

All tool executions return JSON:

Success Response:

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

Error Response:

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

Execute Python Response:

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

Important Notes

Vercel Limitations

Tools 7

create_fileCreate new files with content
read_fileRead file contents
update_fileUpdate existing files
delete_fileDelete files
list_filesList files and directories
create_directoryCreate new directories
execute_pythonExecute Python scripts with arguments

Try it

Create a new Python script named 'data_processor.py' that prints 'Processing complete'.
List all files in the current workspace directory.
Execute the 'data_processor.py' script and show me the output.
Create a new directory named 'logs' for storing application output.
Read the contents of 'hello.py' to verify its current code.

Frequently Asked Questions

What are the key features of AI Workspace?

Secure sandboxed workspace restricted to /tmp/workspace. Full file management including create, read, update, delete, and list. Python script execution with 30-second timeout. Path validation to prevent directory traversal attacks. Serverless deployment architecture on Vercel.

What can I use AI Workspace for?

Automating file organization and cleanup tasks within a cloud environment. Running isolated Python scripts for data processing or testing. Managing project file structures programmatically via AI. Executing code snippets in a secure, ephemeral serverless environment.

How do I install AI Workspace?

Install AI Workspace by running: vercel

What MCP clients work with AI Workspace?

AI Workspace works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep AI Workspace docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare