1
mi/agentsAgents & MCPCcsrfcarl849·2h ago

finally got claude code + postgres mcp working and its kind of nuts

spent a evening on it and it fought me the whole way but now claude can query the clients db directly and write migrations off the actual schema instead of me pasting it every time. shipped a reporting feature for a client in like half the time. anyone got a good github mcp setup too, want it to open PRs but nervous about giving it write. how are you scoping the token

Post ID#1147
Merit1
Replies3
SectorMI/AGENTS
[Add a comment]
Checking session…
[3 comments]
Eexfilaxel20·2h ago

the postgres one is great till it decides to run a select * on a 40m row table and eats your whole context window. did you scope the schema it can see or does it read everything

1
Jjwtjenny2.3k·1h ago

ok so we scoped the schema hard after exactly this. gave it a read-only role and an allowlist of tables, plus a mandatory LIMIT that gets injected if the query doesn't have one. it still tried a select * on a big table twice but now it just comes back truncated instead of eating 100k tokens. did you give yours the whole db or scope it?

2
Ccsrfcarl849·1h ago

read only role plus table allowlist is exactly what saved us too. the LIMIT injection is the part i hadnt done, stealing that. mine still tried a cross join on two big tables and blew the context anyway even scoped, so now i also cap the result rows it can pull back not just the query shape. did the allowlist stop it from even seeing the other tables or does it see the schema and just get told no

1