Skip to content
docsv0.5.1

McpRequestEvent

Dispatched by {@see \Milpa\McpServer\JsonRpcService::handle()} as the readonly half of the `mcp.request` PRE event, right before a resolved JSON-RPC method is dispatched. Always readonly (family convention, core 0.5 KEYSTONE) — this class carries observability data only. The companion mutable {@see \Milpa\Events\InterceptionSlot}, dispatched alongside it under the `'slot'` payload key, is the only thing a listener can use to veto the method (`$slot->stop()`) or serve a canned/cached response in its place (`$slot->shortCircuit($response)`) — never this event object. Fires for every resolved method, including notifications (a request with no `id` member) — `handle()` still owes observability the emit even though the wire response is suppressed.

McpRequestEvent::__construct()

public function __construct(string $method, array $params, ?Milpa\ToolRuntime\Contracts\ToolContext $ctx):

Parameters

Parameters of __construct()
NameTypeDescription
$methodstring
$paramsarray<string, mixed>the raw, array-normalized `params` member of the incoming JSON-RPC request (never the un-normalized non-array value a malformed request might have sent)
$ctx?Milpa\ToolRuntime\Contracts\ToolContext

McpRequestEvent::getMethod()

public function getMethod(): string

The JSON-RPC method about to be dispatched (e.g. `tools/call`).

McpRequestEvent::getParams()

public function getParams(): array

The request's `params`, already normalized to an array.

McpRequestEvent::getContext()

public function getContext(): ?Milpa\ToolRuntime\Contracts\ToolContext

The authenticated caller context, if the host resolved one, else `null`.