SQLite MCP Server
SQLite MCP servers enable AI models to interact with SQLite databases, providing capabilities for structured data operations, SQL queries, and local data management.
Overview
The MCP SQLite Server provides a lightweight and efficient way for AI models to interact with SQLite databases. Based on the official Python reference, this Node.js implementation offers an npx-based solution for environments where Python's UVX runner might not be available. It enables AI to perform structured data operations, execute SQL queries, and manage local data, making it ideal for embedded applications and local data storage needs.
Created by:
Developed by johnnyoshika
Key Features
Local Data Management
Efficiently manage and query data stored in local SQLite files.
SQL Query Execution
Execute standard SQL queries for data retrieval and manipulation.
Lightweight & Embedded
Ideal for embedded applications and scenarios requiring a serverless database.
Schema Inspection
Inspect database schemas, tables, and column details.
Available Tools
Quick Reference
| Tool | Purpose | Category |
|---|---|---|
read_query | Execute SELECT queries | Read |
write_query | Execute INSERT/UPDATE/DELETE | Write |
create_table | Create a table | Schema |
list_tables | List tables in the database | Schema |
describe_table | Get table structure details | Schema |
Detailed Usage
read_queryβΆ
Execute a SELECT query.
use_mcp_tool({
server_name: "sqlite",
tool_name: "read_query",
arguments: {
query: "SELECT * FROM users WHERE id = 1"
}
});
Returns matching rows from the database.
write_queryβΆ
Execute an INSERT, UPDATE, or DELETE query.
use_mcp_tool({
server_name: "sqlite",
tool_name: "write_query",
arguments: {
query: "INSERT INTO users (name, email) VALUES ('Jane Doe', '[email protected]')"
}
});
Returns information about the executed statement (e.g., last insert ID, rows affected).
list_tablesβΆ
List all tables in the connected SQLite database.
use_mcp_tool({
server_name: "sqlite",
tool_name: "list_tables",
arguments: {}
});
Returns a list of table names.
describe_tableβΆ
Get the structure (columns, types) of a specific table.
use_mcp_tool({
server_name: "sqlite",
tool_name: "describe_table",
arguments: {
table_name: "users"
}
});
Provides column names, data types, and other table details.
Installation
{
"mcpServers": {
"sqlite": {
"command": "npx",
"args": [
"-y",
"mcp-server-sqlite-npx",
"/absolute/path/to/database.db"
],
"env": {}
}
}
}
Database Path:
Replace /absolute/path/to/database.db with the actual path to your SQLite database file.
Common Use Cases
1. Local Data Storage
Store and retrieve application configuration or user preferences locally:
use_mcp_tool({
server_name: "sqlite",
tool_name: "create_table",
arguments: {
query: "CREATE TABLE IF NOT EXISTS settings (key TEXT PRIMARY KEY, value TEXT)"
}
});
use_mcp_tool({
server_name: "sqlite",
tool_name: "write_query",
arguments: {
query: "INSERT OR REPLACE INTO settings (key, value) VALUES ('theme', 'dark')"
}
});
use_mcp_tool({
server_name: "sqlite",
tool_name: "read_query",
arguments: {
query: "SELECT value FROM settings WHERE key = 'theme'"
}
});
2. Embedded Analytics
Perform simple analytics on local datasets without external dependencies:
use_mcp_tool({
server_name: "sqlite",
tool_name: "read_query",
arguments: {
query: "SELECT category, COUNT(*) as count FROM products GROUP BY category ORDER BY count DESC"
}
});
3. Caching for Offline Access
Cache data from remote APIs for offline access or reduced network calls:
use_mcp_tool({
server_name: "sqlite",
tool_name: "create_table",
arguments: {
query: "CREATE TABLE IF NOT EXISTS api_cache (url TEXT PRIMARY KEY, data TEXT, timestamp INTEGER)"
}
});
use_mcp_tool({
server_name: "sqlite",
tool_name: "write_query",
arguments: {
query: "INSERT OR REPLACE INTO api_cache (url, data, timestamp) VALUES ('/api/data', 'cached data', 0)"
}
});
use_mcp_tool({
server_name: "sqlite",
tool_name: "read_query",
arguments: {
query: "SELECT data FROM api_cache WHERE url = '/api/data'"
}
});
Connection String Format
The SQLite MCP server connects directly to a specified .db file. The path to this file is provided as an argument during server initialization.
- Database Path: The absolute path to the SQLite database file (e.g.,
/absolute/path/to/database.db).
Sources
Related Articles & Guides
Airtable MCP Server
Airtable MCP servers enable AI models to interact with Airtable bases, providing capabilities for base management, record operations, field configuration, and structured data automation.
ArangoDB MCP Server
ArangoDB MCP servers enable AI models to interact with ArangoDB databases, providing capabilities for document operations, graph queries, AQL queries, and multi-model data management.
ClickHouse MCP Server
ClickHouse MCP servers enable AI models to interact with ClickHouse databases, providing capabilities for high-performance analytical queries, data warehousing, and real-time analytics.