"""Standardized response format for all MCP tools."""

from typing import Any


class ErrorType:
    VALIDATION = "validation_error"
    NOT_FOUND = "not_found"
    CONNECTION = "connection_error"
    INTERNAL = "internal_error"
    INGESTION = "ingestion_error"


def success_response(**data: Any) -> dict[str, Any]:
    return {"status": "success", **data}


def error_response(
    message: str,
    error_type: str = ErrorType.INTERNAL,
    **extra: Any,
) -> dict[str, Any]:
    response = {
        "status": "error",
        "error": message,
        "error_type": error_type,
    }
    if extra:
        response.update(extra)
    return response


def validation_error(message: str, **extra: Any) -> dict[str, Any]:
    return error_response(message, ErrorType.VALIDATION, **extra)


def not_found_error(message: str, **extra: Any) -> dict[str, Any]:
    return error_response(message, ErrorType.NOT_FOUND, **extra)


def internal_error(message: str, **extra: Any) -> dict[str, Any]:
    return error_response(message, ErrorType.INTERNAL, **extra)
