The grain command
One command for people and scripts
The installer puts the grain command on your PATH. Every tool that Grain offers to agents over MCP also has a grain command, so you can do the same things from a terminal. Add --json to any data command to get the same structured output an agent receives.
grain connections list
grain query "select count(*) from orders" --connection warehouse
grain tables --connection warehouse --schema public --json
Data commands
| Command | What it does |
|---|---|
grain connectors |
Lists the database types Grain supports |
grain connections list |
Lists your saved connections |
grain connections add --type T [--name N] [--field k=v ...] |
Creates a connection and opens its setup page |
grain connections test <id> |
Tests a saved connection |
grain connections credentials <id> |
Opens a setup page to enter or update a password |
grain connections remove <id> |
Removes a saved connection |
grain schemas --connection <id> |
Lists the schemas in a database |
grain tables --connection <id> --schema <name> |
Lists the tables in a schema |
grain describe <table> --connection <id> --schema <name> |
Shows the columns of a table |
grain query "<sql>" [--connection <id>] [--limit <n>] |
Runs a query |
grain demo |
Sets up the built-in demo data |
When Grain refuses a command, e.g., a write while safe mode is on, it exits with status 1 and prints the reason.
Service and setup commands
| Command | What it does |
|---|---|
grain connect |
Connects Grain to the AI agents you choose |
grain disconnect |
Removes Grain from your AI agents |
grain ui |
Opens the browser workspace, which is in beta |
grain start, grain stop, grain restart |
Starts, stops or restarts the Grain service |
grain status |
Shows whether the Grain service is running |
grain add-to-path |
Adds the grain command to your PATH |
grain uninstall |
Removes Grain and lists what it kept |
grain uninstall keeps your connections and downloaded drivers, and it prints where they are. grain uninstall --purge asks for confirmation and then removes all of Grain’s local data.