Visual Loop MCP Server
Enables AI clients to write, run, and visually render code in a single loop, combining secure execution via Judge0/Codebox with Playwright screenshots.
README
<div align="center">
<!-- Animated Header Banner --> <img src="https://capsule-render.vercel.app/api?type=waving&color=0:6C63FF,50:A855F7,100:EC4899&height=220§ion=header&text=Visual%20Loop%20MCP&fontSize=50&fontColor=FFFFFF&fontAlignY=35&desc=Execute%20%E2%80%A2%20Render%20%E2%80%A2%20Verify&descSize=20&descAlignY=55&animation=fadeIn" width="100%" alt="Visual Loop MCP Header"/>
<br/>
<br/>
<p align="center"> <strong>A production-ready MCP server that combines <em>secure code execution</em> with <em>visual rendering</em> — giving multimodal AI clients the power to write, run, and <em>see</em> code in one seamless loop.</strong> </p>
<br/>
🚀 Quick Start • 📖 Documentation • 🔧 Configuration • 🤖 Claude Desktop • 📡 API Reference
<br/>
</div>
✨ Why Visual Loop?
Most AI coding assistants can write code — but they can't see the result. Visual Loop MCP closes that gap by providing a single tool that:
<table> <tr> <td width="60" align="center">⚡</td> <td><strong>Executes code securely</strong> via Judge0/Codebox sandboxed runtime</td> </tr> <tr> <td align="center">🖼️</td> <td><strong>Renders visual output</strong> using Playwright headless Chromium</td> </tr> <tr> <td align="center">📸</td> <td><strong>Returns screenshots</strong> alongside console output in a single multimodal response</td> </tr> <tr> <td align="center">🔄</td> <td><strong>Enables iterative UI development</strong> — AI sees its own output and self-corrects</td> </tr> </table>
[!TIP] Think of it as giving your AI eyes — it can now verify layouts, catch visual bugs, and iterate on designs without human intervention.
🏗️ Architecture
┌──────────────────────────────┐
│ AI Client │
│ (Claude Desktop / Cursor) │
└──────────────┬───────────────┘
│
stdio (JSON-RPC 2.0)
│
┌──────────────▼───────────────┐
│ Visual Loop MCP Server │
│ │
│ ┌───────────────────────┐ │
│ │ Phase A: Execute │ │ ┌──────────────────┐
│ │ Code Validation │───┼────▶│ Judge0/Codebox │
│ │ │ │ │ (Sandboxed API) │
│ └───────────────────────┘ │ └──────────────────┘
│ │
│ ┌───────────────────────┐ │
│ │ Phase B: Render │ │ ┌──────────────────┐
│ │ Visual Screenshot │───┼────▶│ Playwright │
│ │ │ │ │ (Headless Chrome) │
│ └───────────────────────┘ │ └──────────────────┘
│ │
│ ┌───────────────────────┐ │
│ │ Phase C: Cleanup │ │ Temp files removed
│ │ Resource Disposal │ │ Browser closed
│ └───────────────────────┘ │
│ │
└───────────────────────────────┘
<div align="center">
graph LR
A[🤖 AI Client] -->|stdio JSON-RPC| B[🔄 Visual Loop MCP]
B -->|POST /submissions| C[⚡ Judge0 Codebox]
B -->|file:// render| D[🌐 Playwright]
C -->|stdout / stderr| B
D -->|base64 PNG| B
B -->|multimodal response| A
style A fill:#6C63FF,stroke:#4F46E5,color:#fff,stroke-width:2px
style B fill:#A855F7,stroke:#9333EA,color:#fff,stroke-width:2px
style C fill:#F59E0B,stroke:#D97706,color:#fff,stroke-width:2px
style D fill:#10B981,stroke:#059669,color:#fff,stroke-width:2px
</div>
📦 Prerequisites
| Requirement | Version | Purpose |
|---|---|---|
| <img src="https://img.shields.io/badge/-Node.js-339933?logo=node.js&logoColor=white&style=flat-square" /> | ≥ 20.0 |
Runtime environment |
| <img src="https://img.shields.io/badge/-npm-CB3837?logo=npm&logoColor=white&style=flat-square" /> | ≥ 10.0 |
Package management |
| <img src="https://img.shields.io/badge/-Docker-2496ED?logo=docker&logoColor=white&style=flat-square" /> | Any | Judge0 container hosting |
🚀 Quick Start
1️⃣ Start the Judge0 Sandbox
# Pull and run Judge0 CE in Docker
docker run -d -p 2358:2358 --name judge0 judge0/judge0-ce
2️⃣ Install & Build
# Clone the repository
git clone https://github.com/IqbalHere/-Visual-Loop-MCP-Server.git
cd -Visual-Loop-MCP-Server
# Install dependencies
npm install
# Install Playwright Chromium (minimal footprint)
npx playwright install chromium
# Build the TypeScript project
npm run build
3️⃣ Run the Server
<details> <summary><strong>🐧 macOS / Linux</strong></summary>
CODEBOX_URL=http://localhost:2358 CODEBOX_TOKEN=your_token npm start
</details>
<details> <summary><strong>🪟 Windows (PowerShell)</strong></summary>
$env:CODEBOX_URL = "http://localhost:2358"
$env:CODEBOX_TOKEN = "your_token"
npm start
</details>
🔧 Configuration
| Variable | Required | Description |
|---|---|---|
CODEBOX_URL |
✅ | Base URL of your Judge0/Codebox instance |
CODEBOX_TOKEN |
❌ | Auth token for the Codebox API (omit if no auth) |
[!NOTE] If
CODEBOX_URLis unset, the server gracefully skips code execution and only performs visual rendering. No crash, no fuss.
🤖 Claude Desktop Integration
Add this to your Claude Desktop configuration file:
| Platform | Config Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
{
"mcpServers": {
"visual-loop": {
"command": "node",
"args": ["C:/absolute/path/to/visual-loop-mcp/build/index.js"],
"env": {
"CODEBOX_URL": "http://localhost:2358",
"CODEBOX_TOKEN": "your_token_here" // optional
}
}
}
}
[!IMPORTANT] Replace the path in
argswith the absolute path to your cloned project. Use forward slashes (/) even on Windows.
After saving, restart Claude Desktop. The execute_and_render tool will appear in the tool picker. 🎉
📡 Tool Reference
execute_and_render
The single, powerful tool exposed by this server.
AI writes code → Codebox validates logic → Playwright renders visuals → AI sees the result
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
source_code |
string |
✅ | — | Raw HTML/CSS/JS source code to execute and render |
language_id |
number |
✅ | — | Judge0 language ID (see table below) |
viewport_width |
number |
❌ | 1280 |
Browser viewport width in pixels |
viewport_height |
number |
❌ | 720 |
Browser viewport height in pixels |
Response Format
The tool returns a multimodal MCP content array containing both text and image:
{
"content": [
{
"type": "text",
"text": "[Codebox] Status: Accepted (id: 3)\n── stdout ──\nHello, world!\n\nExecution time: 0.012s | Memory: 3456 KB"
},
{
"type": "image",
"data": "<base64-encoded-PNG-screenshot>",
"mimeType": "image/png"
}
]
}
🗂️ Supported Languages
| Language | ID | Language | ID |
|---|---|---|---|
| 🟨 JavaScript (Node.js) | 63 |
🐍 Python 3 | 71 |
| 🔷 TypeScript | 74 |
☕ Java | 62 |
| ⚙️ C++ (GCC) | 54 |
💎 Ruby | 72 |
| 🐹 Go | 60 |
🌐 HTML/CSS | 82 |
[!TIP] For a complete list of 60+ supported languages, query your Judge0 instance:
GET /languages
🛡️ Error Handling
The server is engineered to never crash from tool-level errors. Every failure is caught and returned gracefully:
| Scenario | Behavior |
|---|---|
| 🔌 Codebox timeout / network error | Error details in text response; screenshot still attempted |
| 🖥️ Playwright crash | Codebox results returned with rendering error note |
| 💥 Both fail | Descriptive error text returned; no image block |
⚠️ Missing CODEBOX_URL |
Codebox phase skipped with warning; rendering proceeds |
🧰 Development
# Build and run in one step
npm run dev
# Watch mode with tsx (great for iterating)
npx tsx watch src/index.ts
Project Structure
visual-loop-mcp/
├── 📄 src/
│ └── index.ts # Main server — Codebox + Playwright + MCP
├── 📁 build/ # Compiled JavaScript output
├── 📦 package.json # Dependencies & scripts
├── ⚙️ tsconfig.json # TypeScript configuration
└── 📖 README.md # You are here!
🛠️ Tech Stack
<div align="center">
| Technology | Role |
|---|---|
| <img src="https://img.shields.io/badge/-TypeScript-3178C6?logo=typescript&logoColor=white&style=for-the-badge" height="28" /> | Core language with strict type safety |
| <img src="https://img.shields.io/badge/-MCP%20SDK-6C63FF?style=for-the-badge" height="28" /> | Model Context Protocol server framework |
| <img src="https://img.shields.io/badge/-Playwright-2EAD33?logo=playwright&logoColor=white&style=for-the-badge" height="28" /> | Headless browser automation & screenshots |
| <img src="https://img.shields.io/badge/-Judge0-E34F26?style=for-the-badge" height="28" /> | Sandboxed multi-language code execution |
| <img src="https://img.shields.io/badge/-Axios-5A29E4?logo=axios&logoColor=white&style=for-the-badge" height="28" /> | HTTP client for Codebox API |
| <img src="https://img.shields.io/badge/-Zod-3E67B1?logo=zod&logoColor=white&style=for-the-badge" height="28" /> | Runtime schema validation |
</div>
🤝 Contributing
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License — see the LICENSE file for details.
<div align="center">
<img src="https://capsule-render.vercel.app/api?type=waving&color=0:6C63FF,50:A855F7,100:EC4899&height=120§ion=footer&animation=fadeIn" width="100%" alt="Footer"/>
<br/>
Built with ❤️ by Iqbal
<br/>
<a href="https://github.com/IqbalHere/-Visual-Loop-MCP-Server/stargazers"> <img src="https://img.shields.io/github/stars/IqbalHere/-Visual-Loop-MCP-Server?style=social" alt="GitHub Stars" /> </a> <a href="https://github.com/IqbalHere/-Visual-Loop-MCP-Server/network/members"> <img src="https://img.shields.io/github/forks/IqbalHere/-Visual-Loop-MCP-Server?style=social" alt="GitHub Forks" /> </a> <a href="https://github.com/IqbalHere/-Visual-Loop-MCP-Server/issues"> <img src="https://img.shields.io/github/issues/IqbalHere/-Visual-Loop-MCP-Server?style=social" alt="GitHub Issues" /> </a>
<br/><br/>
⭐ Star this repo if you found it useful! ⭐
</div>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。