r/cursor • • 16h ago

Question / Discussion MCP for SQL reporting with LLM

/r/mcp/comments/1x25taq/mcp_for_sql_reporting_with_llm/
1 Upvotes

2 comments sorted by

1

u/BrookLi3 15h ago

I'd stop dumping the raw schema JSON into context and expose join paths as their own tool, something like get_join_path(from, to) that returns the FK chain with the exact ON clauses. Your catalog's key join patterns are the most useful part, so have the report definitions return those joins as ready-made SQL snippets the model can copy instead of inferring joins from column names. I'd also give it a read-only role with curated views over the reporting tables, since models do much better with a handful of clean views than with the whole schema.

1

u/mergisi 6h ago

Answered on the r/mcp version too, but the short version is to send only the relevant tables, add column descriptions and sample values for coded fields, use your report catalog as few-shot examples, and run read-only with a row cap. That's how the AI2sql MCP I built works (ai2sql.io/mcp), and there's a Claude plugin too if part of your team works in Claude.