seems to miss a function inside Protocol. Let me know if it s correct or not. ``` public function send(string $request): ?string { $clientId = 'local'; // Use a dummy client ID for local calls $responseToSend = null; $parsedMessage = null; $messageData = null; try { $messageData = json_decode($request, true, 512, JSON_THROW_ON_ERROR); if (!is_array($messageData)) { throw new ProtocolException('Invalid JSON received (not an object/array).'); } $parsedMessage = $this->parseMessageData($messageData); if ($parsedMessage === null) { throw McpServerException::invalidRequest('Invalid MCP/JSON-RPC message structure.'); } $responseToSend = $this->processor->process($parsedMessage, $clientId); } catch (JsonException $e) { $responseToSend = Response::error(McpServerException::parseError($e->getMessage())->toJsonRpcError(), null); } catch (McpServerException $e) { $id = $this->getRequestId($parsedMessage, $messageData); $responseToSend = Response::error($e->toJsonRpcError(), $id); } catch (Throwable $e) { $id = $this->getRequestId($parsedMessage, $messageData); $responseToSend = Response::error(McpServerException::internalError()->toJsonRpcError(), $id); } if ($responseToSend instanceof Response) { return $responseToSend->toJson(); } return null; } ``` and Response.php ``` public static function fromSuccess(mixed $result, ?string $id = null): self { $response = new self(); $response->jsonrpc = '2.0'; $response->result = $result; $response->id = $id; return $response; } public function toJson(): string { return json_encode($this); } public function jsonSerialize(): array { return [ 'jsonrpc' => '2.0', 'result' => $this->result, 'id' => $this->id, ]; } ```
Activity