JustAMCPRuntime

Inherits: Object

Engine singleton that hosts the JustAMCP runtime server.

Description

JustAMCPRuntime hosts the exported or play-mode MCP endpoint. The HTTP host exposes only project-owned tools and prompts registered with register_tool() and register_prompt(). The TCP bridge still accepts register_custom_command(). It is independent of the active SceneTree, so it can keep serving while scenes are opened, closed, or changed.

The game HTTP MCP host listens on ProjectSettings.blazium/justamcp/export_port when set, otherwise the editor port plus one (6506 → 6507). Autowork --aw-* does not start MCP unless --enable-mcp or --enable-mcp-game-control is also passed. Project-owned Cursor tools register through register_tool(); TCP register_custom_command() stays for the game-control bridge.

JustAMCPRuntime.port = 6507
JustAMCPRuntime.enabled = true

JustAMCPRuntime.register_tool("echo", "Echo text", {"type": "object", "properties": {"text": {"type": "string"}}}, func(args):
    return args.get("text", "")
)

JustAMCPRuntime.register_custom_command("double", func(value):
    return value * 2
)

Properties

bool

enabled

false

int

port

6507

Methods

Dictionary

execute_command(command: String, params: Dictionary)

bool

is_listening() const

Array

list_tools() const

void

load_project_mcp_scripts()

void

poll()

void

register_custom_command(name: String, callable: Callable)

void

register_prompt(name: String, description: String, callable: Callable)

void

register_tool(name: String, description: String, input_schema: Dictionary, callable: Callable)

void

unregister_custom_command(name: String)

void

unregister_prompt(name: String)

void

unregister_tool(name: String)


Signals

client_connected() 🔗

Emitted when a new MCP client connects to the runtime server.


client_disconnected() 🔗

Emitted when an MCP client disconnects or the runtime closes its connection.


command_received(command: String, params: Dictionary) 🔗

Emitted after the runtime parses an incoming MCP command. The signal exposes the command name and decoded parameter dictionary before dispatch.


Property Descriptions

bool enabled = false 🔗

  • void set_enabled(value: bool)

  • bool is_enabled()

When true, the runtime server is active and can accept MCP traffic. Setting it to false stops serving runtime requests.


int port = 6507 🔗

  • void set_port(value: int)

  • int get_port()

Game MCP port. Defaults to the editor HTTP port plus one (6506 → 6507). Override with --mcp-game-port or ProjectSettings.blazium/justamcp/export_port. Never bind the editor port. remote_control also defaults to 6507; if bind fails the host retries once on port+1.


Method Descriptions

Dictionary execute_command(command: String, params: Dictionary) 🔗

Executes a runtime command with params and returns the command result dictionary. Commands include built-in runtime operations, tool dispatch, resources, prompts, and run_custom_command.


bool is_listening() const 🔗

Returns true when the HTTP MCP host or TCP game-control bridge is accepting connections.


Array list_tools() const 🔗

Returns schemas for project-owned tools registered with register_tool().


void load_project_mcp_scripts() 🔗

Loads register.gd and register.luau from ProjectSettings.blazium/justamcp/project_mcp_dir (default res://mcp) so those scripts can call register_tool() and register_prompt().


void poll() 🔗

Processes pending network activity for the runtime server, including new connections, inbound MCP payloads, and queued asynchronous work.


void register_custom_command(name: String, callable: Callable) 🔗

Registers callable under name so MCP clients can invoke it with execute_command("run_custom_command", {"name": name, "args": [...]}). Registering the same name replaces the previous callable.


void register_prompt(name: String, description: String, callable: Callable) 🔗

Registers a project-owned MCP prompt. callable receives the prompt argument dictionary and should return messages or a string. Same ClassDB API for GDScript and Luau.


void register_tool(name: String, description: String, input_schema: Dictionary, callable: Callable) 🔗

Registers a project-owned Streamable HTTP MCP tool that appears in tools/list and is invoked by tools/call. input_schema is a JSON Schema object. Same ClassDB API for GDScript and Luau.


void unregister_custom_command(name: String) 🔗

Removes the custom command registered as name. Calls to run_custom_command with that name will return an error after removal.


void unregister_prompt(name: String) 🔗

Removes the project-owned MCP prompt registered as name.


void unregister_tool(name: String) 🔗

Removes the project-owned MCP tool registered as name.