Published: 2026-02-17
Connect AI Agents to Your Database with MCP
AI coding assistants can write SQL, but they can't see your schema. They don't know your table names, column types, or relationships. The Model Context Protocol (MCP) changes that — it gives AI agents a secure, structured way to interact with live databases. This guide shows you how to set it up.
In This Guide
- What Is MCP and Why Do SQL Developers Need It?
- The Problem: AI Can't See Your Schema
- How MCP Bridges AI Tools and Live Databases
- Step-by-Step: Connect Claude Code to Your Database
- Step-by-Step: Connect Claude Desktop
- Step-by-Step: Connect Codex CLI
- What Can AI Do Once Connected?
- Security: Why This Is Safe
- Real-World Use Cases
- FAQ
1. What Is MCP and Why Do SQL Developers Need It?
The Model Context Protocol (MCP) is an open standard for connecting AI tools to external data sources. Think of it as a universal adapter between AI assistants and the applications they need to work with.
For SQL developers, MCP solves a fundamental limitation: AI tools are great at writing SQL syntax, but they have no idea what your actual database looks like. Without schema context, AI-generated queries reference tables that don't exist, use wrong column names, and miss relationships between tables.
MCP changes the workflow from "copy-paste your schema into a chat window" to "the AI already knows your schema, table structures, and can execute queries directly."
2. The Problem: AI Can't See Your Schema
You've probably experienced this workflow:
- Ask an AI assistant to write a query
- Get back syntactically correct SQL that references
userswhen your table is calleddbo.Customers - Paste your schema definition into the chat
- Get a better query, but it misses a foreign key relationship
- Paste more context
- Repeat
This manual context-passing is slow, error-prone, and doesn't scale. A database with 50 tables and 200 stored procedures can't be summarized in a chat message. Even if you could, the context would be stale the moment someone adds a column.
MCP eliminates this friction. Instead of manually describing your database, the AI agent connects to a live data source and introspects the schema in real-time.
3. How MCP Bridges AI Tools and Live Databases
Here's how MCP works with Jam SQL Studio:
- Jam SQL Studio connects to your databases — SQL Server, PostgreSQL, MySQL, SQLite, Azure SQL
- Jam SQL Studio runs a local MCP server — a lightweight HTTP endpoint on localhost
- Your AI tool connects to the MCP server — using a bearer token for authentication
- The AI agent calls MCP tools — to list connections, introspect schemas, execute queries, and control the UI
The AI tool never connects directly to your database. Jam SQL Studio acts as a secure intermediary that manages connections, enforces permissions, and logs every action.
4. Step-by-Step: Connect Claude Code to Your Database
Claude Code has native HTTP support for MCP servers, making it the simplest setup.
Step 1: Enable MCP Server in Jam SQL Studio
- Open Jam SQL Studio
- Go to Settings (gear icon) → AI Integrations tab
- Toggle Enable MCP server to ON
- Copy the Endpoint URL (e.g.,
http://127.0.0.1:14507/mcp) - Click Show next to the token, then Copy
Step 2: Configure Claude Code
Option A: User scope (available across all projects) — create or edit ~/.claude.json:
{
"mcpServers": {
"jam-sql": {
"type": "http",
"url": "http://127.0.0.1:14507/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN_HERE"
}
}
}
}Option B: Project scope (shared with your team) — create .mcp.json in your project root:
{
"mcpServers": {
"jam-sql": {
"type": "http",
"url": "${JAM_SQL_MCP_ENDPOINT:-http://127.0.0.1:14507/mcp}",
"headers": {
"Authorization": "Bearer ${JAM_SQL_MCP_TOKEN}"
}
}
}
}Option C: CLI command:
claude mcp add --transport http jam-sql http://127.0.0.1:14507/mcp \
--header "Authorization: Bearer YOUR_TOKEN_HERE" \
--scope userStep 3: Verify the Connection
Run claude mcp list in your terminal, or type /mcp inside Claude Code. You should see jam-sql listed as a connected server.
Now ask Claude something like: "List all tables in my database" — it will use the MCP connection to query your actual schema.
5. Step-by-Step: Connect Claude Desktop
Claude Desktop uses stdio transport, so it requires the mcp-remote proxy and Node.js 20+.
Step 1: Verify Node.js 20+
node --version # Must be v20.0.0 or higherInstall Node 20+ from nodejs.org if needed.
Step 2: Configure Claude Desktop
Edit your config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"jam-sql": {
"command": "/path/to/node20+/bin/npx",
"args": [
"-y",
"mcp-remote",
"http://127.0.0.1:14507/mcp",
"--header",
"Authorization:${JAM_SQL_TOKEN}"
],
"env": {
"JAM_SQL_TOKEN": "Bearer YOUR_TOKEN_HERE"
}
}
}
}Replace /path/to/node20+/bin/npx with the actual path to your Node 20+ npx binary (e.g., ~/.nvm/versions/node/v22.x.x/bin/npx or /opt/homebrew/bin/npx).
Step 3: Restart Claude Desktop
Quit and reopen Claude Desktop. You should see "jam-sql" in the MCP tools menu (hammer icon). If you see ReferenceError: File is not defined, your npx path is pointing to Node 18 or older.
6. Step-by-Step: Connect Codex CLI
OpenAI's Codex CLI uses TOML configuration for MCP servers.
Configure Codex
Add the MCP server to ~/.codex/config.toml:
[mcp_servers.jam-sql]
url = "http://127.0.0.1:14507/mcp"
bearer_token_env_var = "JAM_SQL_MCP_TOKEN"Then set the token in your shell profile (~/.zshrc or ~/.bashrc):
export JAM_SQL_MCP_TOKEN="YOUR_TOKEN_HERE"Verify by typing /mcp inside Codex to see active MCP servers.
7. What Can AI Do Once Connected?
Once your AI agent is connected via MCP, it can interact with your databases through Jam SQL Studio's tools. Here's what becomes available:
Schema Introspection
The AI can list all connections, databases, tables, views, stored procedures, and column definitions. It understands your actual schema — not a stale copy you pasted into a prompt. This means accurate table names, correct column types, and awareness of foreign key relationships.
Query Execution
With read-only mode enabled, the AI can execute SELECT queries and return results. It can explore your data, run diagnostic queries, and verify its own SQL before presenting it to you. In confirm mode, write queries require your explicit approval in an in-app dialog.
Execution Plan Analysis
The AI can generate execution plans (estimated or actual) for your queries, read the plan details, and suggest optimizations based on what the query optimizer reports. No more manually running EXPLAIN and pasting the output.
UI Control
The AI can open query tabs, set editor content, switch between result tabs, open table explorers, configure charts, and even take screenshots of the app window. This enables workflows where you describe what you want and the AI builds it in the IDE.
Context Resources
The MCP server exposes read-only snapshots of the current workspace state: active connections, open tabs, editor content, query results, and selected objects. The AI uses these to understand what you're working on without you having to explain it.
8. Security: Why This Is Safe
Giving AI access to your database sounds risky. Here's why Jam SQL Studio's approach is designed to be safe:
Localhost Only
The MCP server binds to 127.0.0.1. It is not accessible from the network, other machines, or the internet. Only processes running on your machine can connect.
Bearer Token Auth
Every request requires a valid bearer token. The token is generated in-app and can be regenerated at any time. No token, no access.
Tiered Permissions
Block (default): no query execution. Read-only: SELECT, EXPLAIN, SHOW only. Confirm: write queries require your in-app approval.
No Credential Exposure
Database passwords are never sent to the AI agent. The AI interacts with Jam SQL Studio, which manages all database connections internally.
Audit Logging
Every MCP tool call is logged with timestamp, tool name, parameters, and outcome. You can review exactly what the AI did.
Write Approval
In confirm mode, each write query triggers an in-app dialog with the full SQL, connection context, and a 60-second auto-deny timeout. No silent writes.
9. Real-World Use Cases
Debugging Application Issues
Ask your AI agent to check the state of your data while debugging. Instead of switching between your IDE and a SQL client, the AI can query relevant tables, inspect recent records, and correlate data across multiple tables — all from your terminal.
Query Optimization
Paste a slow query into Claude Code and ask it to optimize. With MCP, it can generate the actual execution plan, identify table scans and missing indexes, suggest improvements, and run the optimized version to compare performance — all without you touching the SQL IDE.
Schema Documentation
Ask the AI to document your database schema. It can introspect every table, view, and stored procedure, then generate comprehensive documentation with descriptions, relationships, and data type summaries.
Data Analysis and Reporting
Describe the report you need in natural language. The AI can write the SQL, execute it, read the results, and iterate until the output matches your requirements. It can also configure charts directly in Jam SQL Studio to visualize the data.
Building Migration Scripts
The AI can compare your current schema against your application models and generate migration scripts. With read access to the actual database, the migrations account for existing data, constraints, and dependencies.
10. FAQ
Which databases does MCP support?
MCP works with any database supported by Jam SQL Studio: SQL Server, Azure SQL, PostgreSQL, MySQL, MariaDB, and SQLite. The AI agent connects to Jam SQL Studio, not directly to the database, so no database-specific configuration is needed on the AI side.
Do I need a paid plan?
The MCP server is available in the free Personal tier. AI Workspace features (file sync, schema export, auto-generated context files) require Pro. The AI Chat Sidebar uses your existing Claude Code installation at no additional cost.
Can I use this with tools other than Claude?
Yes. Any tool that supports MCP or HTTP/JSON-RPC can connect: Codex CLI, OpenCode, GitHub Copilot (via MCP extension), LangChain agents, AutoGen agents, or custom scripts using curl or any HTTP client.
What if I don't want the AI to run queries?
Set the permission level to Block (the default). The AI can still introspect schemas, open query tabs, and write SQL into the editor — but it cannot execute any queries. You run them manually when ready.
Can other people on my network access the MCP server?
No. The server binds exclusively to 127.0.0.1 (localhost). It does not listen on any network interface. Only processes on your local machine can reach it.
Connect Your AI Agent Today
Download Jam SQL Studio and connect Claude, Codex, or any MCP-compatible AI tool to your databases in under 5 minutes.
Jam SQL Studio