Querying
All reading is done as one of two read-only roles. Sid sends the password separately. Do not paste it into a prompt, a notebook, or a commit.
| Role | Can read |
|---|---|
catalog_reader |
Tables built only from public sources, plus all catalog.* metadata |
licensed_reader |
The same, plus lightcast_derived tables. For people covered by a Lightcast license. |
A catalog_reader query against a Lightcast-derived table fails with
"permission denied". That is the license gate working, not an error.
Connection details
| Setting | Value |
|---|---|
| Host | aws-0-<region>.pooler.supabase.com |
| Port | 5432 |
| Database | postgres |
| User | <role>.<project_ref>, e.g. catalog_reader.<project_ref> |
| Password | Sent by Sid |
Sid fills in <region> and <project_ref> when he sends the password. This
is the session pooler. It works on ordinary home and office networks.
First queries
-- What datasets exist?
SELECT id, schema, title, grain, current_vintage, license_class
FROM catalog.datasets;
-- What do the columns of one dataset mean?
SELECT name, type, definition, units
FROM catalog.variables
WHERE dataset_id = '<dataset id>'
ORDER BY ordinal;
-- Everything at once.
SELECT * FROM catalog.overview;
Each dataset page on this site has a ready-made query for its table.
Option 1: Supabase dashboard SQL editor
For Sid. Collaborators are not added to the Supabase project, because the editor logs in as the admin role. Use Option 2 or 3.
- Open the project, then SQL Editor.
-
Run this first, in the same query tab:
SET ROLE catalog_reader; -
Run your query. To confirm the role, run
SELECT current_user;.
The editor starts as the postgres role, which can change data. Setting the
role first makes a mistake harmless.
Option 2: psql
psql "host=aws-0-<region>.pooler.supabase.com port=5432 dbname=postgres user=catalog_reader.<project_ref> sslmode=require"
psql asks for the password. Any other Postgres client (DBeaver, TablePlus, R, Python) takes the same settings.
Option 3: an AI agent through a read-only MCP server
An MCP server lets an agent such as Claude run queries for you, as your
read-only role, never the postgres one.
For most collaborators the Setup page is easier: Claude does it all, with no GitHub account. The rest of this section is the manual route.
Prerequisites (Mac or Linux): Claude Code, git, uv
(https://docs.astral.sh/uv/, which provides the uvx command the server
runs with), and a GitHub account Sid has added to the catalog repo.
With the repo: clone it, copy .env.example to .env, and
put your connection string in CATALOG_READER_URL (use your
licensed_reader connection there if you have one). Claude Code picks up
the repo's .mcp.json and starts the server for you; any other MCP
client can run the same scripts/catalog-mcp.sh.
The repo also ships the moonlight-data skill, which Claude Code loads on
its own. Without the repo, the Setup page has Claude
install the skill and the server for you.
Without the repo, this config does the same thing:
{
"mcpServers": {
"moonlight-catalog": {
"command": "uvx",
"args": ["--with", "mcp[cli]==1.9.4", "--with", "pydantic==2.10.6",
"postgres-mcp",
"postgresql://<role>.<project_ref>:<password>@aws-0-<region>.pooler.supabase.com:5432/postgres"]
}
}
}
Keep that file out of git, since it holds the password. The two pins work around an import crash in postgres-mcp 0.3.0.
Tell the agent to read the comment on the catalog schema first. It
explains the rules below in plain words.
Rules that apply to every query
- Check
grainbefore joining. See Conventions. - Check that
_vintagematches before combining two datasets. - Use the
citationfield verbatim. - Check
license_classbefore sharing results. See Licenses.