npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jeffreyhaen/mssql-axi

v0.2.1

Published

Agent-ergonomic CLI for Microsoft SQL Server and Azure SQL — read-by-default, token-efficient TOON output, an AXI (Agent eXperience Interface) backed by the native Microsoft ODBC driver.

Downloads

212

Readme

mssql-axi (SQL Server axi)

ci npm license node

Agent-ergonomic CLI for Microsoft SQL Server and Azure SQL — schema discovery, row previews, read-only queries, showplans, and gated mutations, in token-efficient TOON output.

mssql-axi is a SQL Server AXI (Agent eXperience Interface): a CLI designed for autonomous agents rather than humans. It talks to the server through the native Microsoft ODBC driver, passes connection strings through verbatim, is read-by-default, and answers with minimal schemas plus contextual next-step hints.

Why not an MCP server

A database MCP server loads its full tool schema into the agent's context on every request for the rest of the session (~185k input tokens per task in our measurements). A skill-based AXI costs ~55 tokens until the agent actually uses it. Raw sqlcmd is cheaper still, but is free-form, returns wide ASCII tables, and offers no read-only enforcement.

Install

Install globally (recommended for repeated use):

npm install -g @jeffreyhaen/mssql-axi
mssql-axi --help

For a one-off invocation without installing:

npx -y @jeffreyhaen/mssql-axi --help

Prerequisite: the Microsoft ODBC Driver 17 or 18 for SQL Server on the host (Windows: the MSI from Microsoft; Linux/macOS: unixodbc + the Microsoft driver).

Agent integration

Install the skill so an agent loads the usage guide on demand:

npx skills add jeffreyhaen/mssql-axi --skill mssql-axi -g

Omit -g to install the skill for the current project only. To have the agent start each session with the active connection's home view:

mssql-axi setup hooks

Configure

A connection is resolved in this order (first non-empty wins):

  1. --connection-string "<ODBC string>" — passed to ODBC verbatim
  2. MSSQL_CONNECTION_STRING — same shape
  3. mssql-axi.config.json in the working directory (or --config <path>), with --connection <name> to pick a non-default entry
mssql-axi setup config > mssql-axi.config.json   # writes an example to edit
mssql-axi doctor --connection dev
{
  "default": "dev",
  "connections": {
    "dev": "Driver={ODBC Driver 17 for SQL Server};Server=localhost\\SQLEXPRESS;Database=app;Trusted_Connection=Yes;TrustServerCertificate=Yes;",
    "azure": "Driver={ODBC Driver 18 for SQL Server};Server=tcp:myapp.database.windows.net,1433;Database=app;Authentication=ActiveDirectoryInteractive;Encrypt=Yes;"
  }
}
  • Local SQL Server works over Shared Memory with Windows Auth (Trusted_Connection=Yes), including named instances (Server=HOST\INSTANCE).
  • Azure SQL works with Authentication=ActiveDirectoryInteractive|Integrated| Default|ServicePrincipal|Password|ManagedIdentity|DeviceCodeFlow.
  • Secrets live in the connection string, in a shell-interpolated env var ("...Password=${MSSQL_AGENT_PWD};..."), or in a secret manager that exports MSSQL_CONNECTION_STRING. Password=, Pwd=, and UID= are redacted from every error message.
  • See docs/connection-strings.md for the ODBC 17 vs 18 keyword differences and one line per supported auth flow.

The mssql Node package was dropped in favour of odbc: it cannot speak Shared Memory to a local SQL Server, cannot use the current Windows identity, and ODBC covers every scenario it does.

Use

mssql-axi                                    # home: server, database, largest tables
mssql-axi doctor                             # connectivity + read-only role check
mssql-axi list tables                        # tables | views | indexes | schemas
mssql-axi list views --schema sales --limit 50
mssql-axi inspect dbo.Users                  # columns, primary key, foreign keys
mssql-axi inspect view dbo.vActiveUsers
mssql-axi sample dbo.Users --limit 5
mssql-axi sample dbo.Users --where "createdAt > '2026-01-01'" --full
mssql-axi query "SELECT TOP 10 id, email FROM dbo.Users"
mssql-axi explain "SELECT * FROM dbo.Users WHERE email = '[email protected]'"
mssql-axi plan "ALTER TABLE dbo.Users ADD nickname NVARCHAR(50) NULL"
mssql-axi execute "UPDATE dbo.Users SET active = 0 WHERE id = 42" \
  --confirm "UPDATE dbo.Users SET active = 0 WHERE id = 42" --execute
mssql-axi setup role                         # T-SQL to create the agent_reader role
mssql-axi update --check                     # check for a newer version

Every command supports --help. SQL and object names may be passed positionally (query "SELECT 1", inspect dbo.Users) or through flags (--sql, --schema/--name); [bracketed].[names] are accepted and the schema defaults to dbo. Lists support --limit; row output truncates long cells at 200 characters unless --full is given.

Read-only guarantee (two layers)

  1. Database-side — a dedicated agent_reader role with db_datareader and db_denydatawriter. Set up once with mssql-axi setup role; mssql-axi doctor reports whether the current login is a member.
  2. Application-side — a validator on every read command. Only SELECT (optionally with a leading WITH cte AS (...)), EXPLAIN, and SET SHOWPLAN_XML ON are accepted. INSERT, UPDATE, DELETE, MERGE, DROP, TRUNCATE, EXEC, stacked statements, and ;GO are refused with a structured error before any connection is opened.

Safe mutations

execute is dry-run by default and prints the normalised T-SQL. Committing requires --confirm "<the same statement>" (compared after comments are stripped and whitespace is normalised) and --execute. Destructive shapes — DROP, TRUNCATE, and DELETE/UPDATE without a WHERE — additionally require --allow-destructive. --max-rows-affected (default 10,000) refuses to report success for a runaway statement, and --timeout (default 30s) bounds the run.

Design

Built against the ten AXI principles: TOON output, minimal default schemas, truncation with --full, pre-computed aggregates (row counts, totals), definitive empty states, structured errors on stdout with exit code 2 for usage errors, a content-first no-argument home view, contextual next-step hints, and concise per-command help.

Development

pnpm install
pnpm run typecheck
pnpm run build
pnpm test
pnpm run dev -- list tables --connection-string '...'

Tests run the command layer against an injected fake ODBC driver (test/fakeDb.ts), so no live SQL Server is needed. CI runs build, typecheck, tests, and a CLI smoke test on Node 20 and 22 (Linux) and Node 20 (Windows).

License

MIT © Jeffrey Haen

See CHANGELOG.md for release notes.