mcp

v0.2.1
@click-to-source-3d/mcp Checked 3 days ago Published 3 days ago

MCP server that lets AI coding assistants like Claude Code see a running three.js or React Three Fiber scene, read the meshes you point at, and edit their…

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_selection

What the developer is pointing at in the running scene. Call this whenever they refer to objects without naming them: "make this bigger", "why are these so slow", "the one I clicked". `pointing` lists the objects they deliberately pointed you at, in order; act on these first. `selected` is the object open in their inspector panel, and is what they mean if `pointing` is empty. Each object has its source file, function and line, its `props` with the file, exact line, column and raw text of every editable value, including its geometry's and material's, its transform and its rendering cost. A valu…

highlight_object

Outline objects on the developer's screen, in a colour of their own, to show them what you mean: "this is the tree I am changing". Names objects by file and line, as get_selection and list_scene_provenance report them. Add `ordinal` for one of several objects from one line, and `instanceId` for one instance of an InstancedMesh. The outline lasts `seconds`, 15 by default. An empty list clears it. Reports what it found and what it did not.

ParameterTypeDescription
targets *array
pageIdnumberRequired when several pages are open
secondsnumberHow long the outline lasts, up to 120

get_canvas_screenshot

A picture of the running scene, as the developer sees it, with any outlines but without the page around the canvas or the inspector panel. Use it to see what an object looks like, to find something to ask about with resolve_at_point, or to check a change after an edit. `via` is `frame` for a frame the app drew itself. It is `direct` when the tab is in the background and the scene was drawn just for this, without any post-processing.

ParameterTypeDescription
maxSizenumberLongest edge in pixels. Default 1024, up to 2048.
pageIdnumberRequired when several pages are open

get_source

Read a source file from the running Click-to-Source project. Pass no line bounds at all to read the whole file, or `around` to read a window centred on one line — which is the usual next step after list_provenance or resolve_at_point hands you a line. Subject to the same extension allowlist as the overlay panel, so only editable source files are reachable.

ParameterTypeDescription
file *stringPath relative to the Vite project root, e.g. src/components/Trees.jsx
aroundnumber1-indexed line to centre a window on. Reads contextLines either side. Ignored for whichever bound startLine or endLine supplies.
contextLinesnumberLines either side of `around`. Defaults to 20.
endLinenumber1-indexed, inclusive. Overrides the end of `around`.
startLinenumber1-indexed, inclusive. Overrides the start of `around`.

edit_parameter

Rewrite one literal in source, through the same AST editor the panel uses. Only that literal changes; formatting is preserved, and the developer sees the edit in their activity log. Name it exactly, with the line, column and raw text from a value in get_selection or resolve_at_point's props. Or, for a hand-written sourceRef, by argName. Fails with STALE_LOCATION, ARGUMENT_NOT_FOUND, LOCATION_NOT_FOUND or AMBIGUOUS_LOCATION rather than editing the wrong thing. Vite hot-reloads the result.

ParameterTypeDescription
file *string
line *numberLine of the literal. By argName, use the declaredLine reported by list_provenance, which is often not the line the sourceRef sits on.
newValue *String, number, boolean or null
argNamestringThe argument's name, instead of column and expected.
columnnumber1-based column of the literal, from a value's `column`. Needs `expected`.
expectedstringThe literal's current source text, from a value's `raw`.

list_files

List the source files the scanning tools can see, for when you do not know what the project contains. This is not a file browser: it reports exactly the set the provenance scan would read — recognised source extensions under the project root, excluding dotfiles, node_modules, dist, build, .git, .vite and coverage, and not following symlinks. Files outside that set are invisible here whether or not they exist. Reads no contents. Reports the root it walked, and whether it stopped at the scan limit before finishing.

list_provenance

List every hand-written sourceRef in the project, by static scan. Reports what the source says, not what is currently rendered — an object only exists after a mount, and this cannot see the running scene. An empty result means no hand-written sourceRef, NOT that the project has no provenance: locations stamped by the Vite plugin live in transformed output, are invisible to this scan, and still resolve through the panel and through list_scene_provenance, resolve_at_point and get_instance_provenance. Use list_files to see what source exists.

ParameterTypeDescription
filestringRestrict to one file

resolve_at_point

Resolve whatever is under a point in the RUNNING scene. Coordinates are normalised device coordinates, -1 to 1. Needs the dev server running and the app open in a browser tab; nothing else to set up. The answer includes the object's editable props, each with its file and exact line and column, the calls that led to it and the functions behind it. Reports disconnected, no_scene, ambiguous or timeout rather than failing silently — each has a different remedy.

ParameterTypeDescription
x *number-1 (left) to 1 (right)
y *number-1 (bottom) to 1 (top)
pageIdnumberRequired when several pages are open

list_scene_provenance

Every stamped object currently in the running scene, with its address and instance count. Unlike list_provenance this reports what is rendered, not what the source declares — which is the only way to see instanced objects, since their provenance exists at runtime only.

ParameterTypeDescription
pageIdnumber

get_instance_provenance

Provenance for one addressed object, or one instance within an InstancedMesh. Addresses come from list_scene_provenance and are {file, function, line, ordinal} — derived from the source location rather than from Object3D.uuid, which is regenerated on every remount. Includes the object's props, the calls that led to it and the functions behind it. An instance's own transform is read-only: it comes from whatever wrote its matrix, so no literal in source corresponds to it.

ParameterTypeDescription
file *string
function *string
line *number
ordinal *numberWhich object at that call site, from 0
instanceIdnumberSlot within an InstancedMesh
pageIdnumber

search_by_generator

Find provenance sites by generating function or by argument name. Answers where a generator declares provenance, not which live objects it produced — that requires the running scene.

ParameterTypeDescription
argNamestringExact argument name
functionstringSubstring, case-insensitive