Datalink

Provides secure access to PostgreSQL, MySQL, and SQLite databases for MCP clients via the Model Context Protocol.
  • javascript

0

GitHub Stars

javascript

Language

4 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "pilat-mcp-datalink": {
      "command": "npx",
      "args": [
        "-y",
        "@pilat/mcp-datalink"
      ],
      "env": {
        "DATALINK_CACHE_URL": "sqlite:///path/to/cache.db",
        "DATALINK_ANALYTICS_URL": "postgresql://user:password@localhost:5432/analytics",
        "DATALINK_INVENTORY_URL": "mysql://user:password@localhost:3306/inventory",
        "DATALINK_ANALYTICS_READONLY": "true"
      }
    }
  }
}

You can securely connect your MCP clients to PostgreSQL, MySQL, and SQLite databases through the Datalink MCP server. It bridges database access with model contexts, enabling AI assistants to query and manage data safely with built-in protections and clear connection management.

How to use

Install and run the Datalink MCP server to enable your MCP clients to access your databases. You will manage three connections: analytics (read-only), inventory, and cache. Use your MCP client to connect to the server using the provided command and environment variables. The server enforces security rules such as prepared statements, single-statement limits, and per-connection read-only modes. You can also leverage URL-based configuration and environment variable substitution to reuse existing connection details.

How to install

Prerequisites: Make sure you have Node.js and npm installed on your system.

Start the MCP server using the recommended command. This example shows how you would run the server directly via npm tooling.

npx @pilat/mcp-datalink

Configuration and connections

The server creates three database connections named after their roles: analytics, inventory, and cache. You configure each connection with a URL, an optional read-only flag, and an optional maximum timeout.

{
  "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"
      }
    }
  }
}

Connection URL formats and environment substitution

Connection URLs follow standard database URL formats for PostgreSQL, MySQL, and SQLite. You can also substitute environment variables inside URLs using the ${VAR} syntax to reuse existing values from your shell or .env files.

# 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

Config file locations

Place or edit the MCP client configuration in the appropriate location for your client. The following paths are commonly used by different clients.

Claude Code | `~/.claude/settings.local.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`

Environment variable substitution details

You can build a main URL from parts or reference an existing variable using the ${VAR} syntax. This helps you reuse existing environment configurations.

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

Examples of environment variable usage

Reference an existing URL from your environment or build a URL from components using default values when needed.

# 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"

Security

The Datalink MCP server enforces strong safety rules: prepared statements only to prevent SQL injection, one statement per query, DDL operations are blocked, and per-connection read-only mode is supported. You can also limit the query results and enforce a maximum timeout to prevent long-running queries.

Notes on usage and limits

Default query timeout is 30 seconds. The model can request up to 10 minutes, but the configured MAX_TIMEOUT caps the limit. Output is truncated to 100 rows or 64KB, whichever comes first.

Tools and actions available through the server

The server exposes a set of helper tools to interact with your databases through MCP clients.

License

MIT

Additional notes

This MCP server is designed to work with Claude Desktop, Claude Code, Cursor, Cline, and any MCP-compatible client. You can manage three database connections—analytics, inventory, and cache—through a single MCP server instance.

Available tools

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

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational