Skip to main content
Glama
DmitriyGolub

threejs-devtools-mcp

by DmitriyGolub

run_js

Destructive

Run arbitrary JavaScript code with access to the Three.js scene, renderer, and camera. Returns the execution result for debugging or live inspection.

Instructions

Execute arbitrary JavaScript with access to scene, renderer, camera. Returns the result. Runtime only (lost on reload). If the code mutates scene state, ASK the user first: runtime preview or persistent code change?

SHADER PATCHING RECIPE — when modifying materials via onBeforeCompile:

  1. Reset patch flags: mat._curvedWorldPatched = false; mat._windPatched = false;

  2. Delete old shader refs: delete mat.userData.shakeShader; stop old animations via mesh.userData._stopShake?.();

  3. ONE onBeforeCompile pass (never chain) — include curved world + your effect together

  4. Replace '#include <project_vertex>' with full transform: USE_BATCHING/USE_INSTANCING guards → effect in world space → curved world (worldPos.y -= dist²0.005) → viewMatrixworldPos → gl_Position

  5. Declare uniforms before main(): shader.vertexShader.replace('void main() {', 'uniform float uTime;\nvoid main() {')

  6. Set mat.customProgramCacheKey = () => 'effect-' + Date.now(); — forces recompilation

  7. mat.needsUpdate = true;

  8. Animate uniforms via requestAnimationFrame loop

  9. Use transformed.y for height-based effects (local vertex Y), worldPos for spatial phase

Debug only — page reload will reset. No code changes needed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code. Available vars: scene, renderer, camera, gl. Use return for results.
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses runtime-only behavior, warns about mutations, and gives shader patching steps. Adds significant context beyond annotations (destructiveHint=true) by explaining when to ask user and that changes are lost on reload.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is long due to detailed shader patching recipe, which could be moved to documentation. However, front-loaded with core purpose and usage guidelines. Some redundancy (e.g., 'Runtime only' appears twice). Could be more concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers execution environment, return value, mutability warning, and reset behavior. No output schema but return value explained. Shader recipe adds depth. Slightly less complete in explaining error handling or side effects beyond scene mutation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers 100% of parameter description. Description adds available variables and usage hint but does not substantially extend beyond schema's 'JavaScript code. Available vars: scene, renderer, camera, gl. Use return for results.' Baseline 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it executes arbitrary JavaScript with access to scene, renderer, camera, and returns the result. Distinguishes from sibling tools that are more specific (e.g., set_uniform, material_details).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit guidance: ask user before mutating scene state, debug only, reset on reload. Includes detailed shader patching recipe. Lacks direct comparison to alternatives but context implies unique role.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DmitriyGolub/threejs-devtools-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server