DataLink — Claude Code MCP server: features and setup
Connects PostgreSQL, MySQL, or SQLite to an AI assistant over MCP. Inspect schemas and run database queries from a supported client.
claude mcp add --env DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> --env DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> --transport stdio datalink -- npx -y @pilat/mcp-datalinkWhat DataLink 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.
What it helps with
- 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 for the agent
- 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.
How to install DataLink
Platform CLI
claude mcp add --env DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> --env DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> --transport stdio datalink -- npx -y @pilat/mcp-datalinkReplace <…> with your own values
Platform CLI
codex mcp add datalink --env DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> --env DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> -- npx -y @pilat/mcp-datalinkReplace <…> with your own values
Config file
{
"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
Config file
{
"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
Platform CLI
gemini mcp add -e DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> -e DATALINK_ANALYTICS_READONLY=<DATALINK_ANALYTICS_READONLY> datalink npx -y @pilat/mcp-datalinkReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about DataLink
How do I install DataLink in Claude Code?
Run claude mcp add mcp-datalink -e DATALINK_ANALYTICS_URL=<DATALINK_ANALYTICS_URL> -- npx -y @pilat/mcp-datalink. Replace the placeholder with your database URL.
What does DataLink do?
It connects PostgreSQL, MySQL, and SQLite databases to an AI assistant over MCP. The assistant can inspect database structure and run queries.
Can I restrict a connection to read-only access?
Set DATALINK_{NAME}_READONLY to true for that connection. DataLink then blocks writes on it.