HelPHP

Server
in package

Tags
class

Server

Hand-rolled MCP (Model Context Protocol) JSON-RPC 2.0 dispatcher. Shared by both transports: helphp/utils/mcp_server.php (stdio) and helphp_instance/mcp/message.php (HTTP+SSE) each read one JSON-RPC message, call handle_message(), and write the response back on their own wire (a stdout line, or an HTTP body / SSE event).

No reflection or attribute magic: tools are a plain list, following the same "no shared/generic magic, OPcache-friendly" spirit as the rest of the framework's CRUD discipline.

Table of Contents

Constants

PROTOCOL_VERSION  : mixed = '2024-11-05'

Methods

handle_message()  : array<string|int, mixed>|null
Dispatches one decoded JSON-RPC message and returns the response to write back, or null when nothing should be written (a notification, i.e. a message with no "id").

Constants

PROTOCOL_VERSION

public mixed PROTOCOL_VERSION = '2024-11-05'

Methods

handle_message()

Dispatches one decoded JSON-RPC message and returns the response to write back, or null when nothing should be written (a notification, i.e. a message with no "id").

public static handle_message(array<string|int, mixed> $message, array<string|int, mixed> $context) : array<string|int, mixed>|null
Parameters
$message : array<string|int, mixed>

Decoded JSON-RPC request/notification.

$context : array<string|int, mixed>

['transport'=>'stdio'|'http', 'is_admin'=>bool, 'user_id'=>int|null, 'login'=>string|null]

Return values
array<string|int, mixed>|null
On this page

Search results