(string) ($params['protocolVersion'] ?? '2025-03-26'), 'capabilities' => ['tools' => ['listChanged' => false]], 'serverInfo' => ['name' => 'naurua-market-management', 'version' => '1.0.0'], ]; } elseif ($method === 'notifications/initialized') { http_response_code(202); exit; } elseif ($method === 'tools/list') { $result = ['tools' => market_management_mcp_tools()]; } elseif ($method === 'tools/call') { $tool = (string) ($params['name'] ?? ''); $arguments = is_array($params['arguments'] ?? null) ? $params['arguments'] : []; $result = [ 'content' => [[ 'type' => 'text', 'text' => json_encode(market_management_mcp_call_idempotent($pdo, $userSubject, $tool, $arguments), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR), ]], 'isError' => false, ]; } else { throw new InvalidArgumentException('Unbekannte JSON-RPC-Methode: ' . $method); } echo json_encode(['jsonrpc' => '2.0', 'id' => $id, 'result' => $result], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR); } catch (Throwable $e) { http_response_code($e instanceof RuntimeException && str_contains($e->getMessage(), 'Token') ? 401 : 400); echo json_encode([ 'jsonrpc' => '2.0', 'id' => $request['id'] ?? null, 'error' => ['code' => -32600, 'message' => $e->getMessage()], ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); }