M
MCP Sqlite Server
by @liliang-cn
Sqlite MCP server
Created 8/30/2025
Updated 8 days ago
README
Repository documentation and setup instructions
MCP SQLite Server
A Model Context Protocol (MCP) server for SQLite database operations, built with Go. This server allows AI assistants to interact with SQLite databases through a secure, directory-restricted interface.
Features
- Multi-database support: Switch between different SQLite databases dynamically
- Directory security: Operations restricted to specified allowed directories
- Complete SQLite operations: Query, execute, transactions, table management, indexing
- Database management: Create, delete, list, and switch between databases
- Query analysis: Analyze query execution plans and get database statistics
- Transaction support: Execute multiple statements atomically
Installation
Prerequisites
- Go 1.19 or later
- SQLite3 (for creating/managing database files)
Install via go install (recommended)
go install github.com/liliang-cn/mcp-sqlite-server@latest
# Add to PATH (for zsh users)
echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# Verify installation
mcp-sqlite-server --help
Build from source
git clone https://github.com/liliang-cn/mcp-sqlite-server.git
cd mcp-sqlite-server
go build -o mcp-sqlite-server
Usage
Basic usage
Required: You must specify at least one database path or directory as an argument.
# Specify a single database file
mcp-sqlite-server /path/to/database.db
# Specify a directory containing .db files (will use the first found)
mcp-sqlite-server /path/to/db/directory
# Specify multiple directories for access control
mcp-sqlite-server /path/to/db/dir1 /path/to/db/dir2
Note: The server will exit with an error if:
- No arguments are provided
- No valid SQLite database files are found in the specified directories
With Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"sqlite": {
"command": "mcp-sqlite-server",
"args": ["/path/to/your/database/directory"]
}
}
}
Important: Make sure to:
- Add
$HOME/go/bin
to your PATH (for zsh: addexport PATH="$HOME/go/bin:$PATH"
to~/.zshrc
) - Provide a valid database file or directory path in the
args
array - Ensure the specified directory contains at least one
.db
file
Available Tools (19 Total)
Query & Data Manipulation
query
- Execute a SELECT query on the SQLite databaseexecute
- Execute an INSERT, UPDATE, or DELETE statementtransaction
- Execute multiple SQL statements in a transaction (INSERT/UPDATE/DELETE only, no SELECT)
Table Management
create_table
- Create a new table in the databaselist_tables
- List all tables in the databasedescribe_table
- Get the schema of a specific tabledrop_table
- Drop a table from the database
Index Management
create_index
- Create an index on a table column(s) with advanced optionslist_indexes
- List all indexes for a tabledrop_index
- Drop an index from the database
Database Management
create_database
- Create a new SQLite database file with an AI-generated name in the specified directorydatabase_exists
- Check if a database file exists and is valid in allowed directoriesswitch_database
- Switch to a different SQLite database file in allowed directoriescurrent_database
- Show the currently connected database file pathlist_database_files
- List all SQLite database files in a directorydelete_database
- Delete a SQLite database file from allowed directories (CAUTION: This permanently deletes the file)
Database Analysis & Optimization
vacuum
- Optimize the database by rebuilding itanalyze_query
- Analyze the execution plan of a SQL querydatabase_stats
- Get database statistics and information
Security
- All operations are restricted to specified allowed directories
- Path validation prevents directory traversal attacks
- Database file validation ensures only SQLite files are accessed
- Transaction isolation ensures data consistency
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Quick Setup
Installation guide for this server
Installation Command (package not published)
git clone https://github.com/liliang-cn/mcp-sqlite-server
Manual Installation: Please check the README for detailed setup instructions and any additional dependencies required.
Cursor configuration (mcp.json)
{
"mcpServers": {
"liliang-cn-mcp-sqlite-server": {
"command": "git",
"args": [
"clone",
"https://github.com/liliang-cn/mcp-sqlite-server"
]
}
}
}