Skip to content

Settings

settings

Runtime settings for the MCP serving process.

NonProductionPortError

Bases: ValueError

Raised when a non-production profile has no explicit MCP HTTP port.

Source code in packages/axm-mcp/src/axm_mcp/settings.py
Python
class NonProductionPortError(ValueError):
    """Raised when a non-production profile has no explicit MCP HTTP port."""

resolve_http_port()

Resolve the MCP HTTP port, requiring an override outside production.

Source code in packages/axm-mcp/src/axm_mcp/settings.py
Python
def resolve_http_port() -> int:
    """Resolve the MCP HTTP port, requiring an override outside production."""
    override = os.environ.get("AXM_MCP_PORT")
    if override is not None:
        return int(override)

    profile = current_profile()
    if profile != "production":
        msg = f"profile {profile!r} requires the AXM_MCP_PORT environment variable"
        raise NonProductionPortError(msg)
    return 9427

resolve_pid_file()

Resolve the MCP server PID file for the active profile.

Source code in packages/axm-mcp/src/axm_mcp/settings.py
Python
def resolve_pid_file() -> Path:
    """Resolve the MCP server PID file for the active profile."""
    root = profile_root()
    if root is not None:
        return root / "mcp-server.pid"
    return Path.home() / ".axm" / "mcp-server.pid"

resolve_serve_mode(explicit=None)

Resolve serving mode with explicit > environment > file > default.

Source code in packages/axm-mcp/src/axm_mcp/settings.py
Python
def resolve_serve_mode(explicit: str | None = None) -> ServeMode:
    """Resolve serving mode with explicit > environment > file > default."""
    resolved = (
        explicit
        if explicit is not None
        else get("mcp", "serve_mode", default="dedicated")
    )
    match resolved:
        case "shared":
            return "shared"
        case "dedicated":
            return "dedicated"
        case _:
            msg = f"invalid serve mode: {resolved!r}"
            raise ValueError(msg)