A server-side implementation of the Model Context Protocol (MCP) for SQLite databases, enabling AI applications to interact with multiple SQLite databases through a standardized protocol. Each database must be registered before use, allowing dynamic database management and multi-database operations.
sqlite-mcp-server/
├── cmd/
│ └── server/ # Main application entry point
├── internal/
│ ├── mcp/ # MCP implementation
│ │ ├── tools/ # Tool implementations
│ │ ├── resources/ # Resource implementations
│ │ └── prompts/ # Prompt templates
│ └── db/ # Database management
│ └── migrations/ # Database migrations
db/register_database
: Register a new SQLite database for usedb/list_databases
: List all registered databases
db/get_table_schema
: Get schema for a specific table in a databasedb/insert_record
: Insert a new record into a tabledb/query
: Execute a read-only SQL query on a specific databasedb/get_tables
: List all tables in a specific databasedb/get_schema
: Get full schema of a specific database
db/databases
: List of all registered databases
db/multi_database_help
: Overview of multi-database capabilitiesdb/register_help
: Help for registering databasesdb/query_help
: Help text for constructing queriesdb/schema_help
: Help text for understanding schemasdb/insert_help
: Help text for inserting records
- Go 1.21 or later
- SQLite 3
go install github.com/nipunap/sqlite-mcp-server@latest
Run as a local MCP server:
# Start with registry only (no default database)
sqlite-mcp-server --registry registry.db
# Start with registry and register a default database
sqlite-mcp-server --registry registry.db --db path/to/default.sqlite
The server communicates via STDIO using JSON-RPC 2.0 messages.
- Register a database:
{
"jsonrpc": "2.0",
"id": 1,
"method": "invoke",
"params": {
"name": "db/register_database",
"params": {
"name": "users_db",
"path": "/absolute/path/to/users.sqlite",
"description": "User management database",
"readonly": false,
"owner": "app_user"
}
}
}
- List registered databases:
{
"jsonrpc": "2.0",
"id": 2,
"method": "invoke",
"params": {
"name": "db/list_databases",
"params": {}
}
}
- Query a specific database:
{
"jsonrpc": "2.0",
"id": 3,
"method": "invoke",
"params": {
"name": "db/query",
"params": {
"database_name": "users_db",
"query": "SELECT * FROM users WHERE id = ?",
"args": [1]
}
}
}
- Get tables from a specific database:
{
"jsonrpc": "2.0",
"id": 4,
"method": "invoke",
"params": {
"name": "db/get_tables",
"params": {
"database_name": "users_db"
}
}
}
- Insert into a specific database:
{
"jsonrpc": "2.0",
"id": 5,
"method": "invoke",
"params": {
"name": "db/insert_record",
"params": {
"database_name": "users_db",
"table_name": "users",
"data": {
"name": "John Doe",
"email": "john@example.com"
}
}
}
}
- Clone the repository:
git clone https://github.com/nipunap/sqlite-mcp-server.git
cd sqlite-mcp-server
- Install dependencies:
go mod download
- Run tests:
go test ./...
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.