mcp-server-sqlite

mcp-server-sqlite

Enables AI assistants to execute arbitrary SQL queries on a local SQLite database via a single execute_sql tool.

Category
Visit Server

README

mcp-server-sqlite

Serveur MCP (Model Context Protocol) en Python exposant une base SQLite à un assistant IA via un unique outil : execute_sql. Usage local et personnel.

L'IA peut exécuter n'importe quelle requête SQL (SELECT, INSERT, UPDATE, DELETE, DDL…) et récupérer les résultats au format JSON.

⚠️ Aucun garde-fou de sécurité : le SQL est totalement libre, il n'y a ni mode lecture seule, ni authentification, ni limite. Destiné à un usage local par un utilisateur unique.

Prérequis

  • Python 3.12+
  • uv

Installation

uv sync

Lancement

Le chemin de la base SQLite est fourni via --db-path ou la variable d'environnement SQLITE_DB_PATH. Le fichier est créé automatiquement s'il n'existe pas.

Mode stdio (usage local standard)

uv run mcp-server-sqlite --db-path ./ma_base.db

Mode HTTP (JSON, sans SSE)

uv run mcp-server-sqlite --transport http --db-path ./ma_base.db --host 127.0.0.1 --port 8000

Le transport HTTP répond en application/json (pas de flux SSE), adapté aux clients incapables de streamer. Par défaut : 127.0.0.1:8000.

Accès navigateur : le serveur fonctionne sans aucune configuration d'origine. La protection anti DNS-rebinding du SDK MCP est désactivée (sinon les origines non-localhost sont rejetées avec « Invalid Origin header ») et le CORS autorise par défaut toutes les origines (*). Si vous souhaitez malgré tout restreindre le CORS, utilisez --cors-origin (répétable) :

uv run mcp-server-sqlite --transport http --cors-origin http://localhost:3000 --cors-origin https://mon-app.example

L'en-tête Mcp-Session-Id est exposé pour permettre aux clients navigateurs de lire l'identifiant de session MCP.

L'outil execute_sql

  • Entrée : sql — une chaîne contenant du SQL arbitraire. Plusieurs instructions peuvent être séparées par ; (exécution de type executescript).
  • Sortie (chaîne JSON) :
    • Requête renvoyant des lignes (SELECT) : {"rows": [{"colonne": valeur, ...}, ...]}
    • Requête de modification / DDL : {"rowcount": <nombre de lignes affectées>}
    • Erreur SQL : {"error": "<message>"}
  • Les types non natifs JSON sont convertis en chaîne : BLOB décodé en UTF-8 (repli en hexadécimal), dates au format ISO.
  • Commit automatique après chaque appel réussi.

Configuration côté client MCP

Deux cas de figure : le client lance lui-même le serveur (mode stdio), ou le client se connecte à un serveur HTTP déjà démarré.

Mode stdio (le client lance le serveur)

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "sqlite": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "d:/___AGENTS/mcp-server-sqlite-uv",
        "mcp-server-sqlite",
        "--db-path",
        "d:/___AGENTS/mcp-server-sqlite-uv/ma_base.db"
      ]
    }
  }
}

VS Code (.vscode/mcp.json)

{
  "servers": {
    "sqlite": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "d:/___AGENTS/mcp-server-sqlite-uv",
        "mcp-server-sqlite",
        "--db-path",
        "d:/___AGENTS/mcp-server-sqlite-uv/ma_base.db"
      ]
    }
  }
}

Mode HTTP (le serveur est démarré à part)

Démarrez d'abord le serveur en mode HTTP :

uv run mcp-server-sqlite --transport http --db-path ./ma_base.db --host 127.0.0.1 --port 8000

Le point de terminaison MCP est alors disponible sur http://127.0.0.1:8000/mcp. Configurez ensuite le client pour s'y connecter par URL.

VS Code (.vscode/mcp.json)

{
  "servers": {
    "sqlite": {
      "type": "http",
      "url": "http://127.0.0.1:8000/mcp"
    }
  }
}

Claude Desktop (claude_desktop_config.json)

Claude Desktop ne se connecte qu'en stdio ; on passe par le proxy mcp-remote pour atteindre un serveur HTTP :

{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": ["mcp-remote", "http://127.0.0.1:8000/mcp"]
    }
  }
}

ℹ️ Si le client tourne dans un navigateur, autorisez son origine avec --cors-origin au lancement du serveur (voir la section Lancement).

Tests

uv run pytest

Développement avec mise

Le projet fournit un mise.toml qui gère les outils (Python 3.12, uv) et expose des tâches. uv est configuré pour utiliser le Python fourni par mise.

mise install       # installe Python + uv
mise run install   # uv sync
mise run test      # tests pytest
mise run serve     # serveur en mode stdio
mise run serve-http # serveur en mode HTTP (JSON)

Licence

MIT — voir LICENSE.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured