canvas3d-mcp

canvas3d-mcp

Enables AI agents to create, render, and validate 3D scenes, 2D art, and games in HTML canvas using Three.js, WebGL, or Canvas 2D, with multi-angle screenshots, structured validation reports, and interactive playtesting.

Category
Visit Server

README

canvas3d-mcp

Servidor MCP que dá a agentes de IA olhos e instrumentos para criar arte e jogos em <canvas> HTML: modelos 3D (Three.js, WebGL puro, Canvas 2D por software), ilustração 2D, UI de jogos, pixel art e jogos 2D/3D jogáveis (com playtest automatizado). Suporta projetos multi-arquivo (a pasta do HTML de entrada é servida inteira).

A IA escreve um arquivo HTML auto-contido; o servidor renderiza em Chromium headless e devolve:

  • render_scene — screenshots multi-ângulo (front/side/top/three-quarter ou ângulos custom, close-up via distance_factor < 1) ou frames sequenciais de animação (animation_frames + frame_interval_ms). A IA passa a ver o que criou e itera.
  • validate_scene — relatório JSON estruturado: erros de página/console, canvas em branco, e (com Three.js registrado) checks profundos do grafo de cena: objetos flutuando, sem luzes, fora do frustum, transform NaN, texturas sem UV, clipping de câmera etc. Para pixel art (window.__pix): ANTI_ALIASING (pixels borrados/fora da grade) e PALETTE_OVERFLOW. Cada issue vem com severidade e sugestão de correção.
  • interact_sceneplaytest: executa um roteiro de inputs (teclas seguradas, cliques, esperas) intercalado com screenshots e leituras de window.__state(), para a IA verificar que o gameplay funciona (player anda? pula? pontua?). Inclui estimativa de FPS.
  • inspect_scene — dump da árvore de cena Three.js com bounding boxes em coordenadas de mundo, para raciocinar sobre posicionamento exato.
  • get_guidelines — guias (workflow, ofício 3D geral, texturização, armadilhas por tecnologia, ilustração 2D + UI de jogos, pixel art).

Bibliotecas de helpers servidas em /__helpers/ para o HTML da IA:

Lib Para Destaques
three-helpers.js Three.js register(), anchor(), mirrorX(), frameCamera(), threePointLights(), applyTexture()
canvas3d.js Canvas 2D mini-engine 3D por software (C3D): primitivas, câmera orbital, flat shading
webgl-helpers.js WebGL puro GLH: shaders prontos, malhas com UVs, mat4, orbitCamera, upload de texturas
texture-helpers.js todas TEX: texturas procedurais (wood, brick, marble, noise, bump...) sem rede
draw2d.js ilustração 2D / UI D2D: camadas com transform, formas/gradientes/sombras, UI de jogos (panel, healthBar, button), ticker de animação
pixel-helpers.js pixel art PIX: grade lógica exibida nítida, paletas retrô (Game Boy, PICO-8, NES...), Bresenham, flood fill, dithering, espelhamento, outline, sprites, animação por frames
game2d.js jogos 2D G2D: loop com timestep fixo, input com edge detection, entidades/tags, colisão AABB, tilemap por strings com moveEntity (física de plataforma), câmera follow/shake, tweens, partículas, cenas
game3d.js jogos 3D G3D: bootstrap de mundo (luzes + registro automático), character controller (WASD+pulo+gravidade), câmera 3ª pessoa, colisores AABB moveAndCollide, raycast pick, spawner

Setup

npm install
npx playwright install chromium

Registrar no Claude Code

# escopo do projeto atual:
claude mcp add canvas3d -- npx tsx "C:\Users\use\Desktop\ESTUDO\3d canvas improve\src\index.ts"

# ou disponível em todos os projetos:
claude mcp add --scope user canvas3d -- npx tsx "$PWD\src\index.ts"


# para confirmar
claude mcp list

Depois peça, por exemplo: "usando as tools do canvas3d, crie um robô 3D em Three.js — leia get_guidelines('workflow') primeiro e itere com render/validate até ficar bom".

O loop que a IA segue

  1. get_guidelines("workflow") → convenções e snippets
  2. escreve o HTML (com helpers, registrando window.__scene ou window.__setView)
  3. render_scene → olha todos os ângulos
  4. validate_scene → corrige errors, depois warnings
  5. repete até imagem + relatório ficarem bons

Desenvolvimento

npm test            # vitest: unit + integração (Playwright real)
npm run typecheck   # tsc --noEmit
npx tsx scripts/smoke-render.ts examples/good-threejs-robot.html   # render direto, salva JPGs
npx tsx scripts/smoke-mcp.ts                                       # smoke da camada MCP via stdio

Estrutura: src/ (servidor MCP + pipeline Playwright + análise), src/probe/injected/ (scripts injetados na página), helpers/ (libs servidas ao HTML), guidelines/ (guias), examples/ (cenas boas + defects/ que disparam cada validador), tests/.

Notas de plataforma (descobertas empiricamente nesta máquina)

  • WebGL headless funciona sem flags (SwiftShader). Override: CANVAS3D_BROWSER_ARGS.
  • O primeiro contexto WebGL criado logo após o launch do browser é perdido (corrida de init do processo GPU). Mitigado por warmup no launch + reload automático da página quando o snapshot detecta contexto perdido.
  • Canvas WebGL "render-once" pode capturar em branco (buffer descartado após present). O probe força preserveDrawingBuffer: true e o servidor chama window.__redraw antes de capturar.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured