JsonRpcService
JSON-RPC 2.0 dispatcher for the Model Context Protocol, running over a {@see ToolRegistry}. Transport-agnostic by design: it takes a decoded JSON-RPC request array and an optional caller {@see ToolContext}, and returns a JSON-RPC response array — nothing here knows about HTTP, SSE, stdio, or how the caller authenticated. A host adapter owns decoding the wire request, resolving the caller into a `ToolContext` (see `Auth\TokenValidatorInterface`), and encoding the response back onto its transport of choice. Covers the MCP method set this package implements: `initialize`, `notifications/initialized`, `tools/list`, `tools/call`.
JsonRpcService::__construct()
public function __construct(Milpa\ToolRuntime\ToolRegistry $toolRegistry):Parameters
| Name | Type | Description |
|---|---|---|
| $toolRegistry | Milpa\ToolRuntime\ToolRegistry |
JsonRpcService::handle()
public function handle(array $request, ?Milpa\ToolRuntime\Contracts\ToolContext $ctx = null): arrayDispatch one JSON-RPC 2.0 request through the MCP method set and return its response. Never throws for a well-formed-but-unknown method or a failed tool call — those come back as a JSON-RPC `error` member. Only a malformed envelope (missing/wrong `jsonrpc`, missing `method`) throws, since there is no `id` to safely key a response on.
Parameters
| Name | Type | Description |
|---|---|---|
| $request | array<string, mixed> | |
| $ctx | ?Milpa\ToolRuntime\Contracts\ToolContext |