ajan-sql

ajan-sql

An MCP server that provides safe, read-only SQL access for AI agents to query databases (PostgreSQL, MySQL, SQLite) with schema awareness and guardrails.

Category
Visit Server

README

<p align="center"> <img src="./assets/cover.svg" alt="ajan-sql cover" width="860" /> </p>

<p align="center"> <b>Safe, read-only SQL access for AI agents β€” via MCP.</b> </p>

<p align="center"> <a href="https://www.npmjs.com/package/ajan-sql"><img src="https://img.shields.io/npm/v/ajan-sql" /></a> <a href="https://www.npmjs.com/package/ajan-sql"><img src="https://img.shields.io/npm/dt/ajan-sql" /></a> <a href="https://borakilicoglu.github.io/ajan-sql/"><img src="https://img.shields.io/badge/docs-vitepress-5d98ea" /></a> <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-lightgrey" /></a> </p>


⚑ What is ajan-sql?

ajan-sql is an MCP server that lets AI agents safely query your database.

πŸ‘‰ read-only
πŸ‘‰ schema-aware
πŸ‘‰ guardrailed

Supports:

  • PostgreSQL
  • MySQL
  • SQLite

πŸš€ Quick Start

DATABASE_URL=postgres://USER:PASSWORD@HOST:PORT/DB npx ajan-sql

That’s it.


🧠 What it solves

AI agents querying databases is risky.

Without guardrails:

  • they can modify data
  • run heavy queries
  • break your system

πŸ‘‰ ajan-sql fixes this by enforcing strict rules.


πŸ”₯ Safety by default

All queries are:

  • SELECT only
  • no INSERT, UPDATE, DELETE
  • no DROP, ALTER, TRUNCATE
  • limited results (LIMIT 100)
  • timeout enforced (max 5s)
  • no multi-statement queries
  • no SQL comments

πŸ‘‰ These rules cannot be bypassed.


πŸ”’ Sandboxing & Approvals

ajan-sql enforces sandboxing at the SQL access layer:

  • every query is validated before execution
  • query execution is readonly and bounded
  • results are limited by row count, timeout, and size
  • optional schema/table access policies can restrict readable tables

Human approval flows are handled by the MCP host or client. ajan-sql does not provide its own approval UI.

For production use, connect with a database user that only has readonly permissions. Database permissions should be the final safety backstop.


⚑ Available Tools

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

🧠 Example

{
  "tool": "run_readonly_query",
  "arguments": {
    "sql": "SELECT * FROM users LIMIT 10"
  }
}

Tool responses include both standard MCP structuredContent and an embedded text/toon version of the same payload.


🌐 Supported Databases

# PostgreSQL
DATABASE_DIALECT=postgres
DATABASE_URL=postgres://USER:PASSWORD@HOST:PORT/DB

# MySQL
DATABASE_DIALECT=mysql
DATABASE_URL=mysql://USER:PASSWORD@HOST:PORT/DB

# SQLite
DATABASE_DIALECT=sqlite
DATABASE_URL=file:/absolute/path/to/database.sqlite

Optional readonly policy controls:

AJAN_SQL_ALLOWED_SCHEMAS=public,analytics
AJAN_SQL_ALLOWED_TABLES=public.users,analytics.events
AJAN_SQL_DENIED_TABLES=public.audit_logs
AJAN_SQL_AUDIT_LOG=true

βš™οΈ Features

  • MCP-native SQL access
  • multi-database support
  • strict read-only guardrails
  • schema discovery + introspection
  • structured JSON output for AI agents
  • TOON-formatted embedded tool results
  • predictable execution limits
  • type-safe schemas

🧠 Use Cases

  • AI copilots querying databases
  • internal data assistants
  • analytics agents
  • safe DB access in automation
  • MCP-based workflows

πŸ“¦ Install

npm install -g ajan-sql

or:

npx ajan-sql

🧩 Client Example

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

πŸ’‘ Philosophy

AI should never have unsafe database access.

ajan-sql ensures queries are safe, predictable, and controlled.


❀️ Support

If this tool helps you:

⭐ Star the repo
β˜• Support via GitHub Sponsors

https://github.com/sponsors/borakilicoglu


πŸ”— Links

  • GitHub: https://github.com/borakilicoglu/ajan-sql
  • npm: https://www.npmjs.com/package/ajan-sql
  • Docs: https://borakilicoglu.github.io/ajan-sql/

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured