A Model Context Protocol (MCP) server for SQLite database operations. This server provides a standardized interface for SQLite database interactions including schema inspection, read and write operations.
The MCP server exposes three main tools:
- Description: List all tables in the SQLite database with their schema information
- Parameters: None
- Usage: Provides complete schema introspection including columns, types, constraints, and indexes
- Description: Execute read-only queries against the SQLite database.
- Parameters:
sql(required): Read-only SQL query to execute -Usage: Only SELECT, WITH, and EXPLAIN queries are allowed
- Example:
SELECT * FROM users WHERE age > 25
- Description: Execute write operations against the SQLite database
- Parameters:
sql(required): SQL statement that modifies the database
- Usage: INSERT, UPDATE, DELETE, CREATE, ALTER, DROP operations
- Example:
INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com')
- Go: SQLite MCP Server requires Go 1.26 or later. Download from go.dev/doc/install
- Task: Install go-task to run automated development tasks. Install using Homebrew with
brew install go-task - SQLite3: For creating and managing SQLite databases locally
- golangci-lint: Go linter. Install using Homebrew with
brew install golangci-lintor follow instructions at golangci-lint.run (optional) - Docker: To run the server with Docker (optional)
- Clone the repository:
git clone https://github.com/rvarun11/sqlite-mcp.git
cd sqlite-mcp- Build:
# Builds the binary and the example database
task build
# Or if you prefer Docker:
task docker-buildAfter installation, add the following configuration to your MCP client:
{
"mcpServers": {
"sqlite": {
"url": "http://localhost:3000/mcp"
}
}
}Start the server before connecting the MCP client:
./build/sqlite-mcp --database /path/to/your/database.dbOptions:
--database, -d: Path to SQLite database file (required)--address: Streamable HTTP listen address (default:${HOST:-0.0.0.0}:${PORT:-3000})--endpoint: Streamable HTTP endpoint path (default:/mcp)--debug: Enable debug mode for verbose logging (optional)
{
"mcpServers": {
"sqlite": {
"url": "http://localhost:3000/mcp"
}
}
}Start the Docker container before connecting the MCP client. The image uses example.sql to build the example database. To use a custom schema SQL file, see the Docker commands below.
The server exposes unauthenticated database write tools. Keep port 3000 bound to localhost unless it is protected by authentication and TLS at a reverse proxy.
To see a list of all available development tasks, run:
task --listAvailable tasks include:
fmt: Tidy modules and format codelint: Rungoclangci-lintstatic analysistest: Run unit testscheck: Runfmt,lintandtest.build-example-db: Create example db fromexample.sqlrun-dev: Run from source with example db, includes all checksbuild: Build the binary with example db, including testsdocker-build: Build Docker image
- After building the binary with
task buildortask build-with-db, run:
./build/sqlite-mcp --database ./build/example.db [--debug]Connect an MCP client to http://localhost:3000/mcp. A health endpoint is available at http://localhost:3000/health.
- After building the docker image with
task docker-build, run the Docker container:
# Run with default example.sql database
docker run --rm -p 127.0.0.1:3000:3000 sqlite-mcp-server
# Or run with custom schema.sql file
docker run --rm -p 127.0.0.1:3000:3000 -v "/path/to/your/schema.sql:/data/schema.sql:ro" sqlite-mcp-serverConnect the MCP client to http://localhost:3000/mcp.