- Home
- MCP servers
- SQLite
SQLite
- python
0
GitHub Stars
python
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You can query and explore a SQLite database through an MCP server so you can ask natural language questions and get precise results. The server exposes a small set of tools to inspect tables, get schemas, count rows, and run read-only queries, while a client UI lets you interact with those tools in a chat-like experience.
How to use
Interact with the SQLite MCP Server using the Chainlit-based client. You describe what you want to know or fetch from your database, and the agent decides which server tools to call to fulfill your request. Typical tasks include listing tables, inspecting a table’s schema, counting rows, and executing safe SELECT queries. You can ask for combined results or step-by-step details, and the client will present the results in a readable format.
How to install
Prerequisites: Python 3.8 or higher and a pre-populated SQLite database file named example.db in your project directory. You will also need an Anthropic API key for the client, or you can use another supported LLM provider.
# 1) Create a virtual environment
python -m venv venv
# 2) Activate the environment
# Linux/macOS
source venv/bin/activate
# Windows
venv\Scripts\activate
# 3) Install dependencies
pip install -r requirements.txt
Prepare the database and verify you have example.db in your project directory. The server expects the database to be pre-populated and will not initialize or modify data.
Set up environment variables for the client if you are using Anthropic or another LLM provider. This example uses Anthropic.
export ANTHROPIC_API_KEY=your_anthropic_api_key
# If using OpenAI instead, set the corresponding key and adjust the client accordingly
# export OPENAI_API_KEY=your_openai_api_key
Start the MCP server to expose the SQLite tools
python mcp_sqlite_server.py
In a separate terminal, start the Chainlit client to open the web interface
chainlit run mcp_client_chainlit.py
Additional sections
Configuration and security notes: The server provides tools to interact with the SQLite database in a controlled way. It restricts queries to SELECT statements and validates table names to mitigate SQL injection risks. Use a strong, rotating API key strategy for the client if you expose the UI publicly.
Transport and endpoint: The MCP server uses streamable-http for JSON-RPC 2.0 communication and is accessed at http://localhost:8080/mcp. This transport enables real-time, event-driven responses to your prompts.
Server tools exposed by this MCP server: list_tables, get_table_schema, count_rows, execute_query. The client will call these tools automatically as you ask questions, and it will present the results in the chat interface.
Troubleshooting: If the server does not start, verify that the Python script mcp_sqlite_server.py is present and you can reach http://localhost:8080/mcp. If the client fails to load, ensure the port for Chainlit (typically 8001) is available and that the MCP_SERVER_CONFIG in the client script points to the correct server URL. For database errors, confirm example.db exists and is readable, and check the server logs for any SQL-related messages.
Available tools
list_tables
Lists all tables present in the SQLite database.
get_table_schema
Retrieves column names and data types for a specified table.
count_rows
Counts the number of rows in a specified table.
execute_query
Executes read-only SQL SELECT queries and returns results.