Railyard tutorial: Using MCP to query production databases with read-only SQL
Understand this story
Railyard has published a tutorial explaining how to let AI agents query production databases via MCP using read-only SQL. It provides two tools, list_tables and query_database, and queries pass through five layers of protection: write permission scope, role restrictions, database-level read-only transactions (Postgres/MySQL/ClickHouse), statement timeouts, and a maximum return of 200 rows. According to the tutorial, write-type statements fail directly at the database layer; write permissions are limited to administrators and owners, and only administrators and owners can grant write permissions. When query results exceed 200 rows, they are truncated and flagged.
AI overview based on source reports · Updated 23 hr ago
Coverage timeline
Follow the coverage to explore different perspectives.
- Hacker News AILet an AI agent query your prodution database safely with read-only SQL over MCP
This tutorial explains how to set up Railyard's list_tables and query_database MCP tools so an AI agent can answer plain-language questions about a production database without changing anything. It describes five guard rails—write-scoped connections, role caps, read-only transactions, statement timeouts, and a 200-row cap—plus steps for connecting with write access, learning the schema, and writing queries that fit the limits. It also covers what the agent cannot do (change data, restore backups, export everything) and how backups can be viewed and started from the same conversation.
Activity for this story
- Current comparable activity
- 5
- Peak comparable activity
- 10Nov 13 23:00
- Change in the past 24 hours
- –
Trends compare the same fully observed participants, which may cover fewer participants than current activity. Move the pointer or tap the chart to inspect hourly activity; use the left and right arrow keys with a keyboard.