A very simple Model Context Protocol (MCP) server for interacting with SQLite databases. This allows Cursor AI to interact with your employees.db database safely through an MCP server instead of direct database access.
-
Run the setup script:
chmod +x setup.sh ./setup.sh
-
Test the setup:
python3 test_mcp_server.py
-
Start your preferred MCP server:
Option 1 (Recommended): Node.js MCP Server
npx @modelcontextprotocol/server-sqlite /workspace/employees.db
Option 2: Python MCP Server
python3 simple_mcp_server.py /workspace/employees.db
employees.db- Your SQLite database with employee and department datasimple_mcp_server.py- Custom Python MCP server implementationmcp-config.json- Configuration file for Cursor AIsetup.sh- Automated setup scripttest_mcp_server.py- Test script to verify functionalitypackage.json- Node.js dependencies
Copy the mcp-config.json to your Cursor settings directory or configure Cursor to use the MCP server with these settings:
{
"mcpServers": {
"sqlite-server": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-sqlite",
"/workspace/employees.db"
]
}
}
}The MCP server provides these safe, read-only operations:
- List Tables - Get all table names in the database
- Get Schema - View the structure of all tables
- Execute Queries - Run SELECT queries (read-only)
-- List all employees
SELECT * FROM employees;
-- Get employees by department
SELECT e.name, d.name as department, e.salary
FROM employees e
JOIN departments d ON e.department_id = d.id;
-- Count employees per department
SELECT d.name, COUNT(*) as employee_count
FROM departments d
LEFT JOIN employees e ON d.id = e.department_id
GROUP BY d.name;- Read-only access - Only SELECT queries are allowed
- Query validation - Prevents dangerous SQL operations
- Row limits - Prevents excessive data retrieval
- Safe parameter binding - Protection against SQL injection
-
"Database file not found"
- Ensure
/workspace/employees.dbexists - Check file permissions
- Ensure
-
"Node.js not found"
- Install Node.js from https://nodejs.org/
- Restart your terminal
-
"MCP server not responding"
- Check if the server process is running
- Verify the configuration file path
- Review server logs for errors
Run the test script to verify everything is working:
python3 test_mcp_server.pyThis will check:
- Database accessibility
- Python MCP server functionality
- Node.js MCP server availability
Your employees.db contains:
employees table:
- id (PRIMARY KEY)
- name (TEXT)
- department_id (INTEGER, FOREIGN KEY)
- salary (REAL)
- hire_date (TEXT)
departments table:
- id (PRIMARY KEY)
- name (TEXT)
If you encounter issues:
- Run the test script:
python3 test_mcp_server.py - Check that Node.js and Python are properly installed
- Verify the database file exists and is readable
- Ensure MCP server configuration matches your setup
MIT License - feel free to modify and use as needed.