aifordatabase-mcp
v0.1.2Query any database in plain English or SQL through a guardrailed, read-only data layer.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_connections
List the database connections available to this API key. Returns id, name, type (POSTGRES/MYSQL/MARIADB/MSSQL/MONGODB/SQLITE), host, database, isActive. Use the returned id as connectionId in other tools.
| Parameter | Type | Description |
|---|---|---|
page | number | Page number (default 1) |
pageSize | number | Items per page (default 20) |
get_schema
Get the cached schema (tables, columns, relationships) of a database connection. Call this once before writing SQL — no discovery queries needed.
| Parameter | Type | Description |
|---|---|---|
connectionId * | string | Connection id from list_connections |
run_query
Run a SQL query directly against a database connection. Deterministic, no AI in the loop, no credits consumed. Returns columns, rows, rowCount, executionTime. On a SQL error the database's own message is returned — fix the SQL and retry. Rows cap at 500, so aggregate in SQL rather than pulling raw tables.
| Parameter | Type | Description |
|---|---|---|
connectionId * | string | Connection id from list_connections |
sql * | string | The SQL statement to execute |
ask
Ask a question about a database in plain English. The API's own agent translates it to SQL, runs it, and returns the answer (content), the SQL used (sqlQuery), and the results (queryResult). For follow-up questions, pass the conversationId from the previous response. Consumes AI credits — for repeated/known queries prefer run_query.
| Parameter | Type | Description |
|---|---|---|
connectionId * | string | Connection id from list_connections |
message * | string | The question in plain English, e.g. 'Top 10 customers by revenue in the last 30 days' |
conversationId | string | Optional: conversationId from a previous ask response, to keep context for follow-ups |
list_workflows
List workflows (scheduled database alerts / reports). Returns each workflow with its trigger type and step/action counts.
| Parameter | Type | Description |
|---|---|---|
page | number | Page number (default 1) |
pageSize | number | Items per page (default 20) |
create_workflow
Create a workflow: SQL steps + EMAIL/WEBHOOK actions, run manually or on a cron schedule. To make an alert, write a step query that only returns rows when the condition fires and set stopIfEmpty=true — actions then run only when rows come back. Step results are auto-appended to the email/webhook payload. Point a WEBHOOK at a Slack incoming-webhook URL for Slack alerts. Free plan allows 3 workflows.
| Parameter | Type | Description |
|---|---|---|
name * | string | Workflow name |
triggerType * | string | MANUAL (run on demand) or SCHEDULE (cron) |
actions | array | Actions fired after steps complete |
connectionId | string | Connection id the step queries run against |
description | string | Optional description |
steps | array | SQL steps, run in order |
triggerConfig | string | For SCHEDULE: JSON string with a cron expression, e.g. {"cron": "0 9 * * *"} |
run_workflow
Run a workflow immediately (regardless of its schedule) and return the run record with its status.
| Parameter | Type | Description |
|---|---|---|
workflowId * | string | Workflow id from list_workflows or create_workflow |
list_dashboards
List dashboards. Dashboards re-run their widget queries on schedule server-side. To create one, the fastest path is the ask tool: 'create a dashboard showing revenue by month' with a connectionId.
| Parameter | Type | Description |
|---|---|---|
page | number | Page number (default 1) |
pageSize | number | Items per page (default 20) |
get_usage
Get the current AI-credit budget: included, topUp, used, and remaining (in cents) for the current billing period. Check this to self-throttle ask calls before hitting a 402.