---
title: Self-Hosting
description: Self-host mem/ctl on your own infrastructure
---

# Self-Hosting

mem/ctl is open source (Apache-2.0) and can be self-hosted.

For local setup and day-to-day development, see [Local Development](/docs/local-development). For production planning, see [Deployment](/docs/deployment).

## Requirements

- Node.js 20+
- A Turso database (or any libSQL-compatible database)
- GitHub OAuth app (for authentication)
- Stripe account (for billing, optional)

## Setup

### 1. Clone and install

```bash
git clone https://github.com/memctl/memctl.git
cd memctl
pnpm install
```

### 2. Configure environment

```bash
cp .env.example .env
```

Fill in the required values in `.env`.

### 3. Set up database

```bash
pnpm db:push
```

### 4. Build and start

```bash
pnpm build
pnpm start
```

### 5. Configure your agents

Point your MCP server to your self-hosted instance using `memctl auth` or environment variables:

```bash
MEMCTL_API_URL=https://your-instance.com/api/v1 npx memctl auth
```

Or add `MEMCTL_API_URL` to your MCP config:

```json
{
  "mcpServers": {
    "memctl": {
      "command": "npx",
      "args": ["-y", "memctl@latest"],
      "env": {
        "MEMCTL_API_URL": "https://your-instance.com/api/v1",
        "MEMCTL_ORG": "your-org",
        "MEMCTL_PROJECT": "your-project"
      }
    }
  }
}
```

## Docker

### Quick start (development)

```bash
cp .env.example .env
docker compose up
docker compose exec web pnpm db:push
```

This starts a local libSQL database on port 8080 and the web app on port 3000 with hot reload.

### Production build

```bash
docker build --build-arg NEXT_PUBLIC_APP_URL=https://your-domain.com -t memctl-web .
```

The production image runs a standalone Next.js server as a non-root user on port 3000. See [Local Development](/docs/local-development) for the full Docker Compose setup and configuration details.
