MCP tool reference¶
Configuration¶
Setting |
Meaning |
|---|---|
|
Enable MCP at |
|
Port for the environment opt-in; default 8765. For |
|
Supplied credential; otherwise generated at each server start. |
|
Comma-separated tool groups; replaces the defaults. |
One active App per process is supported. For multiple Apps, use separate processes
and ports: serve --port 8766 or serve --port 0 for an available port.
Tool groups¶
Default groups are scene,camera,capture,recording,profile,docs: 24 tools
including engine_status. Without guide files, search_docs and get_doc are
omitted at startup, leaving 22 tools; get_api_docs remains available.
The optional scenario group adds five tools and requires registered MCP targets
for playback. See the Group column below for membership.
KANGENGINE_MCP_TOOLS=scene,camera,capture python -m kangengine.adapters.mcp serve
Unknown or empty group selections fail at startup. Restart the server and reconnect
the client after changing groups. engine_status is always available; its
available_tools lists exposed tools, while capabilities describe runtime support.
Groups are not user roles or an authorization system.
Reuse a token¶
To retain the current App’s generated token, run this while it is still running, in the shell that will launch its next instance:
export KANGENGINE_MCP_TOKEN="$(python -m kangengine.adapters.mcp token)"
Close the old App, then launch serve from that shell. Supplied tokens require
at least 32 printable ASCII characters without spaces; use a generated token
rather than a password. Store it privately if it must survive shell restarts.
To generate a new token, run unset KANGENGINE_MCP_TOKEN in the App-launching
shell before restarting the App, then refresh the client’s credential and restart
the client or its IDE host process.
Client configuration output¶
print-config prints settings for the selected App without revealing its token
or editing client configuration. On the default port, its JSON output is:
{
"transport": "streamable-http",
"url": "http://127.0.0.1:8765/mcp",
"headers": {
"Authorization": "Bearer <token>"
},
"token_command": "python -m kangengine.adapters.mcp token"
}
Replace <token> with the output of the token command. With --format codex:
[mcp_servers.kangengine]
url = "http://127.0.0.1:8765/mcp"
bearer_token_env_var = "KANGENGINE_MCP_TOKEN"
See the official Codex MCP guide for client configuration.
Tools¶
Exposure follows the configuration.
Always available is not a configurable group name.
Tool |
Group |
Inputs |
Result |
|---|---|---|---|
|
Always available |
None |
Session, readiness, backends, coordinates, capabilities and limits. Refreshed at a frame boundary once ready. |
|
|
|
Copied hierarchy, transforms, active/visible state and resource IDs. |
|
|
|
Create a box, sphere or plane with a registered mesh and material. |
|
|
|
Edit a static leaf’s local transform; omitted/null fields stay unchanged. |
|
|
|
Assign an untextured Phong material to one static visual. |
|
|
|
Delete a childless object created through automation in this App session. |
|
|
|
One prim’s transforms, resource IDs, render flags and physics metadata. |
|
|
|
Resource type/name/URI, usage count and bounded usage paths. |
|
|
|
Auto-fit an automation-created primitive; explicit distance targets a static prim’s world origin. |
|
|
|
Literal text search in the source checkout’s public guide. |
|
|
|
Read a bounded portion of a public guide page. |
|
|
|
Public symbol signature and docstring, without executing code. |
|
|
Optional |
PNG image content and dimensions, native frame ID and optional saved path. |
|
|
|
Existing profile snapshots and summary; never enables profiling. |
|
|
|
Measure a bounded number of normal frames; return a job ID. |
|
|
|
Measurement progress and previous profiler setting. |
|
|
|
Copied frame results, with pagination. |
|
|
|
Stop measurement and restore the previous profiler setting. |
|
|
None |
Navigation camera position/target in world coordinates and active scene camera path. |
|
|
|
Set navigation camera position and target, each three scene-unit values. |
|
|
|
Set one prim’s local visibility; report effective visibility. |
|
|
None |
Common App recorder state and current or last output path. |
|
|
|
Start recording to a new MP4 within the allowed output directory. |
|
|
None |
Finalize the common App recording. |
|
|
None |
Registered targets, supported scenarios and data/configuration identifiers. |
|
|
|
Reset the target and start a fixed-step job; return its ID. |
|
|
|
Progress, terminal state, pose snapshot and capture metadata. |
|
|
|
Stop at a step boundary and release live control. |
|
|
|
Return a completed job’s retained PNG without rendering again. |
Matrices are serialized by rows; positions use scene units and the reported up
axis. meters_per_unit is null. Resource-only prims have no transforms;
ExternalBuffer matrices describe the batch owner, not individual instances.
Large geometry, texture and tensor buffers are omitted.
PNGs contain the postprocessed RGB scene with a top-left origin and no UI, at the presented framebuffer’s dimensions. They are returned to the client and saved only when requested. Cancellation cannot undo a file commit already in progress; App shutdown waits for it to finish.
The App must keep rendering to answer requests. Capture and large queries can
increase frame time. Profiler enabled and data_status distinguish disabled,
empty and retained results; unavailable timings are null without waiting for the GPU.
Authored materials remain retained until the App closes, including after object deletion, and count toward the limits.
Transform edge cases¶
Translation-only edits preserve shear/reflection. Changing only rotation or only scale requires a nonsingular, non-reflected TRS matrix; otherwise supply both to replace the linear part.
Common response fields¶
Fields below describe successful responses; documentation tools do not carry an
App session ID. Frame IDs are zero-based native frame indices, comparable only
within the same app_session_id, and share the profiler’s frame_index numbering.
Field |
Returned by |
Meaning |
|---|---|---|
|
All non-documentation tools |
Identifies the App automation session, not the HTTP connection. |
|
|
The rendered frame used for the PNG. Retained scenario captures keep their original ID. |
|
|
Observation was taken before this frame’s updates/render. It does not identify every frame in a profile history result. |
|
Scene tools except |
Command was processed before this frame’s updates/render. For job queries this is the query boundary, not the job’s measured/captured frame. |
|
|
Last completed frame at the status observation; |
|
|
Opaque handle scoped to that job type and App session; invalid after eviction or App restart. |
|
|
Content was omitted due to the query or output bound. Narrow the query or use the tool’s paging controls where available. |
|
|
Pass as the next |
Ordering edits and captures¶
Wait for an edit’s successful response before calling viewport_capture.
Its frame ID is the edit’s processed_before_frame_id or later in the same session.
Parallel calls do not guarantee this order. Callbacks and animation may change
the scene before capture. Server instructions and the capture tool description
also specify this rule.
CLI mapping¶
Run commands as python -m kangengine.adapters.mcp COMMAND. Put
--connection-file PATH before the command when selecting a session.
CLI command |
MCP tool / action |
|---|---|
|
Open a new blank App |
|
List local records and process state; no token output |
|
Print the credential from the selected connection file, not |
|
Print generic JSON or Codex TOML without credentials |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Other tools are available directly to MCP clients. frame_count selects how many
frames to measure; max_frames limits how many a query returns.
Limits¶
Operation |
Limit |
|---|---|
Outstanding requests / processing |
16 / 4 per frame |
Request deadline |
10 seconds including queue time; not the whole profile/scenario job |
HTTP request / tool JSON response |
64 KiB / 1 MiB |
Capture |
16,777,216 pixels; PNG at most 8 MiB; at most 2 encoding jobs |
PNG output |
New |
Scene inspection |
Depth 0..16; 1..1000 prims; resource usage query 1..1000 paths |
Primitive authoring |
256 live objects; 128 distinct retained materials per App |
Supplied translation / scale |
±1,000,000 per axis / 0.0001..10000 per axis |
Material |
Linear RGB 0..1; shininess 1..256 |
Explicit focus distance |
0.001..1,000,000 scene units |
Recording |
1..240 fps; new |
Profiling |
1..240 measured frames; result pages 1..60 frames; 1 active / 4 retained jobs |
Existing profile query |
1..240 frames |
Scenario (optional) |
0..120 logical seconds; 1 active / 4 retained jobs; 8 steps per frame with a 4 ms scheduling budget |
Documentation |
Search up to 30 results; read up to 120 lines per call |
Errors and recovery¶
Execution errors return is_error=true and
{"error": {"code": "...", "message": "..."}}.
Protocol/schema errors remain SDK errors. Read message for the specific cause.
Code / symptom |
What to do |
|---|---|
|
Fix inputs; use a new filename and keep output within its allowed directory. |
|
Inspect current paths or job IDs; an old job may have been evicted. |
|
Check ownership, rendering mode and feature scope. If the guide directory disappeared after startup, use |
|
Wait for the first render or job completion. |
|
Wait for pending work; finish the active job/recording or respect resource limits. |
|
Confirm the App is still producing frames. Check current state before retrying a mutation. |
|
Request was canceled; inspect current state before retrying. |
|
Start/connect to a running App session. |
|
Check rendering, destination permissions and the App’s error output. |
|
Request fewer prims/frames/lines or reduce capture resolution. |
|
Inspect the App error and reproduce with a bounded request. |
Connection refused / HTTP 401 |
Check the running App’s URL and current credential using |
Multiple session candidates |
Select one with |
Missing tool |
Check |
Client blocks deletion |
Use the client’s approval workflow; tool annotations are hints, not permission grants. |
engine_status may report initializing before the first frame. A hidden GLFW
window still requires a display; headless=True is not a displayless renderer.
Stale or ambiguous sessions¶
Automatic selection excludes dead records and requires one remaining candidate;
unknown records remain candidates. Use --connection-file PATH if ambiguous.
Normal shutdown removes the App’s record; stale records are not automatically deleted.
alive is a process check, not a connection test, and cannot detect PID reuse on
macOS. Use status to verify connectivity and the App session ID.