Skip to content

About

An open-source MCP server, API, and CLI for records, files, permissions, and reminders. Single binary, self-hosted.

Topics

Resources

Stars

8 stars

Watchers

0 watching

Forks

Repository files navigation

The Last SaaS

The Last SaaS is a TypeScript backend for records, files, team permissions, notifications, and audit logs, accessed through an HTTP API, MCP, or CLI. It runs on Bun and supports SQLite(mostly for dev and evaluation) and PostgreSQL(preferred).

Local development

Requires Bun 1.4 or later. From the repository root:

bun install
cd packages/server
cp .env.example .env
mkdir -p data
DATABASE_URL=file:../data/lastsaas.db bunx prisma migrate deploy
bun run prisma:generate
bun run dev

The server runs with file watching at http://localhost:8787. Sign up at /auth/signup; the MCP endpoint is /v1/mcp. On subsequent runs, start it from the repository root with bun run dev.

Bun loads packages/server/.env when starting the server. The example uses SQLite, local file storage, and console output for email. See the configuration reference for environment variables. The migration command uses a path relative to the Prisma schema directory; the runtime SQLite path is relative to packages/server.

Disable password authentication

Set PASSWORD_AUTH_ENABLED=false in the server environment and restart to disable password signup, login, reset, and password changes. Password forms are hidden; Google (when configured) and magic-link authentication remain available. Existing accounts, passwords, sessions, and API keys are retained. The default is true; set it back to true and restart to re-enable password authentication.

Repository layout

  • packages/server/ — HTTP API, MCP, authentication, storage, and background jobs.
  • packages/client/ — the saas CLI.
  • packages/shared/ — shared types, validation, and errors.
  • packages/server/prisma/ — database schema and SQLite migrations.
  • scripts/ — build, generation, and backend test scripts.
  • skills/lastsaas/ — operator guide embedded in the CLI.
  • agent_docs/ and docs/ — implementation and behavior references.

Checks

Run from the repository root:

bun run test               # shared, server, and client tests
bun run typecheck
bun run lint
bun run format:check

Use bun run test:shared, bun run test:server, or bun run test:client to run one package's tests. These test commands require Bun 1.4 or later and run files across the available CPU cores with a fresh global and module registry per file. Tests within a file remain sequential so they can share fixtures, and each test retains a bounded 30-second timeout to accommodate worker contention. Override the worker count with bun run test --parallel=4 (or --parallel=1 for a serial isolated run); the same option works with the package test commands. See Bun's parallel test documentation. Use bun run format to apply formatting.

The regular suite uses temporary SQLite fixtures. Run PostgreSQL checks with the dedicated runners below, which generate the PostgreSQL client and keep files sharing a database schema sequential. Do not set their fixture URL variables (QUERY_TEST_DATABASE_URL, QUEUE_TEST_DATABASE_URL, SCHEDULE_TEST_DATABASE_URL, or TRANSACTION_TEST_DATABASE_URL) when running the parallel SQLite suite.

Working with the CLI

saas login defaults to https://app.thelastsaas.com when no server is saved. Use --server to select a local or self-hosted deployment.

With the development server running, build and log in from another terminal:

bun run build:client       # produces dist/saas
dist/saas login --server http://localhost:8787

See the CLI command reference. See notifications for team audiences and destination permissions. See durable queue workers, application automation, and secret backup and rotation for operator workflows. The embedded operator guide is available through dist/saas skills.

Database development

packages/server/prisma/schema.prisma is the canonical SQLite schema. After pulling SQLite migrations, apply them and regenerate the client:

cd packages/server
DATABASE_URL=file:../data/lastsaas.db bunx prisma migrate deploy
bun run prisma:generate

For PostgreSQL development, set DATABASE_URL in packages/server/.env to your development database URL, then run from the repository root:

bun run --cwd packages/server prisma:push:postgres
bun run --cwd packages/server prisma:generate:postgres
bun run dev

These scripts generate schema.postgres.prisma from the canonical schema. Re-run them after schema changes; do not apply SQLite migrations to PostgreSQL. Regenerate the SQLite client with prisma:generate when switching back.

Run PostgreSQL backend contract tests separately from the regular test suite:

TEST_POSTGRES_URL=postgresql://user:password@localhost:5432/lastsaas_test bun run test:postgres

The test script creates and drops an isolated schema and restores the SQLite Prisma client on exit. See database backends and repository scripts for details.

Builds

bun run build:client           # dist/saas for the current platform
bun run build:client:all       # CLI binaries for all supported platforms
bun run build:server           # dist/saas-server with a SQLite Prisma client
bun run build:server:postgres  # dist/saas-server with a PostgreSQL Prisma client

Server builds embed the CLI binaries for download. The database provider is fixed when the Prisma client is generated, so choose the matching server build.

Implementation references

About

An open-source MCP server, API, and CLI for records, files, permissions, and reminders. Single binary, self-hosted.

Topics

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages