@pilat/mcp-datalink

@pilat/mcp-datalink

MCP server for PostgreSQL, MySQL, and SQLite that gives AI assistants secure database access via the Model Context Protocol.

Category
Visit Server

README

@pilat/mcp-datalink

MCP server for PostgreSQL, MySQL, and SQLite. Gives AI assistants secure database access via Model Context Protocol.

npx @pilat/mcp-datalink

Works with Claude Desktop, Claude Code, Cursor, Cline, and any MCP-compatible client.

Installation

Add to your MCP client config file (see config locations below):

{
  "mcpServers": {
    "datalink": {
      "command": "npx",
      "args": ["-y", "@pilat/mcp-datalink"],
      "env": {
        "DATALINK_ANALYTICS_URL": "postgresql://user:password@localhost:5432/analytics",
        "DATALINK_ANALYTICS_READONLY": "true",

        "DATALINK_INVENTORY_URL": "mysql://user:password@localhost:3306/inventory",

        "DATALINK_CACHE_URL": "sqlite:///path/to/cache.db"
      }
    }
  }
}

This creates three database connections: analytics (read-only), inventory, and cache.

Variable Description
DATALINK_{NAME}_URL Connection URL (creates database named {name})
DATALINK_{NAME}_READONLY Set to true to block writes
DATALINK_{NAME}_MAX_TIMEOUT Max query timeout in ms (caps model requests)

Connection URL formats:

# PostgreSQL
postgresql://user:password@localhost:5432/dbname
postgresql://user:password@localhost:5432/dbname?sslmode=require

# MySQL
mysql://user:password@localhost:3306/dbname
mysql://user:password@localhost:3306/dbname?ssl=true

# SQLite
sqlite:///path/to/database.db
sqlite:///Users/me/data/app.sqlite
sqlite://../relative/path/data.db

Environment Variable Substitution

URLs support ${VAR} syntax to reference other environment variables:

{
  "mcpServers": {
    "datalink": {
      "command": "npx",
      "args": ["-y", "@pilat/mcp-datalink"],
      "env": {
        "DATALINK_MAIN_URL": "${DATABASE_URL}"
      }
    }
  }
}

This allows reusing existing environment variables (like DATABASE_URL from your shell or .env file).

Supported syntax:

Syntax Description
${VAR} Expands to value of VAR, or keeps ${VAR} if unset
${VAR:-default} Expands to value of VAR, or default if unset

Examples:

# Reference existing DATABASE_URL
DATALINK_MAIN_URL="${DATABASE_URL}"

# Build URL from parts
DATALINK_MAIN_URL="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}:5432/mydb"

# With default values
DATALINK_MAIN_URL="postgresql://localhost:${DB_PORT:-5432}/mydb"

Config File Locations

Client Config file
Claude Code ~/.claude.json (global) or .mcp.json (project)
Claude Desktop (macOS) ~/Library/Application Support/Claude/claude_desktop_config.json
Claude Desktop (Windows) %APPDATA%\Claude\claude_desktop_config.json
Cursor ~/.cursor/mcp.json or Settings → Features → MCP Servers
Cline cline_mcp_settings.json or VS Code settings cline.mcpServers

Tools

Tool Description
list_databases List configured database connections
list_tables List tables with row counts
describe_table Get schema, indexes, foreign keys
query Run SELECT queries
execute Run INSERT/UPDATE/DELETE
explain Show query execution plans

Security

  • Prepared statements only (no SQL injection)
  • Single statement per query (no chaining)
  • DDL blocked (no DROP, ALTER, TRUNCATE)
  • Readonly mode per connection
  • Response size limit (100 rows, 64KB default, configurable via DATALINK_MAX_TOTAL_SIZE)
  • Query timeout: 30s default, model can request up to 10min, MAX_TIMEOUT caps it

License

MIT

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
Qdrant Server

Qdrant Server

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

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