MCP ExplorerExplorer

Mcp Sqlite Client

@calvinwon a year ago
2 MIT
FreeCommunity
AI Systems
A simple command line mcp client interacting with sqlite database

Overview

What is Mcp Sqlite Client

mcp-sqlite-client is a simple command-line client designed for interacting with an MCP SQLite server, allowing users to engage with SQLite databases using natural language through OpenRouter’s LLM API.

Use cases

Use cases include querying databases for information, generating reports based on database content, and educational purposes for teaching database interactions using natural language.

How to use

To use mcp-sqlite-client, first clone the repository, set up a virtual environment, install the required dependencies, and configure the MCP SQLite server. After setting up, run the client using Python to start an interactive chat session with the database.

Key features

Key features include natural language processing capabilities for querying SQLite databases, easy installation and setup, and support for multiple sample databases like Chinook and Northwind.

Where to use

mcp-sqlite-client can be used in various fields such as data analysis, education, and application development, where users need to interact with SQLite databases in a user-friendly manner.

Content

MCP SQLite Client

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.

Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)

Setup Steps

  1. Create a project directory:

    git clone https://github.com/calvinw/mcp-sqlite-client.git
    cd mcp-sqlite-client
    
  2. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate
    
  3. Install the required dependencies:

    Then install from the requirements file:

    pip install -r requirements.txt
    
  4. Install the MCP SQLite server:

    pip install mcp-server-sqlite
    
  5. 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 .
    
  6. Create a configuration file:
    Create a file named servers_config.json with the following content:

    {
      "mcpServers": {
        "sqlite": {
          "command": "mcp-server-sqlite",
          "args": [
            "--db-path",
            "./chinook.db"
          ]
        }
      }
    }
  7. Set up your API key:
    Create a .env file in the project directory:

    OPENROUTER_API_KEY=your_openrouter_api_key_here
    

Usage

Run the client using Python:

python mcp_client.py

This 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.

Customizing the Database

To use a different SQLite database, modify the --db-path in the servers_config.json file to point to your desired database file.

Troubleshooting

If you encounter issues:

  1. MCP-Server-SQLite not found: Ensure that the package is correctly installed and the command is available in your PATH.

    which mcp-server-sqlite
    
  2. API Key issues: Verify that your .env file contains the correct API key and is in the same directory as the script.

  3. Connection issues: Check that the database file exists and is readable at the path specified in servers_config.json.

License

MIT

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers