A simple command-line client for interacting with an MCP SQLite server. This client enables natural language interaction with SQLite databases through OpenRouter's LLM API.
- Python 3.8 or higher
- pip (Python package installer)
-
Create a project directory:
git clone https://github.com/calvinw/mcp-sqlite-client.git cd mcp-sqlite-client -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate -
Install the required dependencies:
Then install from the requirements file:
pip install -r requirements.txt
-
Install the MCP SQLite server:
pip install mcp-server-sqlite
-
Download a sample SQLite database:
# For Chinook database curl -L https://github.com/lerocha/chinook-database/raw/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite -o chinook.db # For Northwind database git clone https://github.com/jpwhite3/northwind-SQLite3.git cp northwind-SQLite3/northwind.db . # For Superheroes database (optional) git clone https://github.com/codecrafters-io/sample-sqlite-databases.git cp sample-sqlite-databases/superheroes.db .
-
Create a configuration file: Create a file named
servers_config.jsonwith the following content:{ "mcpServers": { "sqlite": { "command": "mcp-server-sqlite", "args": [ "--db-path", "./chinook.db" ] } } } -
Set up your API key: Create a
.envfile in the project directory:OPENROUTER_API_KEY=your_openrouter_api_key_here
Run the client using Python:
python mcp_client.pyThis will start an interactive chat session where you can ask questions about the database in natural language.
For the chinook.db you can use these examples:
Example queries:
- "What tables are in this database?"
- "How many albums are there in total?"
- "Show me the artists with the most albums"
- "List all employees and their hire dates"
Type 'exit' or 'quit' to end the session.
To use a different SQLite database, modify the --db-path in the servers_config.json file to point to your desired database file.
If you encounter issues:
-
MCP-Server-SQLite not found: Ensure that the package is correctly installed and the command is available in your PATH.
which mcp-server-sqlite
-
API Key issues: Verify that your
.envfile contains the correct API key and is in the same directory as the script. -
Connection issues: Check that the database file exists and is readable at the path specified in
servers_config.json.