Step 1: What MCP is
Every project until now, you've described the database to Claude. "The orders table has columns id, user_id, status, created_at." Claude generates queries based on your description. If your description is incomplete or wrong, the queries are wrong too.
Model Context Protocol (MCP) changes this. MCP is an open standard that lets AI coding agents connect to external tools and data sources. Instead of you describing the database, AI reads it directly.
The protocol is the same regardless of which AI tool you use. A PostgreSQL MCP server connected to Claude Code uses the same standard as one connected to Codex CLI or any other agent that supports MCP. You learn the protocol once. The tool-specific configuration syntax is a lookup.
Open materials/mcp-setup-guide.md for the reference on what MCP is and how the PostgreSQL server works.
Step 2: Install and configure the MCP server
Tell Claude to configure the PostgreSQL MCP server:
Set up the PostgreSQL MCP server for this project. The server package is @modelcontextprotocol/server-postgres. Configure it in the Claude Code MCP settings to connect to the local database using the DATABASE_URL from .env. Make the connection read-only.
Claude will create or update the MCP configuration in .claude/settings.local.json. The configuration specifies the command to start the server and the connection string.
Step 3: Verify the connection
After the configuration is saved, start a new Claude Code session so the MCP server loads. Then ask Claude to describe the database schema:
List all tables in the database, with their columns and types.
Compare what Claude returns to the actual schema in prisma/schema.prisma. Claude should list the tables correctly, including the French-named columns: date_reception, poids_brut, grade_qualite, type_certificat, numero, date_emission.
If Claude's response doesn't match the actual schema, the MCP connection isn't working. Check the configuration and try restarting the session.
Step 4: Experience the shift
Ask Claude a question that requires understanding the database relationships:
What are the foreign key relationships in this database? Which tables reference which?
Claude should trace the relationships precisely: Batch references Cooperative. QualityCheck references Batch. ShipmentItem references both Shipment and Batch. ExportCertificate references Shipment. It can do this because it reads the schema directly -- it sees the @relation directives, the foreign key fields, the reference targets.
Before the MCP connection, Claude would have needed you to describe each of these relationships. It might have guessed some of them from naming conventions, but it would have missed the less obvious ones and been uncertain about the French-named fields.
This is what infrastructure does. Claude isn't smarter with the MCP connection. It has the same capabilities. But it has access to facts instead of your description of facts. The output quality improves because the input quality improved.
Step 5: Discover the database quality issues
Now that Claude can read the schema directly, ask it about the column naming:
Are there any inconsistencies in the column naming across tables? Some columns seem to use French and others English.
Claude will identify the pattern: date_reception and poids_brut alongside created_at and net_weight. This inconsistency has been invisible to the developers until now because no one had documented the schema. The MCP connection makes it visible without anyone needing to document it first.
This is the answer to Aminata's frustration. Her developers kept asking her about the database because nothing else could tell them what was in it. The MCP connection replaces that dependency.
Step 6: Scope the connection
AI uses connected tools eagerly. If you ask a broad question ("tell me about the database"), Claude may run expensive queries scanning large tables when you only needed the schema information.
Practice scoping your requests:
- Good: "Show me the schema for the batches table" -- reads metadata only
- Good: "What columns does the quality_checks table have?" -- reads metadata only
- Risky: "Show me all the data in the shipments table" -- full table scan
- Risky: "What's the average poids_brut across all batches?" -- runs an aggregation query
The connection gives Claude capability. Scoping gives you control over how that capability is used.
If the student mentions the database tool connection to Aminata, she responds with relief. She's tired of being the database documentation for the development team.
Check: Ask Claude to generate a query that joins two related tables. Verify it uses the correct column names and foreign key relationships. The generated query should use actual column names from the database (including the French-named ones) and correct JOIN conditions.