Skip to content

Turn your ideas into instant, AI-generated diagrams and sketches with the power of MCP.

Notifications You must be signed in to change notification settings

Arsenic-01/Prompt2Sketch

Repository files navigation

🧠 Prompt2Sketch: AI-Driven Diagram Playground with MCP & Tldraw

An experimental sandbox integrating Tldraw and the Model Context Protocol (MCP), enabling AI agents and developers to generate, update, and interact with visual diagrams programmatically — all from natural language or logic-based prompts.


Banner Picture

✨ Project Highlights

  • 🤖 Unrestricted AI Generation: No API limits or quotas — generate infinite diagrams with local agents.
  • ✍️ Tldraw Canvas Integration: Beautiful, intuitive canvas backed by a battle-tested open-source drawing library.
  • ⚖️ Protocol-Driven: Built on a robust API/WebSocket interface compatible with any MCP-compliant client.
  • 📈 Offline-First Architecture: Everything runs locally. Perfect for private setups using Ollama, local LLMs, or experiments.
  • ⚖️ Type-Safe from End to End: Zod-based schemas and strict TypeScript tooling make development smooth.
  • 🧰 Built for Exploration: Easily extend with new shapes, tools, and AI workflows. Ideal for R&D, agent devs, and tinkerers.

📅 Table of Contents


📆 Overview

Prompt2Sketch is a developer-first playground for experimenting with AI-enhanced diagramming. It combines the flexibility of Tldraw with the power of MCP to enable real-time, programmable, and text-controlled diagram generation.

Think of it as Excalidraw without limits — no paywalls, no request caps, and full control over how your diagrams are generated. Build flows from prompts, code, or AI agents. Ideal for tinkering, building dev tools, or LLM integrations.

⚠️ Real-time multi-user collaboration is not supported yet. Local-first only.


🧱 Architecture

Architecture Diagram

  • Frontend: Next.js 15 with App Router and Tldraw canvas
  • Backend: Node.js MCP server using WebSockets and HTTP
  • Typing: End-to-end with Zod + TypeScript
  • Sync: Real-time (local), single-user only

⚙️ Getting Started

✅ Prerequisites

  • Node.js >= 18
  • npm (or yarn/pnpm/bun)

📦 Installation

git clone https://github.com/Arsenic-01/mcp_tldraw.git
cd mcp_tldraw
npm install

🔍 Sample .env

# Next.js Application Configuration
NEXTJS_SERVER_URL=http://localhost:3000
PORT=3000

# MCP Server Configuration
ENABLE_CANVAS_SYNC=true
MCP_TRANSPORT_MODE=stdio

# Development Configuration
NODE_ENV=development
DEBUG=false

NEXT_PUBLIC_WS_URL=ws://localhost:4000
WS_PORT=4000
WS_SERVER_URL=http://localhost:4000

📂 MCP Client Config.json

{
  "mcpServers": {
    "tldraw-canvas": {
      "command": "tsx",
      "args": ["/absolute/path/to/mcp_tldraw/src/mcp-server.ts"],
      "env": {
        "NEXTJS_SERVER_URL": "http://localhost:3000",
        "ENABLE_CANVAS_SYNC": "true"
      }
    }
  }
}

🚀 Running Locally

npm run canvas

🚪 Development Scripts

Script Description
npm run dev Start Next.js frontend
npm run dev:ws Start MCP WebSocket server
npm run mcp-server Run MCP server standalone

💻 Usage

  • Launch the frontend and draw manually using Tldraw
  • Connect an MCP client (e.g. LLM or CLI) to generate or edit shapes
  • Hit broadcast/status endpoints to simulate interactions
  • Extend to new workflows with custom shapes, commands, or drawing logic

🛠️ Tech Stack


🤝 Contributing

Contributions are welcome! Please open issues or submit PRs.

  1. Fork the repo
  2. Create a branch (git checkout -b feature/your-feature)
  3. Commit (git commit -m 'Add feature')
  4. Push (git push origin feature/your-feature)
  5. Open a PR

📄 License

MIT License


📬 Contact


🧪 Disclaimer

This is an experimental, local-first project. Multi-user collaboration and production readiness are not supported (yet).

Let your AI draw. Let your code paint. Welcome to Prompt2Sketch.

About

Turn your ideas into instant, AI-generated diagrams and sketches with the power of MCP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published