Skip to main content
Glama
viewer-mcp

viewer-mcp

by Akhil7199

viewer-mcp

An MCP (Model Context Protocol) server that lets an AI agent build and edit a live three.js / WebGL scene in plain language. Ask Claude "put a red sphere on top of the box", and the scene in your browser updates as the tools run.

Scene built by an agent through MCP tool calls

What it shows

Area

How it's done

MCP tools

7 tools (get_scene, list_objects, add_object, update_object, remove_object, set_camera, clear_scene). Inputs are validated with Zod schemas, and tools carry read-only/destructive annotations.

Guardrails

Coordinate bounds, scale limits, a cap on object count and hex-only colors. When a request breaks a rule, the tool returns an error the model can act on instead of crashing. A failed update leaves the scene unchanged.

Human-in-the-loop

clear_scene asks the user to confirm through MCP elicitation. If the user declines, or the client can't ask, nothing is deleted. The model can't approve the deletion itself.

Traceability

Every tool call writes one structured JSON trace line (trace id, args, outcome, duration) to stderr. stdout stays reserved for the protocol.

Evaluation harness

evals/scenarios.json defines tasks and the scene state each should end in. CI runs the reference solution for each scenario through a real MCP client. npm run eval:llm gives the same scenarios to Claude and grades the final scene.

Tests & CI

22 tests with Vitest: unit, MCP integration and viewer bridge. GitHub Actions runs typecheck, tests and build on Node 20 and 22.

Viewer

three.js + WebGL, kept in sync over WebSocket. Meshes are matched by object id, so only objects that changed are rebuilt.

Claude / MCP host ──stdio──▶ MCP server ──▶ SceneStore (guardrails) ──WebSocket──▶ three.js viewer
                                  │
                                  └─▶ JSON traces (stderr)

Related MCP server: canvas3d-mcp

Run it

npm install
npm run build
npm run demo          # builds a sample scene through real MCP tool calls
# open http://127.0.0.1:5174

Use it from Claude Desktop / Claude Code

{
  "mcpServers": {
    "viewer": { "command": "node", "args": ["/absolute/path/to/viewer-mcp/dist/src/main.js"] }
  }
}

Open http://127.0.0.1:5174, then ask: "Build a small table with four legs and put a blue vase on it."

Test and evaluate

npm test              # unit + integration + scripted eval scenarios
npm run eval:llm      # optional: Claude runs every scenario (uses API credits)

The LLM eval uses claude-opus-5-5 by default (override with EVAL_MODEL). It reads credentials from ANTHROPIC_API_KEY or an ant auth login profile. Set EVAL_ONLY=<text> to run matching scenarios and EVAL_VERBOSE=1 to print Claude's tool calls and replies.

Latest results (Nov 2026, claude-opus-5-5, effort medium)

7/7 scenarios passed, using about 32K tokens in total.

Scenario

Result

Add a red cube

Pass

Stack a sphere on a box

Pass

Recolor by name, leave others alone

Pass

Out-of-bounds move is refused

Pass

Clear scene, user confirms

Pass

Clear scene, user declines

Pass

Clear scene, client cannot ask the user

Pass

On the first run, the out-of-bounds scenario failed (6/7). The transcript showed Claude read the ±50 limit in the tool schema, never made the invalid call, and explained the limit to the user. The scenario had required the server guardrail to fire, which tested how the move was blocked rather than whether it was. It now checks that the object didn't move. The server-side guardrail still has its own test in test/server.test.ts.

Layout

src/scene.ts      scene model + guardrails
src/server.ts     MCP tools, tracing wrapper, elicitation
src/bridge.ts     HTTP + WebSocket bridge to the viewer
viewer/index.html three.js / WebGL viewer
evals/            scenarios, harness, Claude-driven eval
test/             Vitest suites

License

MIT, see LICENSE.

Available Tools

7 tools
add_objectC

Add a primitive to the scene. At most 50 objects.

Inputs: shape (required), name, color, scale, +1 more.

clear_sceneA
Destructive

Remove ALL objects. The server asks the human to confirm (MCP elicitation); if they decline or the client cannot ask, nothing is deleted.

Inputs: no named parameters.

get_sceneA
Read-only

Return every object in the scene plus the camera. Call this before editing so you use real ids.

Inputs: no named parameters.

list_objectsB
Read-only

List objects, optionally filtered by shape or by a case-insensitive name match.

Inputs: shape, nameContains.

remove_objectB
Destructive

Remove one object by id.

Inputs: id (required).

set_cameraB

Move the camera. target defaults to the current look-at point.

Inputs: position (required), target.

update_objectB

Change an object's color, position, scale or name. Only the fields you pass change.

Inputs: id (required), name, color, scale, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 7 tools

    Disambiguation4/5

    Most tools map to a distinct action (add/update/remove/clear/set_camera), but list_objects and get_scene both return scene contents, which could cause an agent to pick the wrong one. The descriptions do differentiate them (filtered list vs. full scene plus camera), so confusion is limited.

    Naming Consistency5/5

    All seven tools follow a clean snake_case verb_noun pattern (list_objects, get_scene, add_object, update_object, remove_object, clear_scene, set_camera). No mixed conventions or vague verbs.

    Tool Count5/5

    Seven tools is a well-scoped surface for a 3D scene viewer, and each one clearly earns its place. There are no redundant or filler tools.

    Completeness4/5

    The object lifecycle is fully covered (list, read, add, update, remove, bulk clear) plus camera positioning and reading via get_scene. Minor gaps exist, such as no way to read or reset the camera independently or duplicate objects, but core workflows are complete.

    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
    • F
      license
      A
      quality
      D
      maintenance
      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.
      5
      -
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to inspect and modify live Three.js scenes in real time through 59 tools covering objects, materials, shaders, textures, animations, performance monitoring, memory diagnostics, and code generation. Works with vanilla Three.js, React Three Fiber, and any framework without changing your project, using an injected browser bridge and in-page devtools overlay.
      6,808 npm
      MIT
    • A
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to inspect a running Three.js scene in the browser and try out live edits to objects, materials, shaders, lights, camera and animation without touching project files. Every change is recorded and can be exported as ready-to-paste vanilla Three.js or React Three Fiber code, alongside performance audits and frame capture.
      6,808 npm
      MIT