CLI and MCP server

Use Querly from scripts, CI, terminals, and local AI tools with safe defaults.

Install the CLI

querly-cli ships inside Querly.app. Open Settings → Integrations and click Install for Terminal. Querly links /usr/local/bin/querly-cli to the copy inside the app, and macOS asks for your password if that folder is protected.

Common commands

Terminal
querly-cli connections
querly-cli --connection "Shop (local)" tables
querly-cli --connection "Shop (local)" query "SELECT count(*) FROM users"
querly-cli ./app.sqlite tables
querly-cli postgresql://user@localhost/app describe users
querly-cli ./app.sqlite export users --format csv --limit 10000
querly-cli ./app.sqlite schema-all

--connection uses a connection you saved in Querly, by name. The password is read from the macOS Keychain, and SSH tunnels, TLS, and cloud sign-in work as in the app. querly-cli connections lists your saved connections and their AI access. You can also pass a SQLite file or a connection URL. When the connection argument is omitted, the CLI reads QUERLY_DB_URL, and warns you if that value contains a password. Export formats are text, CSV, JSON, and SQL INSERT statements.

Build from source (advanced)

Terminal
swift build -c release --product querly-cli

Run the MCP server

The easy way

Use Connect an AI agent in Settings. It writes the right setup for your agent and keeps your password out of the config. See Connect an AI agent.

The MCP server communicates over standard input and output. Read tools are enabled by default. Write tools require the explicit --allow-write launch flag. Giving an agent Read & write access on a saved connection is included with a licence; read access is free.

MCP configuration
{
  "mcpServers": {
    "querly": {
      "command": "/usr/local/bin/querly-cli",
      "args": ["mcp"],
      "env": {
        "QUERLY_DB_URL": "postgresql://user:password@localhost/app"
      }
    }
  }
}
Keep credentials out of shared files

Prefer an environment-injection or secret-management feature from your MCP host. Do not commit a connection URL containing a password.

Read bounds

MCP accepts one SELECT or WITH statement at a time, rejects destructive SQL, caps the outer result to 5,000 rows, and stops any query that runs longer than 30 seconds. It works with SQLite, PostgreSQL, MySQL, and MariaDB, and the database itself enforces read-only access.

↑↓ move↩ open