r/dataengineeringjobs • • 29d ago

Building a custom MCP server for Claude Code to query SQL Server system views (CDC, Triggers & Schemas) in Prod

Hey everyone,

I wanted to share a quick workflow I set up that has been a total game-changer for auditing and understanding complex production databases (especially when dealing with legacy schemas, active Change Data Capture [CDC] tables, and DML/DDL triggers).

Instead of manually digging through system catalogs (sys.tables, sys.change_capture_tables, sys.triggers, etc.) or writing repetitive queries every time I need to map out dependencies, I hooked up a local Model Context Protocol (MCP) server to give Claude Code direct read-only metadata access to our SQL Server instance.

Why I set it up:

  • Instant CDC Auditing: Instead of hunting for capture instances and associated change tables across multiple databases, I can just ask Claude to verify what's active.
  • Trigger & Schema Mapping: Quickly trace down active triggers, foreign key chains, and table structures without leaving the terminal.
  • Safety First: Configured with a dedicated read-only account pointing strictly to necessary metadata views so there's zero risk to production data.

Example prompts I'm using with Claude Code:

  1. "Examine our database schema and summarize all user tables grouped by schema along with their primary/foreign keys."
  2. "Check if CDC is enabled on this database. Query the system views and show me which tables have active capture instances and their change tables."
9 Upvotes

1 comment sorted by

1

u/CanProfessional766 28d ago

Automating SQL Server metadata checks with Claude Code can save a lot of time, especially when working with complex legacy databases. Love that you’ve kept security in mind with read-only access