# In an editable checkout this is the repository root. In an installed wheel it is merely a

- Object ID: `em:implementation:sha256:85f4e28a6a876c082c7b7e6201529b2e9d9c3256e0ae02c03306ee3e47602b9d`
- Kind: `implementation`
- Repository path: [`src/epistemedia/server/__init__.py`](https://github.com/yoheinakajima/epistemedia/blob/f92846570180dfa4511263f8ba98ecd18f7772c9/src/epistemedia/server/__init__.py)
- Content digest: `0161a354ed8def0bb0f5db6f9196b6960b7946600a51d94afff0364555209068`

**Also filed under:** [Human and Agent Interfaces](https://epistemedia.org/topics/public-interfaces/)

## Source content

"""Lazy compatibility package for the ASGI gateway.

A package directory intentionally takes precedence over the legacy sibling `server.py` module.
It sets a non-authoritative fallback root before loading that implementation so importing the
remote CLI never requires the caller to be inside a repository. Local realm commands still
resolve and require an explicit repository through the CLI.
"""

from __future__ import annotations

import importlib.util
import os
import sys
from pathlib import Path

_file = Path(__file__).resolve().parent.parent / "server.py"
# In an editable checkout this is the repository root. In an installed wheel it is merely a
# harmless package fallback; remote commands do not read it, and local commands resolve a root.
os.environ.setdefault("EPISTEMEDIA_ROOT", str(Path(__file__).resolve().parents[3]))
_name = "epistemedia._server_implementation"
_spec = importlib.util.spec_from_file_location(_name, _file)
if _spec is None or _spec.loader is None:  # pragma: no cover
    raise ImportError(f"Unable to load Epistemedia gateway from {_file}")
_module = importlib.util.module_from_spec(_spec)
sys.modules[_name] = _module
try:
    _spec.loader.exec_module(_module)
except BaseException:
    sys.modules.pop(_name, None)
    raise

Gateway = _module.Gateway
MCPRequestError = _module.MCPRequestError
Request = _module.Request
tool_definitions = _module.tool_definitions
app = Gateway()

__all__ = ["Gateway", "MCPRequestError", "Request", "app", "tool_definitions"]
