"""WorkspaceMCPServer - Google Workspace MCP Server over SSE."""

from onit_workspace.mcp_server import run


class WorkspaceMCPServer:
    """Google Workspace MCP Server that runs over SSE transport."""

    def __init__(
        self,
        host: str = "0.0.0.0",
        port: int = 18204,
        path: str = "/sse",
        credentials_file: str = None,
        oauth_client_file: str = None,
        delegated_user: str = None,
        data_path: str = None,
        verbose: bool = False,
    ):
        self.host = host
        self.port = port
        self.path = path
        self.options = {}
        if credentials_file:
            self.options["credentials_file"] = credentials_file
        if oauth_client_file:
            self.options["oauth_client_file"] = oauth_client_file
        if delegated_user:
            self.options["delegated_user"] = delegated_user
        if data_path:
            self.options["data_path"] = data_path
        if verbose:
            self.options["verbose"] = True

    def start(self):
        """Start the MCP server (blocking)."""
        run(
            transport="sse",
            host=self.host,
            port=self.port,
            path=self.path,
            options=self.options,
        )
