GuidesSQL Server
An AI agent for SQL Server that answers in one T-SQL statement.
DeepORG connects to SQL Server 2012 and later, discovers tables, keys and functions, and compiles each question the agent asks into one T-SQL statement. SQL Server builds the nested JSON itself, and your row rules are part of the statement before it runs.
The short version
What you get on SQL Server.
- T-SQL written by the engine. Nested selections become
CROSS APPLYsubqueries, results are shaped withFOR JSON PATH, and pages useOFFSET … FETCH NEXT. - No SQL from the model. The agent writes a GraphQL query against the catalog. The engine writes the T-SQL and passes values as parameters.
- Rules from the caller. A role’s row filter and column list are compiled into the statement. A column a role cannot read cannot be summed either.
- Changes wait. When DeepORG’s own agent proposes a write, it is rehearsed, rolled back and held until a person approves that exact version.
Connect
Connection and TLS.
curl -fsSL https://deeporg.io/install.sh | bash# config/dev.yml
sources:
- name: erp
kind: database
type: mssql
default: true
# sqlserver://user:pass@host:1433?database=erp
connection_string: ${MSSQL_DSN}
encrypt: true
trust_server_certificate: false
read_only: true # start read-onlyKeep trust_server_certificate: false outside a laptop: it is what makes the client check the server’s certificate. For a first run, connect as a login that is a member of db_datareader only.
deeporg serveYour AI client
Add it to Claude Code or Codex.
claude mcp add deeporg -- deeporg mcp --path /absolute/path/to/config
codex mcp add deeporg -- deeporg mcp --path /absolute/path/to/configYour client’s model does the reasoning; DeepORG supplies the catalog, the checks and the execution. With a server already running, deeporg mcp add claude http://localhost:8080 registers it over HTTP.
Ask
A question, a query, a statement.
“Which suppliers have open purchase orders worth more than $50,000?” The agent finds suppliers and purchase_orders in the catalog, reads the relationship between them, and writes:
query {
purchase_orders(
distinct: [supplier_id]
where: { status: { eq: "open" } }
order_by: { sum_amount: desc }
) {
supplier_id
sum_amount
count_id
}
}SQL Server computes the totals and does the sorting. The agent reads the result, and the answer carries the rows it rests on.
Limits
Where SQL Server differs.
- No full-text search through the query language. Filters, ordering, aggregates, geo filters and subscriptions work; the full-text operators are not mapped to SQL Server.
- Bit columns are booleans. Database functions that return a 0/1 value can be declared
return_type: booleanunderfunctions:so they come back astrueandfalse. - Recursive relationships. Supported, written as a
WITHcommon table expression without theRECURSIVEkeyword. - Tested version. The test suite runs against SQL Server 2022.
Go deeper
Related pages.
- MCP server for PostgreSQL: the five questions to ask any database MCP server.
- Your rules, your approval: how row rules and write approvals work.
- Database config: pools, TLS and table mapping.
- Database support: every dialect side by side.