Skip to main content
Glama

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_scene — playtest: 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

Related MCP server: 3d-eyes

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.

Available Tools

5 tools
get_guidelinesGet 3D modeling guidelines and helper library docsA

Returns curated guides for building good 3D canvas scenes. Call topic 'workflow' BEFORE writing your first scene — it explains the write→render→validate loop, the helper libraries served at /__helpers/, and the conventions (window.__scene / __setView / __ready) that unlock multi-angle screenshots and deep validation.

Inputs: topic (required).

inspect_sceneDump the Three.js scene graph with world-space dataA

Returns the scene tree (names, types, positions, rotations, world bounding boxes, geometry and material info) for a scene that registers window.__scene. Use it to reason about EXACT placement and sizes when fixing issues reported by validate_scene (e.g. which Y puts the hat on the head). Three.js only.

Inputs: file_path (required), max_depth, filter, width, +4 more.

interact_scenePlaytest a game: send inputs and watch what happensA

Loads a game HTML file and executes a script of inputs (key presses/holds, clicks, waits) interleaved with screenshots and state reads, so you can VERIFY the gameplay you wrote actually works: does the player move, jump, collide, score? Games should expose window.__state = () => ({...}) for read_state assertions. Always playtest after building or changing game mechanics — a game that renders is not a game that plays.

Inputs: file_path (required), script (required), format, width, +4 more.

render_sceneRender a 3D canvas scene and see it from multiple anglesA

Renders an HTML file containing a 3D scene (Three.js, raw WebGL or Canvas 2D) in a headless browser and returns screenshots from multiple camera angles, so you can SEE what you built. ALWAYS call this after writing or editing scene HTML, look hard at every angle, fix problems and render again. Multi-angle needs window.__scene (Three.js) or window.__setView (other tech) — call get_guidelines topic 'workflow' first if unsure. Use distance_factor < 1 in a custom view for close-ups of textures/details.

Inputs: file_path (required), views, animation_frames, frame_interval_ms, +6 more.

validate_sceneRun structured diagnostics on a 3D canvas sceneA

Loads the scene HTML and returns a JSON report: page/console errors, blank-canvas and detail analysis of the rendered pixels, and — when window.__scene is registered (Three.js) — deep scene-graph checks: floating objects, missing lights, out-of-frustum meshes, NaN transforms, missing UVs/normals, camera clipping, texture problems. Each issue has a severity and a concrete fix suggestion. Fix errors first, then warnings. Call this after render_scene whenever something looks wrong, and at least once before declaring the scene done.

Inputs: file_path (required), include_screenshot, width, height, +3 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: get_guidelines provides workflow guidance, inspect_scene explores the scene tree, interact_scene tests game interactions, render_scene produces screenshots, and validate_scene checks for errors. No overlap or ambiguity.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (get_guidelines, inspect_scene, interact_scene, render_scene, validate_scene) with clear, descriptive verbs that reflect their actions.

    Tool Count5/5

    5 tools is well-scoped for a 3D canvas helper server: it covers guidance, inspection, interaction, rendering, and validation without being too few or excessive for the domain.

    Completeness4/5

    The tools cover the core workflow of building, rendering, inspecting, validating, and testing scenes. Minor gaps like scene editing or asset import tools exist but are outside the server's stated focus, so completeness is high.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to control and manipulate live 3D scenes across frameworks like Three.js, A-Frame, and Babylon.js using a comprehensive set of object and environment tools. It features an integrated in-world chat system that allows for real-time scene modifications directly from within the 3D canvas.
      33
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables coding agents to visually inspect and diagnose 3D files (meshes and Gaussian splats) for defects like flipped normals or floaters, without GPU dependencies.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to drive a live SVG/vector editor, allowing a full observe-and-act loop on a canvas with real tools, state reading, and PNG rendering.
      2
      MIT