SQLite MCP Server

SQLite MCP Server

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

prayanks

Developer Tools
Visit Server

README

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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python