SQLMind MCP Server is a Model Context Protocol server that gives AI agents safe, read-only access to SQL databases.
Phase 6A supports:
- SQLite through
data/sample.db - PostgreSQL through
psycopg2-binary - MySQL through
pymysql - MCP tools for table listing, table description, full schema retrieval, and safe SELECT execution
- SQL safety checks that block destructive statements
- Maximum 100 returned rows by default
- Query logging to
logs/query.log - A reset script for a realistic sample database
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python reset_database.pyCopy .env.example to .env if you want to override defaults.
SQLMind reads the initial database from environment variables:
SQLMIND_DB_TYPE=sqlite
SQLMIND_SQLITE_FILE_PATH=data/sample.db
SQLMIND_DB_HOST=localhost
SQLMIND_DB_PORT=
SQLMIND_DATABASE_NAME=
SQLMIND_DB_USERNAME=
SQLMIND_DB_PASSWORD=
Valid SQLMIND_DB_TYPE values are:
sqlitepostgresqlmysql
SQLite uses SQLMIND_SQLITE_FILE_PATH. PostgreSQL and MySQL use SQLMIND_DB_HOST, SQLMIND_DB_PORT, SQLMIND_DATABASE_NAME, SQLMIND_DB_USERNAME, and SQLMIND_DB_PASSWORD.
python server.pyThe server uses stdio transport through the official MCP Python SDK.
Returns all user-defined tables.
Returns column metadata for one table.
Returns all table schemas.
Executes one read-only SELECT statement and returns:
{
"success": true,
"columns": ["name", "year"],
"rows": [["John Carter", 3]],
"row_count": 1,
"truncated": false
}Connects SQLMind to a SQLite, PostgreSQL, or MySQL database at runtime.
SQLite example:
{
"db_type": "sqlite",
"sqlite_file_path": "data/sample.db"
}PostgreSQL example:
{
"db_type": "postgresql",
"host": "localhost",
"port": 5432,
"database_name": "school",
"username": "postgres",
"password": "secret"
}MySQL example:
{
"db_type": "mysql",
"host": "localhost",
"port": 3306,
"database_name": "school",
"username": "root",
"password": "secret"
}Successful responses never include the password:
{
"success": true,
"database": {
"db_type": "mysql",
"sqlite_file_path": null,
"host": "localhost",
"port": 3306,
"database_name": "school",
"username": "root"
}
}Unsafe SQL returns:
{
"success": false,
"error": "Unsafe SQL operation detected."
}Allowed:
- One
SELECTstatement
Blocked:
DROPDELETEUPDATEINSERTALTERTRUNCATECREATEREPLACEATTACHDETACHVACUUMPRAGMA- semicolon chaining
pytest{
"mcpServers": {
"sqlmind": {
"command": "python",
"args": ["C:\\Users\\inder\\OneDrive\\Desktop\\SQLMind-MCP\\server.py"]
}
}
}