sql-agent
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| SQL_AGENT_DSN | No | Database connection string, e.g. sqlite:///./shop.db or postgresql://readonly:password@localhost:5432/shop. A path with no scheme is read as SQLite. Required unless demo mode is enabled. | |
| OPENAI_API_KEY | No | API key for the OpenAI-compatible endpoint used by the ask and evaluate tools. Not needed for list_tables, describe_table or run_sql. | |
| SQL_AGENT_DEMO | No | Set to 1 to use the bundled sample database (demo mode). Alternative to SQL_AGENT_DSN. | |
| OPENAI_BASE_URL | No | Base URL for an OpenAI-compatible endpoint, if not using the default OpenAI endpoint. | |
| SQL_AGENT_MODEL | No | Model name for the agent, e.g. deepseek-ai/DeepSeek-V3. | |
| SQL_AGENT_MAX_STEPS | No | Maximum number of steps for the agent loop. Default is 12. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Query a SQL database in plain language, and check the answer.
Two ways to use this server:
askruns an agent that inspects the schema, writes SQL, runs it and answers. It returns the SQL that actually executed (final_sql), the rows, and a trace of every step with its latency and cost. If the agent typed SQL into its answer without running it, that is reported separately asclaimed_sqlandsql_was_executedis false — do not quote unexecuted SQL to the user as evidence.list_tables,describe_tableandrun_sqllet you write the SQL yourself.run_sqlaccepts one read-only SELECT or WITH statement.
evaluate runs a golden set — questions with hand-written reference SQL —
against this database and reports accuracy, the failures and what each cost.
It calls the model once per step of every case, so it is not free.
The database is opened read-only. Writes are refused twice over: by the connection and by a parser that accepts a single SELECT and nothing else.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| askA | Answer a question about the database in plain language. Returns the answer, the SQL that was actually executed, the rows it returned, and a trace of every step with its latency and cost. |
| evaluateA | Run a golden set of questions with hand-written reference SQL against this database and report accuracy, every failure with its reason, the tool path taken and the cost. Pass the path to a YAML file of cases; omit it to use the one bundled with the sample database. Each case runs the full agent loop, so this calls the model once per step of every case and is not free — use |
| list_tablesA | Every table in the database with its row count. On PostgreSQL the count is the planner's estimate, marked |
| describe_tableA | A table's columns, types, foreign keys and three real rows. Read this before writing SQL against a table you have not inspected: the sample rows are what reveal that an INTEGER column holds cents and that a TEXT column holds ISO dates. |
| run_sqlA | Execute one read-only SELECT or WITH statement and return up to 50 rows. Anything else is refused: several statements, a write, a write inside a CTE, ATTACH, PRAGMA, SET, a row lock. When the database rejects the query you get its own error text back, which is usually enough to fix it. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 5 tools
Each tool occupies a clearly distinct niche: list_tables and describe_table differ in granularity (inventory vs. columns/sample rows), run_sql executes agent-authored SQL, ask handles natural-language questions, and evaluate runs a golden-set harness. The ask vs. run_sql boundary is explicitly clarified by the input type (plain language vs. SQL) and the returned sql_was_executed/final_sql fields.
Three tools follow a clean verb_noun pattern (list_tables, describe_table, run_sql), and all five are verb-first imperatives. However, ask and evaluate are bare verbs with implicit nouns, which is a minor deviation from the otherwise predictable scheme.
Five tools is tight and well-scoped for a read-only SQL agent: orient, inspect, execute, ask in natural language, and evaluate accuracy. No tool feels redundant or like filler, and nothing essential is obviously missing at this size.
The surface covers the full read-only lifecycle—discover tables, inspect schemas with sample rows, run SELECT/WITH queries, ask plain-language questions, and validate against golden cases. Minor gaps remain, such as no dedicated EXPLAIN/query-plan or schema-search tool, though agents can approximate both through run_sql against catalog tables.