SQLite MCP Server

SQLite MCP Server

By prayanks GitHub

These are MCP server implementations for accessing a SQLite database in your MCP client. There is both a SDIO and a SSE implementation.

mcp mcp-server
Overview

What is SQLite MCP Server?

SQLite MCP Server is a Python-based server that connects to a SQLite database, specifically designed for accessing startup funding data through the Model Context Protocol (MCP). It allows clients to execute read-only SQL queries and provides prompt templates for data analysis tasks.

How to use SQLite MCP Server?

To use the SQLite MCP Server, set up the server by creating a sample SQLite database, running the server script, and then accessing resources or executing SQL queries through the MCP client.

Key features of SQLite MCP Server?

  • Connects to a SQLite database and exposes table schemas as resources.
  • Provides a read-only SQL query tool for executing SELECT statements.
  • Offers prompt templates for generating data analysis insights.
  • Communicates via the STDIO protocol for easy integration.

Use cases of SQLite MCP Server?

  1. Accessing and analyzing startup funding data.
  2. Executing SQL queries to retrieve specific information from the database.
  3. Integrating with language models for enhanced data analysis.

FAQ from SQLite MCP Server?

  • Can I use SQLite MCP Server with any SQLite database?

Yes, as long as the database contains the appropriate schema and data.

  • Is there a limit to the SQL queries I can run?

Only SELECT statements are permitted for read-only access.

  • How do I install the SQLite MCP Server?

Follow the setup instructions in the documentation to create a virtual environment and install dependencies.

Content

SQLite MCP Server

This repository contains an MCP (Model Context Protocol) server written in Python that connects to a SQLite database containing startup funding data. The server exposes table schemas as resources, provides a read-only SQL query tool, and offers prompt templates for common data analysis tasks. It is designed to work with MCP clients and language models (LLMs) and communicates via the STDIO protocol.

Table of Contents


Overview

The MCP server uses the MCP Python SDK (with CLI extras) to implement a server that:

  • Connects to a SQLite database (e.g., a database with startup funding information).
  • Exposes table schemas as MCP resources.
  • Provides a tool for executing read-only SQL queries.
  • Offers prompt templates that help language models generate data analysis insights.
  • Communicates via the STDIO protocol, reading JSON-RPC messages from standard input and writing responses to standard output.

Features

  • Resources

    • schema://sqlite/{table}: Returns the SQL schema for a specific table.
    • schema://sqlite/all: Returns a JSON mapping of all table schemas.
  • Tools

    • sql_query: Executes read-only SQL queries. Only SELECT statements are permitted.
  • Prompts

    • analyze_table_prompt: Generates an analysis prompt for a specific table.
    • describe_query_prompt: Generates a prompt explaining a SQL query.
  • STDIO Protocol

    • Reads from stdin and writes responses to stdout, making integration easy.
  • Logging

    • Uses Python’s logging module to trace activity and debug errors.

Setup and Installation

Creating the Sample SQLite Database

Save the following script as create_db.py:

<same as earlier>

Run with:

python create_db.py

Creating a Virtual Environment

python -m venv venv

Activate the environment:

  • macOS/Linux:

    source venv/bin/activate
    
  • Windows:

    venv\Scripts\activate
    

Install dependencies:

pip install "mcp[cli]"

Running the MCP Server

  1. Save your server code as sqlite_mcp_server.py.
  2. Run the server:
python sqlite_mcp_server.py

Optional (using uv):

uv run sqlite_mcp_server.py

Installing into Claude Desktop

Save the following as install_to_claude.py and run it:

python install_to_claude.py

Update Claude Desktop config with:

{
  "mcpServers": {
    "sqlite_mcp_server": {
      "command": "python",
      "args": ["-u", "/absolute/path/to/sqlite_mcp_server.py"]
    }
  }
}

Restart Claude Desktop afterward.


Usage

  • Access Resources: schema://sqlite/all, schema://sqlite/startups
  • Invoke Tools:
    SELECT * FROM startups WHERE funding_amount > 10000000;
    
  • Use Prompts: Generate SQL or explain queries.

Testing

Run the test script:

python sqlite_mcp_client_tests.py sqlite_mcp_server.py

This script tests:

  • Listing resources
  • Retrieving schemas
  • Valid/invalid queries
  • Prompt templates

Logging

Modify logging config:

logging.basicConfig(
    filename='mcp_server.log',
    level=logging.DEBUG,
    format="[%(asctime)s] %(levelname)s - %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S"
)

Logs print to stderr by default.


License

This project is licensed under the MIT License. See the LICENSE file.


Additional Notes

  • Adjust paths in installation/config scripts as needed.
  • Ensure the SQLite database is created before running the server.
  • Integrates with MCP Inspector or Claude Desktop.
No tools information available.

This is a basic MCP Server-Client Impl using SSE

mcp server-client
View Details

-

mcp model-context-protocol
View Details

Mirror of

image-generation mcp-server
View Details

Buttplug.io Model Context Protocol (MCP) Server

mcp buttplug
View Details

Secure MCP server for analyzing Excel files with oletools

oletools mcp-server
View Details

MCP web search using perplexity without any API KEYS

mcp puppeteer
View Details