SQLite Explorer MCP server

Provides a bridge to SQLite databases for querying and analyzing data through SQL execution, enabling data exploration and insights generation without direct database access.
Back to servers
Provider
Prayank Swaroop
Release date
Apr 16, 2025
Language
Python
Stats
7 stars

This MCP server allows you to connect SQLite databases to language models using the Model Context Protocol. It provides access to database schemas, SQL query execution capabilities, and helpful prompt templates for data analysis, all through a standardized interface.

Installation

Prerequisites

Before using the SQLite MCP server, you'll need to set up a sample database and prepare your environment.

Creating the Sample SQLite Database

Create a database with sample startup funding data:

  1. Save the following script as create_db.py:
import sqlite3
import os

# Create database file
db_path = "startups.db"
if os.path.exists(db_path):
    os.remove(db_path)

# Connect to database
conn = sqlite3.connect(db_path)
cursor = conn.cursor()

# Create tables
cursor.execute('''
CREATE TABLE startups (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    industry TEXT,
    founding_year INTEGER,
    location TEXT,
    founder TEXT,
    funding_amount REAL,
    funding_round TEXT
)
''')

# Insert sample data
sample_data = [
    (1, "TechNova", "AI", 2020, "San Francisco", "Alex Smith", 5000000, "Series A"),
    (2, "GreenEnergy", "Renewable Energy", 2018, "Boston", "Maria Chen", 12000000, "Series B"),
    (3, "HealthPlus", "Healthcare", 2019, "New York", "James Wilson", 3000000, "Seed"),
    (4, "FoodDeliveryX", "Food Tech", 2021, "Chicago", "Sarah Johnson", 8000000, "Series A"),
    (5, "CryptoFinance", "Fintech", 2017, "Miami", "Michael Brown", 15000000, "Series B")
]

cursor.executemany('''
INSERT INTO startups (id, name, industry, founding_year, location, founder, funding_amount, funding_round)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''', sample_data)

# Commit changes and close connection
conn.commit()
conn.close()

print(f"Database created at {db_path} with sample startup data.")
  1. Run the script:
python create_db.py

Setting Up the Environment

  1. Create a virtual environment:
python -m venv venv
  1. Activate the virtual environment:

macOS/Linux:

source venv/bin/activate

Windows:

venv\Scripts\activate
  1. Install dependencies:
pip install "mcp[cli]"

Running the MCP Server

Save your server code as sqlite_mcp_server.py and run:

python sqlite_mcp_server.py

Integration with Claude Desktop

To integrate with Claude Desktop:

  1. Update Claude Desktop configuration with:
{
  "mcpServers": {
    "sqlite_mcp_server": {
      "command": "python",
      "args": ["-u", "/absolute/path/to/sqlite_mcp_server.py"]
    }
  }
}
  1. Restart Claude Desktop after updating the configuration.

Using the MCP Server

Accessing Database Schema Resources

The server exposes database schemas as resources that Claude can access:

  • schema://sqlite/all - Get schemas for all tables
  • schema://sqlite/startups - Get schema for the startups table only

Executing SQL Queries

You can run SQL queries on the database using the sql_query tool. Only SELECT statements are allowed:

SELECT * FROM startups WHERE funding_amount > 10000000;
SELECT name, industry, funding_amount 
FROM startups 
ORDER BY funding_amount DESC 
LIMIT 3;

Using Prompt Templates

The server provides prompt templates to help with:

  • Analyzing specific tables
  • Describing SQL query results

These templates help Claude generate more informative and accurate responses when working with the database.

Troubleshooting

If you encounter issues:

  • Ensure the SQLite database has been created before running the server
  • Check that paths in configuration files are absolute and correct
  • Verify that your virtual environment is activated when running the server
  • Look for error messages in the console output

The server logs to stderr by default, which can help diagnose problems.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later