MCP Server SQLite
A specialized server implementation for the Minecraft Protocol (MCP) project, providing a persistent backend using SQLite. It extends `mcp-server` to manage user data and game state within an SQLite database. Current version is 2025.4.25, following a rapid release cycle often synchronized with Minecraft client updates or changes to the underlying MCP protocol.
Common errors
-
ModuleNotFoundError: No module named 'mcp_server_sqlite'
cause The `mcp-server-sqlite` package is not installed in the current Python environment.fix`pip install mcp-server-sqlite` -
AttributeError: module 'mcp_server_sqlite' has no attribute 'MCPSQLiteServer'
cause Incorrect import path. The `MCPSQLiteServer` class is located within the `server` submodule, not directly under the top-level package.fixChange `from mcp_server_sqlite import MCPSQLiteServer` to `from mcp_server_sqlite.server import MCPSQLiteServer` -
sqlite3.OperationalError: database is locked
cause Another process or application is holding a lock on the SQLite database file, preventing the server from accessing it, or a previous server instance didn't shut down cleanly.fixEnsure no other applications are accessing the `.db` file. If a previous server instance crashed, try restarting your application or system to clear any lingering locks. Consider using an absolute path for `database_file` in `MCPSQLiteServer()` to avoid ambiguity and ensure consistent file access.
Warnings
- gotcha The server defaults to creating `mcp_server.db` in the current working directory if no `database_file` is specified during initialization. Running the server from different directories will create separate, distinct database files, leading to data inconsistencies or loss if not explicitly managed.
- breaking As `mcp-server-sqlite` heavily relies on the `mcp-server` base library, breaking changes or API shifts in `mcp-server` may indirectly break `mcp-server-sqlite`. The `YYYY.MM.DD` versioning of both projects suggests frequent updates that might not always be backward compatible with older `mcp-server` versions.
- gotcha If the server's `run()` method is not wrapped in a `try...except` block (e.g., `KeyboardInterrupt` or other exceptions), the server will abruptly terminate without graceful shutdown, potentially leaving database connections open or causing data corruption.
Install
-
pip install mcp-server-sqlite
Imports
- MCPSQLiteServer
from mcp_server_sqlite import MCPSQLiteServer
from mcp_server_sqlite.server import MCPSQLiteServer
Quickstart
import logging
from mcp_server_sqlite.server import MCPSQLiteServer
# Configure basic logging for better visibility
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# Initialize the SQLite MCP server.
# By default, it creates 'mcp_server.db' in the current working directory.
# For production, it's recommended to specify an explicit path:
# server = MCPSQLiteServer(database_file='/var/lib/mcp/my_server.db')
server = MCPSQLiteServer()
print("Starting MCP SQLite server on 0.0.0.0:25565...")
try:
server.run()
except KeyboardInterrupt:
logging.info("Server stopped by user (KeyboardInterrupt).")
except Exception as e:
logging.error(f"An unexpected error occurred: {e}", exc_info=True)