Provides comprehensive SQLite database management tools including creating and querying databases, managing tables and schemas, and performing CRUD operations (insert, update, delete) on records.
SQLite MCP Server
A Model Context Protocol (MCP) server for SQLite database operations, built with FastMCP. This server allows LLM agents to read, create, update, and delete data in SQLite databases.
Features
Database Management: Open/close SQLite databases
CRUD Operations: Create tables, insert, read, update, and delete records
Query Execution: Execute raw SQL SELECT queries
Schema Inspection: List tables and view table schemas
Type-Safe: Full type hints and error handling
Installation
Prerequisites
Python 3.8 or higher
pip
Setup
Clone or navigate to the project directory:
Create a virtual environment (recommended):
Install dependencies:
Quick Start
Running the Server
Available Tools
1. open_database
Opens or creates a SQLite database file.
Parameters:
path(string): Path to the SQLite database file
Example:
2. close_database
Closes the current database connection.
Example:
3. execute_query
Execute a SELECT query and return results.
Parameters:
query(string): SQL SELECT queryparameters(array, optional): Query parameters for prepared statements
Example:
4. create_table
Create a new table in the database.
Parameters:
table(string): Table nameschema(string): Column definitions
Example:
5. insert
Insert a row into a table.
Parameters:
table(string): Table namedata(object): Column names and values
Example:
6. update
Update rows in a table.
Parameters:
table(string): Table namedata(object): Column names and new valueswhere(string): WHERE clause conditionwhere_params(array, optional): Parameters for WHERE clause
Example:
7. delete
Delete rows from a table.
Parameters:
table(string): Table namewhere(string): WHERE clause conditionwhere_params(array, optional): Parameters for WHERE clause
Example:
8. list_tables
List all tables in the database.
Example:
Returns:
9. get_table_schema
Get the schema of a table (columns, types, constraints).
Parameters:
table(string): Table name
Example:
Returns:
Usage Examples
Example 1: Create a Database and Table
Example 2: Insert and Query Data
Example 3: Update Records
Example 4: Delete Records
Integration with LLM Agents
This MCP server is designed to be used with LLM agents. When configured properly, the agent can:
Create databases and tables
Insert, update, and delete records
Query data
Inspect database schemas
Example Agent Prompt
Error Handling
All tools include comprehensive error handling. Common errors:
"No database is open": Call
open_databasefirst"Table creation failed": Check SQL syntax in schema parameter
"Query execution failed": Verify SQL query syntax and parameters
"Insert/Update/Delete failed": Check table name, column names, and data types
Project Structure
Configuration
To use this server with Claude or other MCP clients, add it to your configuration file:
For Claude Desktop
Edit ~/.config/Claude/claude_desktop_config.json:
Performance Notes
SQLite is suitable for single-user and small-team applications
For concurrent access, consider using connection pooling
Large queries may benefit from appropriate indexing
Use transactions for data consistency (can be added if needed)
Security Considerations
⚠️ Important: This server executes SQL queries directly. When using with untrusted input:
Always use parameterized queries (the
parametersfields in tools)Validate input data before sending to the server
Restrict database file permissions
Don't expose sensitive data in database files
Troubleshooting
Server Won't Start
Check Python version (3.8+)
Verify all dependencies installed:
pip install -r requirements.txtCheck for port conflicts if using HTTP transport
Database File Not Found
Ensure the directory path exists
Check file permissions
Use absolute paths for database files
Query Errors
Verify table names and column names match exactly
Use proper SQL syntax
Check data types match column definitions
Development
To modify the server:
Edit
sqlite_mcp/server.pyto add new toolsEdit
sqlite_mcp/db.pyto modify database operationsRestart the server to apply changes
License
MIT
Contributing
Feel free to submit issues and enhancement requests!
This server cannot be installed