# DataLink

Connects PostgreSQL, MySQL, or SQLite to an AI assistant over MCP. Inspect schemas and run database queries from a supported client.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 5
- Author: pilat
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pilat/mcp-datalink
- Updated: 2026-10-22
- HTML: https://affpapa.org/en/nevibecode/mcp/datalink

## What it does

DataLink exposes database connections to an AI assistant. Its tools can list connections and tables, inspect schemas with indexes and foreign keys, show query plans, and run SQL. Use `SELECT` for reading; changes go through a separate `execute` tool.

Set connection URLs through environment variables, with an optional read-only mode for each database. URLs can also reference other variables with `${VAR}` or `${VAR:-default}`. Queries use prepared statements, allow one statement at a time, and block DDL such as `DROP` and `ALTER`. Read-only mode is a per-connection setting, so check it before allowing write operations.

Responses default to a limit of 100 rows and 64KB. The default query timeout is 30 seconds; size and timeout limits have configuration options. To add the server to Claude Code, provide a database URL with `claude mcp add` and run it through `npx -y @pilat/mcp-datalink`. You’ll need `npx` and a database connection URL.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `DATALINK_ANALYTICS_URL`, `DATALINK_ANALYTICS_READONLY` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> --env DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> --transport stdio datalink -- npx -y @pilat/mcp-datalink
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add datalink --env DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> --env DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> -- npx -y @pilat/mcp-datalink
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "datalink": {
            "command": "npx",
            "args": [
                "-y",
                "@pilat/mcp-datalink"
            ],
            "env": {
                "DATALINK_ANALYTICS_URL": "<DATALINK_ANALYTICS_URL>",
                "DATALINK_ANALYTICS_READONLY": "<DATALINK_ANALYTICS_READONLY>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "datalink": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "@pilat/mcp-datalink"
            ],
            "env": {
                "DATALINK_ANALYTICS_URL": "<DATALINK_ANALYTICS_URL>",
                "DATALINK_ANALYTICS_READONLY": "<DATALINK_ANALYTICS_READONLY>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> -e DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> datalink npx -y @pilat/mcp-datalink
```
Replace <…> with your own values

## When to use it
- inspect configured database connections
- find tables and check their row counts
- review a table’s schema, indexes, and foreign keys
- run a SELECT query against PostgreSQL, MySQL, or SQLite
- view the execution plan for a SQL query

## Example prompts
- List the database connections I can access.
- Show the schema, indexes, and foreign keys for `orders`.
- Run a SELECT query to retrieve recent rows from `orders`.

## Similar
- [World Monitor](https://affpapa.org/en/nevibecode/mcp/world-monitor.md) — MCP server · ★ 89609
- [Scrapling MCP Server](https://affpapa.org/en/nevibecode/mcp/scrapling-mcp-server.md) — MCP server · ★ 89899
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16730
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40459
- [dbx](https://affpapa.org/en/nevibecode/mcp/dbx.md) — MCP server · ★ 27844
- [Metabase](https://affpapa.org/en/nevibecode/mcp/metabase.md) — MCP server · ★ 49863

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
