JustAMCPServer

Inherits: Node < Object

Runs the editor-side Model Context Protocol server.

Description

JustAMCPServer owns the editor-facing MCP transport and emits signals for JSON-RPC tool requests, server lifecycle changes, elicitation responses, and cancellation notices. Most projects use it through the JustAMCP editor plugin or JustAMCPRuntime rather than instantiating it manually.

Implements the MCP Logging utility: declares logging capability, handles logging/setLevel, and pushes notifications/message to SSE clients. Engine output and JustAMCP debug traces can be forwarded when ProjectSettings.blazium/justamcp/forward_engine_logs and ProjectSettings.blazium/justamcp/enable_debug_logging are enabled.

Implements MCP Streamable HTTP on /mcp with MCP-Session-Id, per-stream SSE event IDs, Last-Event-ID replay, and DELETE session teardown. Legacy /sse + /message and stateless POST /mcp remain supported for existing clients.

When ProjectSettings.blazium/justamcp/bind_to_localhost_only is enabled, ProjectSettings.blazium/justamcp/streamable_http_strict_origin defaults to true so non-local Origin headers are rejected if the server is later bound beyond localhost.

ProjectSettings.blazium/justamcp/parallel_readonly_lane is deprecated; use ProjectSettings.blazium/justamcp/readonly_worker_concurrency (0 = serial main-only; N = up to N concurrent WorkerSafe readonly tools on WorkerThreadPool). WorkerSafe is a subset of readonly tools (execution.threadAffinity=worker); readonly alone does not imply off-main safety.

Implements MCP pagination for tools/list, prompts/list, resources/list, and resources/templates/list using opaque cursors. Buffers recent notifications/message payloads for replay when clients missed SSE; see ProjectSettings.blazium/justamcp/mcp_log_buffer_size and canonical blazium://logs/mcp/cursor/{token} (legacy blazium://logs/mcp/{cursor} remains readable for one release).

Supports task-augmented tools/call for long-running tools (Tasks), notifications/progress via _meta.progressToken (Progress), and cooperative cancellation (Cancellation). Sync requests honor notifications/cancelled; task-augmented work uses tasks/cancel.

var server = JustAMCPServer.new()
server.tool_requested.connect(func(request_id, tool_name, args):
    print("MCP tool requested: ", tool_name)
)

Tutorials

Methods

Array

get_session_roots(session_id: String) const

bool

is_server_started() const

void

report_tool_progress(token: String, progress: float, total: float, message: String)

void

send_log_message(level: String, logger: String, data: Variant = null)


Signals

elicitation_completed(request_id: Variant, result: Dictionary) 🔗

Emitted when an elicitation request finishes. request_id identifies the request and result contains the user response or completion payload.


request_cancelled(request_id: Variant, reason: String, caller_session_id: String) 🔗

Emitted when a pending MCP request is cancelled. request_id identifies the request, reason explains the cancellation, and caller_session_id is the session that issued the cancel (empty for legacy/unscoped cancels). Cross-session cancels are ignored.


server_status_changed(started: bool) 🔗

Emitted when the MCP server starts or stops. started is true while the server is running.


tool_requested(request_id: Variant, tool_name: String, args: Dictionary) 🔗

Emitted when an MCP client requests a tool call. Handlers should execute tool_name with args and respond using the associated request_id.


Method Descriptions

Array get_session_roots(session_id: String) const 🔗

Returns the workspace roots last reported by the client for session_id after roots/list or notifications/roots/list_changed.


bool is_server_started() const 🔗

Returns true while the MCP HTTP server is listening on the configured port.


void report_tool_progress(token: String, progress: float, total: float, message: String) 🔗

Emits an MCP notifications/progress notification for the active progressToken.


void send_log_message(level: String, logger: String, data: Variant = null) 🔗

Sends an MCP notifications/message log to connected clients if level meets the client's logging/setLevel minimum. logger is optional. data should be a Dictionary or string (stored as message).