SQLite MCP Server

by madhavarora1988

184 downloads
Not rated
GitHub

About

simple poc to demostrate an mcp server on top of sqlite db

Details

Author
madhavarora1988
Downloads
184
Categories
Database

- Execute SQL queries with validation and safety checks
- Discover table schemas and list all tables
- Count rows in specified tables
- Insert sample data for demonstration (write mode)
- Read-only mode for production safety
- Collect user feedback stored in the database

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name SQLite MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install dependencies with pip install -r requirements.txt, configure the .env file (set DB_PATH, MCP_PORT, READ_ONLY), then start the server with python server.py on port 8080. Add it to Claude Desktop via the mcpServers configuration.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "sqlite mcp server": {
            "mcp_sqlite_poc": {
                "command": "python",
                "args": [
                    "server.py"
                ]
            }
        }
    }
}

McpServers

{
    "mcp_sqlite_poc": {
        "command": "python",
        "args": [
            "server.py"
        ]
    }
}

SQLite MCP Server

A Model Context Protocol (MCP) server implementation for SQLite databases, allowing AI models to interact with SQLite databases through standardized tools.

Features

- Query Execution: Execute SQL queries with built-in validation and safety checks
- Schema Discovery: List tables and describe table schemas
- Row Counting: Count rows in specified tables
- Sample Data: Insert sample data for demonstration purposes (when not in read-only mode)
- Automatic Initialization: Creates a sample database with products, customers, orders, and feedback if none exists
- Read-Only Mode: Option to restrict to read-only operations for safety
- Feedback Collection: Tool to collect user feedback and store it in the database

Requirements

- Python 3.8+
- Dependencies listed in requirements.txt

Installation

1. Clone this repository
2. Install dependencies:

pip install -r requirements.txt

3. Configure environment variables (optional):
- Copy .env.example to .env (or use the existing .env file)
- Modify settings as needed

Usage

Starting the Server

python server.py

The server will start on port 8080 (or the port specified in your .env file).

Configuration Options

Configure the server by editing the .env file:

DB_PATH=sample.db         # Path to your SQLite database file
MCP_PORT=8080             # Port to run the MCP server on
READ_ONLY=true            # Set to false to allow write operations

Using with Claude Desktop

Add this server to your Claude Desktop configuration:

{
"mcpServers": {
		"sqlite": {
			"command": "<Path to UV>",
			"args": [
				"--directory",
				"<Absolute Path to Project Workspace>",
				"run",
				"server.py"
			]
		}
	}
}

Available Tools

The MCP server provides the following tools:

1. execute_query - Execute SQL queries on the database
2. list_tables - List all tables in the database
3. describe_table - Get the schema for a specific table
4. count_rows - Count rows in a specific table
5. insert_sample_data - Insert sample data (disabled in read-only mode)
6. add_feedback - Add user feedback to the feedback table (disabled in read-only mode)

Sample Database Schema

The sample database includes:

Products Table

- id (INTEGER, PRIMARY KEY) - name (TEXT, NOT NULL) - description (TEXT) - price (REAL, NOT NULL) - category (TEXT) - in_stock (BOOLEAN)

Customers Table

- id (INTEGER, PRIMARY KEY) - name (TEXT, NOT NULL) - email (TEXT, UNIQUE) - signup_date (TEXT)

Orders Table

- id (INTEGER, PRIMARY KEY) - customer_id (INTEGER, FOREIGN KEY) - order_date (TEXT) - total_amount (REAL)

Feedback Table

- id (INTEGER, PRIMARY KEY) - user (TEXT, NOT NULL) - email (TEXT, NOT NULL) - feedback (TEXT, NOT NULL) - submission_date (TEXT, DEFAULT CURRENT_TIMESTAMP)

Security Considerations

- SQL queries are validated to prevent dangerous operations
- In read-only mode, all data modification operations are blocked
- Consider running in read-only mode for production use

License

MIT License

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.