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

zapql-mcp

v0.1.5

Published

ZapQL — Autonomous SQL Server query optimizer via MCP

Downloads

625

Readme

ZapQL MCP Server

Autonomous SQL Server query optimizer via the Model Context Protocol. Connect Claude (or any MCP-compatible agent) directly to your SQL Server and get instant query analysis and AI-powered optimization suggestions.

Quick Start

1. Get an API key

Sign up at zapql.com and create an API key on the dashboard.

2. Add to your editor

Cursor — add to .cursor/mcp.json:

{
  "mcpServers": {
    "zapql": {
      "command": "npx",
      "args": ["zapql-mcp"],
      "env": {
        "ZAPQL_API_KEY": "<key from zapql.com dashboard>",
        "SQL_CONNECTION_STRING": "Server=your-server;Database=your-db;User Id=your-user;Password=your-pass;TrustServerCertificate=true"
      }
    }
  }
}

Claude Desktop — edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "zapql": {
      "command": "npx",
      "args": ["zapql-mcp"],
      "env": {
        "ZAPQL_API_KEY": "<key from zapql.com dashboard>",
        "SQL_CONNECTION_STRING": "Server=your-server;Database=your-db;User Id=your-user;Password=your-pass;TrustServerCertificate=true"
      }
    }
  }
}

3. Restart your editor

ZapQL tools will appear automatically. Ask your AI agent to "connect to my database and find the slowest queries."

Optional environment variables

LITELLM_API_KEY=your-openai-key   # BYOK — use your own LLM for optimization
LITELLM_MODEL=gpt-4               # default: gpt-4
ZAPQL_TOP_N=20                     # max optimization suggestions

Tools

connect_database

Establish a connection to a SQL Server instance.

Input:  connectionString (string)
Output: connection status, server info, database name

analyze_query

Analyze a SQL query for performance issues without executing it.

Input:  connectionString (string), queryText (string)
Output: issues list, complexity score, execution plan, suggestions

Detects: SELECT *, missing WHERE clause, leading wildcards, N+1 patterns, NOT IN subqueries, excessive OR conditions, implicit conversions.

optimize_query

Get AI-powered optimization suggestions for a slow query.

Input:  connectionString (string), originalQuery (string), context? (string)
Output: optimizedQuery, explanation, performance comparison, cost improvement estimate

Requires LITELLM_API_KEY. Results are cached in SQLite at ~/.zapql/cache.db.


MCP Resources

| Resource | Description | |----------|-------------| | zapql:///connections | List of active database connections | | zapql:///queries/{connection} | Recent queries for a connection | | zapql:///optimization/{queryId} | Cached optimization result |


Architecture

Claude Desktop
     │  MCP Protocol (stdio)
     ▼
ZapQL MCP Server (Node.js)
     ├── Tools: connect_database, analyze_query, optimize_query
     ├── Resources: connections, queries, optimization results
     ├── SQLServerDriver (mssql) ──→ Your SQL Server
     ├── QueryCache (in-memory + SQLite persistence)
     └── LiteLLM ──→ OpenAI / any LLM provider

Development

npm run build       # Compile TypeScript
npm test            # Run unit tests (node:test)
npm run dev         # Run with tsx (no compile step)
npm run lint        # Type-check without emit

Tests run against dist/ (compiled output). No SQL Server connection required for unit tests — the SQL driver is mocked.


Environment Variables

| Variable | Required | Default | Description | |----------|----------|---------|-------------| | SQL_CONNECTION_STRING | ✅ | — | mssql connection string | | ZAPQL_API_KEY | ✅ | — | Internal API key (any string) | | LITELLM_API_KEY | — | — | Enables optimize_query | | LITELLM_MODEL | — | gpt-4 | LLM model for optimization | | ZAPQL_TOP_N | — | 20 | Max optimization suggestions |

Config file: ~/.zapql/.env (loaded automatically on startup)


Logs

Log files at ~/.zapql/logs/zapql-YYYY-MM-DD.log. Structured JSON. Rotates daily, keeps 7 days.


Status

  • ✅ MCP tools: connect_database, analyze_query, optimize_query
  • ✅ MCP resources: connections, queries, optimization
  • ✅ SQLite state persistence
  • ✅ In-memory query cache with TTL
  • ✅ Comprehensive error handling
  • ⏳ Integration tests (US-016)