MCP server for PostgreSQL, MySQL, and SQLite. Gives AI assistants secure database access via Model Context Protocol. Works with Claude Desktop, Claude Code, Cursor, Cline, and any MCP-compatible client. Add to your MCP client config file (see config locations below): This creates three database connections: analytics (read-only), inventory, and cache. Connection URL formats: URLs support ${VAR} sy
Add this skill
npx mdskills install pilat/mcp-datalinkWell-documented multi-database MCP server with strong security controls and clear setup
1# @pilat/mcp-datalink23MCP server for PostgreSQL, MySQL, and SQLite. Gives AI assistants secure database access via [Model Context Protocol](https://modelcontextprotocol.io).45```6npx @pilat/mcp-datalink7```89Works with Claude Desktop, Claude Code, Cursor, Cline, and any MCP-compatible client.1011## Installation1213Add to your MCP client config file (see [config locations](#config-file-locations) below):1415```json16{17 "mcpServers": {18 "datalink": {19 "command": "npx",20 "args": ["-y", "@pilat/mcp-datalink"],21 "env": {22 "DATALINK_ANALYTICS_URL": "postgresql://user:password@localhost:5432/analytics",23 "DATALINK_ANALYTICS_READONLY": "true",2425 "DATALINK_INVENTORY_URL": "mysql://user:password@localhost:3306/inventory",2627 "DATALINK_CACHE_URL": "sqlite:///path/to/cache.db"28 }29 }30 }31}32```3334This creates three database connections: `analytics` (read-only), `inventory`, and `cache`.3536| Variable | Description |37|----------|-------------|38| `DATALINK_{NAME}_URL` | Connection URL (creates database named `{name}`) |39| `DATALINK_{NAME}_READONLY` | Set to `true` to block writes |40| `DATALINK_{NAME}_MAX_TIMEOUT` | Max query timeout in ms (caps model requests) |4142**Connection URL formats:**4344```bash45# PostgreSQL46postgresql://user:password@localhost:5432/dbname47postgresql://user:password@localhost:5432/dbname?sslmode=require4849# MySQL50mysql://user:password@localhost:3306/dbname51mysql://user:password@localhost:3306/dbname?ssl=true5253# SQLite54sqlite:///path/to/database.db55sqlite:///Users/me/data/app.sqlite56sqlite://../relative/path/data.db57```5859### Environment Variable Substitution6061URLs support `${VAR}` syntax to reference other environment variables:6263```json64{65 "mcpServers": {66 "datalink": {67 "command": "npx",68 "args": ["-y", "@pilat/mcp-datalink"],69 "env": {70 "DATALINK_MAIN_URL": "${DATABASE_URL}"71 }72 }73 }74}75```7677This allows reusing existing environment variables (like `DATABASE_URL` from your shell or `.env` file).7879**Supported syntax:**8081| Syntax | Description |82|--------|-------------|83| `${VAR}` | Expands to value of `VAR`, or keeps `${VAR}` if unset |84| `${VAR:-default}` | Expands to value of `VAR`, or `default` if unset |8586**Examples:**8788```bash89# Reference existing DATABASE_URL90DATALINK_MAIN_URL="${DATABASE_URL}"9192# Build URL from parts93DATALINK_MAIN_URL="postgresql://${DB_USER}:${DB_PASS}@${DB_HOST}:5432/mydb"9495# With default values96DATALINK_MAIN_URL="postgresql://localhost:${DB_PORT:-5432}/mydb"97```9899### Config File Locations100101| Client | Config file |102|--------|-------------|103| Claude Code | `~/.claude.json` (global) or `.mcp.json` (project) |104| Claude Desktop (macOS) | `~/Library/Application Support/Claude/claude_desktop_config.json` |105| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |106| Cursor | `~/.cursor/mcp.json` or Settings → Features → MCP Servers |107| Cline | `cline_mcp_settings.json` or VS Code settings `cline.mcpServers` |108109## Tools110111| Tool | Description |112|------|-------------|113| `list_databases` | List configured database connections |114| `list_tables` | List tables with row counts |115| `describe_table` | Get schema, indexes, foreign keys |116| `query` | Run SELECT queries |117| `execute` | Run INSERT/UPDATE/DELETE |118| `explain` | Show query execution plans |119120## Security121122- Prepared statements only (no SQL injection)123- Single statement per query (no chaining)124- DDL blocked (no DROP, ALTER, TRUNCATE)125- Readonly mode per connection126- Output truncation (100 rows, 64KB max)127- Query timeout: 30s default, model can request up to 10min, `MAX_TIMEOUT` caps it128129## License130131MIT132
Full transparency — inspect the skill content before installing.