Connect to a Database
1. Connect to a Database
MCP is the concept. Now let's put it to work. You'll connect Claude to the Chinook database, a real music store dataset, and start querying it with plain English. SQLite keeps the setup simple here, but the same pattern works with any other database or remote service.2. The Chinook Database
Chinook models a digital music store. Artists ranging from AC/DC to Led Zeppelin, 347 albums, more than three thousand tracks, plus customer records and purchase history. It's the dataset you'll use throughout this chapter to power real queries from the Music Analytics API.3. The Project So Far
The project now includes chinook.db, a single SQLite file. No separate server, no configuration. The MCP server reads it directly. That's one of SQLite's strengths for development: everything in one file, ready to query.4. What Can We Query?
The Chinook database has three core tables: Artists with 275 rows, Albums with 347, and Tracks with over 3,500. Instead of writing SQL against them, ask naturally: "Show me all Pink Floyd albums", "Which artist has the most tracks?", "List all rock genre tracks." Claude handles the translation.5. Connect and Verify
Before querying, you need to connect. Here's how. Run the command shown to install the SQLite MCP server. You'll see a confirmation: "Added MCP server SQLite to local config." Then start Claude and run slash mcp to verify. Navigate the menu to explore the tools the SQLite server exposes: list tables, describe table, read query, write query, and more. Claude now has everything it needs to query the database directly.6. Query with Natural Language
Here's MCP in action. Ask: "Show me all Pink Floyd albums." No SQL needed. Claude calls list tables, finds the structure, and runs a join across artists and albums. The result: The Dark Side of the Moon, the one Pink Floyd album in the database. Exact, accurate, no query written by hand.7. The MCP Query Flow
The five steps on screen match what just happened. You asked a question. Claude picked the right MCP tool. The MCP server ran the SQL. The database returned the data. Claude displayed the result. Natural language in, formatted answer out. And while this example uses a local SQLite file, the same five steps apply when connecting to PostgreSQL, MySQL, or any remote service. The pattern is what matters.8. Let's Practice!
Now it's your turn. Query the Chinook database in plain English: artists, albums, tracks, whatever you're curious about. Claude handles the SQL. You just ask.Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.