Skip to content

ajan-sqlAI-safe MCP server for schema-aware, read-only SQL access.

Run a multi-dialect SQL MCP server over stdio with guarded queries, schema discovery, and structured tool outputs for AI workflows.

Quick Start

Install:

bash
npm install -g ajan-sql

Run:

bash
DATABASE_DIALECT=postgres \
DATABASE_URL=postgres://USER:PASSWORD@HOST:PORT/DB ajan-sql

MySQL:

bash
DATABASE_DIALECT=mysql \
DATABASE_URL=mysql://USER:PASSWORD@HOST:PORT/DB ajan-sql

SQLite:

bash
DATABASE_DIALECT=sqlite \
DATABASE_URL=file:/absolute/path/to/database.sqlite ajan-sql

DATABASE_DIALECT defaults to postgres. Supported values today are postgres, mysql, and sqlite.

MCP Client Example

Add ajan-sql to your MCP client as a stdio server:

json
{
  "mcpServers": {
    "ajan-sql": {
      "command": "ajan-sql",
      "env": {
        "DATABASE_DIALECT": "postgres",
        "DATABASE_URL": "postgres://USER:PASSWORD@HOST:PORT/DB"
      }
    }
  }
}

If your client should run a repository-local build instead of a globally installed binary, use:

json
{
  "mcpServers": {
    "ajan-sql": {
      "command": "node",
      "args": ["/absolute/path/to/ajan-sql/dist/index.js"],
      "env": {
        "DATABASE_DIALECT": "postgres",
        "DATABASE_URL": "postgres://USER:PASSWORD@HOST:PORT/DB"
      }
    }
  }
}

For MySQL, set DATABASE_DIALECT to mysql. For SQLite, set DATABASE_DIALECT to sqlite and use a file URL such as file:/absolute/path/to/database.sqlite.

Available Tools

  • list_tables
  • describe_table
  • list_relationships
  • server_info
  • search_schema
  • run_readonly_query
  • explain_query
  • sample_rows

Available Resources

  • schema://snapshot
  • schema://table/{name}

Detailed resource payload examples are available in Resources.