SQLite MCP to interact with your DB

Query SQL with natural language

SQLite MCP server

  1. Setup Demo DB with sqlite

  • install VSCode/Cursosr extension SQLite Viewer

  • generate data

    • create file name mcp_demo.db

    • using python code to setup data

        import sqlite3
    
        # Connect to SQLite database (or create it if it doesn't exist)
        conn = sqlite3.connect('mcp_demo.db')
    
        # Create a cursor object
        cursor = conn.cursor()
    
        # Create a table
        cursor.execute('''
        CREATE TABLE IF NOT EXISTS mcp_data (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            sensor_name TEXT NOT NULL,
            sensor_value REAL NOT NULL,
            timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
        )
        ''')
    
        # Insert sample data
        cursor.execute("INSERT INTO mcp_data (sensor_name, sensor_value) VALUES ('Temperature', 25.5)")
        cursor.execute("INSERT INTO mcp_data (sensor_name, sensor_value) VALUES ('Humidity', 60.0)")
    
        # Commit changes and close the connection
        conn.commit()
        conn.close()
    
        print("Database created and sample data inserted.")
    • setup MCP server with Cursor like:

     "sqlite": {
      "command": "uv",
      "args": [
        "run",
        "mcp-server-sqlite",
        "--db-path",
        "/path/automation-test-ai/mcp_demo.db"
      ]
    

MCP-Database-server

Last updated