Estimated time to complete: 5 minutes

Overview

Welcome to Magma! 🌋

This template will help you create:

  • An AI agent hosted on Magma
  • A secure connection to your Supabase database
  • Natural language interactions with your database to run complex queries

Prerequisites:

  • A Supabase project with database access
  • Your database’s master password
  • If you’ve lost the password, reset it in the Supabase dashboard before continuing

Getting Started

1

Install the CLI

If you have already installed the CLI, you can skip this step

npm install -g @pompeii-labs/cli
2

Login to Magma

magma login
3

Use the magma init command to create a new agent using the supabase-db template
4

Use the Supabase Template

magma init --template supabase-db [agent-name]

cd [agent-name]

Supabase Configuration

Getting Your Connection String

1

Access Supabase Dashboard

  1. Go to your Supabase project dashboard
  2. Click the “Connect” button at the top of the screen
2

Find Connection Details

Locate the “Transaction Pooler” section in the connection panel

Make sure to use the Transaction Pooler connection string, not the direct connection string!

3

Copy Connection String

Copy the entire postgres connection string (starts with postgresql://)

4

Set Environment Variable

Add the connection string to your .env file:

POSTGRES_URL=postgresql://postgres.your-project-id:[YOUR-PASSWORD]...
5

Update database password

Replace [YOUR-PASSWORD] with your database’s master password in the POSTGRES_URL environment variable.

Testing and Deployment

1

Local Testing

Test your agent locally first:

magma run
2

Deploy

When everything works locally, deploy to Magma:

magma deploy

Now, your agent is deployed on Magma and ready to use!

Troubleshooting