Inspiration

We wanted to challenge ourselves with Anthropic's newly released Model Context Protocol and build something we'd actually use day-to-day as developers. As ICS majors, we all have to work with SQL at times. After enough time writing the same kinds of queries over and over, we figured there had to be a better way.

About The Product

Envoy lets you query any PostgresSQL database using natural language. Type "mark all orders from last month as fulfilled" and Envoy translates it to SQL, shows you exactly which rows will change, tells you the risk level, and asks for your approval before a single row is touched. Versatile in its capabilities, Envoy adapts to various prompt styles to take any CRUD action and explain it thoroughly before executing it for the user.

How We Built It

Envoy uses a multi-agent pipeline powered by Claude. Each user request passes through dedicated agents for SQL generation, risk assessment, and plain-English explanation. Write operations execute via the Postgres MCP server into a pending transaction. Data is never committed until the user explicitly approves.

Challenges We Ran Into

  1. The bug that took the longest to address was when Envoy would confidently tell the user "Done, I've updated those rows", but nothing had actually changed in the database. We fixed this by separating the execution and explanation agents so the explanation layer can only report what the database actually returned, never what it thinks happened.
  2. We also hit inconsistent structured output. The model would occasionally return free-text instead of valid JSON, breaking our parsing logic. Enforcing a strict JSON schema and validating every response solved it.
  3. Response times were also really long early on. Our first version was a single Claude call trying to generate SQL, assess risk, and explain the query all at once. Splitting into focused single-responsibility agents and parallelizing the independent ones brought times down significantly.

Accomplishments That We're Proud Of

Refactoring from one bloated agent into a clean pipeline that's faster and cheaper. We are also proud of the result UI because the message component adapts its layout dynamically based on what the query returned.

What We learned

LLM outputs are far more variable than we expected. Getting consistent, structured responses needed explicit schemas, strict system prompts, scoped context. It showed us how much patience and work goes into making LLM-powered tools reliable rather than just impressive in a demo.

What's next for Envoy: AI Postgres Client

A guided form mode: when a write operation is detected, surface the relevant table columns as structured input fields rather than a blank text box. Simpler for non-technical users, less ambiguous for the model.

Built With

  • anthropic-claude-api
  • next.js
  • postgres-model-context-porotocol
  • postgres-model-context-protocol
  • shadcn
  • tailwind-css
  • typescript
Share this project:

Updates