mcpField
M
mcp-sqlite

mcp-sqlite

Local
github.com/panasencoDatabases28Updated 39w ago

About mcp-sqlite

mcp-sqlite is an MCP server for SQLite database files that gives AI agents a table catalog and SQL query access without connecting them to external systems. It reads Datasette-compatible metadata, so humans and agents can explore the same data. It is aimed at local data exploration with agents.

Key features

  1. 01Catalog of tables and columns via sqlite_get_catalog
  2. 02Descriptions added through YAML or JSON metadata
  3. 03Arbitrary SQL execution with sqlite_execute
  4. 04Canned queries exposed as separate MCP tools
  5. 05Compatible with the Datasette metadata format

Use cases

  1. 01Let an AI agent query a local SQLite file
  2. 02Add descriptions to tables and columns to aid agent understanding
  3. 03Explore the same dataset interactively with MCP Inspector or Datasette

MCP support

This project is an MCP server that exposes tools such as sqlite_get_catalog and sqlite_execute to MCP clients, and creates one tool for each canned query defined in the metadata.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"sqlite-panasenco": {
"command": "uvx",
"args": [
"mcp-sqlite"
]
}
}
}
Run commanduvx mcp-sqlite

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypimcp-sqlite

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

mcp-sqlite

README image

Provide useful data to AI agents without giving them access to external systems. Compatible with Datasette for human users!

Features

  • AI agents can get the structure of all tables and columns in the SQLite database in one command - sqlite_get_catalog.
    • The catalog can be enriched with descriptions for the tables and columns using a simple YAML or JSON metadata file.
  • The same metadata file can contain canned queries to the AI to use. Each canned query will be turned into a separate MCP tool sqlite_execute_main_{tool name}.
  • AI agents can execute arbitrary SQL queries with sqlite_execute.

Quickstart using Visual Studio Code

  1. Install uv.

  2. Install Visual Studio Code if you don't already have it. Turn on GitHub Copilot.

  3. Open this repo in VS Code. Open a GitHub Copilot agent mode chat. Check the available tools - you should see MCP Server: sqlite_sample with three available tools.

    README image

  4. You should be able to ask Copilot in agent mode a question like "Get Titanic survivors of age 28" and get a response.

    README image

  5. Use the sample MCP configuration file mcp.json and the sample metadata file titanic.yml as a starting point for your own configuration.

Interactive exploration with MCP Inspector and Datasette

The same database and metadata files can be used to explore the data interactively with MCP Inspector and Datasette.

MCP InspectorDatasette
README imageREADME image
README imageREADME image
MCP Inspector

Use the MCP Inspector dashboard to interact with the SQLite database the same way that an AI agent would:

  1. Install npm.
  2. Run:
    npx @modelcontextprotocol/inspector uvx mcp-sqlite sample/titanic.db --metadata sample/titanic.yml
    
Datasette

Since mcp-sqlite metadata is compatible with the Datasette metadata file, you can also explore your data with Datasette:

uvx datasette serve sample/titanic.db --metadata sample/titanic.yml

Compatibility with Datasette allows both AI agents and humans to easily explore the same local data!

MCP Tools provided by mcp-sqlite

  • sqlite_get_catalog(): Tool the agent can call to get the complete catalog of the databases, tables, and columns in the data, combined with metadata from the metadata file. In an earlier iteration of mcp-sqlite, this was a resource instead of a tool, but resources are not as widely supported, so it got turned into a tool. If you have a usecase for the catalog as a resource, open an issue and we'll bring it back!
  • sqlite_execute(sql): Tool the agent can call to execute arbitrary SQL. The table results are returned as HTML. For more information about why HTML is the best format for LLMs to process, see Siu et al.
  • {canned query name}({canned query args}): A tool is created for each canned query in the metadata, allowing the agent to run predefined queries without writing any SQL.

Usage

Command-line options
usage: mcp-sqlite [-h] [-m METADATA] [-p PREFIX] [-v] sqlite_file

CLI command to start an MCP server for interacting with SQLite data.

positional arguments:
  sqlite_file           Path to SQLite file to serve the MCP server for.

options:
  -h, --help            show this help message and exit
  -m, --metadata METADATA
                        Path to Datasette-compatible metadata YAML or JSON file.
  -p, --prefix PREFIX   Prefix for MCP tools. Defaults to no prefix.
  -v, --verbose         Be verbose. Include once for INFO output, twice for DEBUG output.
Metadata
Hidden tables

Hiding a table with hidden: true will hide it from the catalog returned by the MCP tool sqlite_get_catalog(). However, note that the table will still be accessible by the AI agent! Never rely on hiding a table from the catalog as a security feature.

Canned queries

Canned queries are each turned into a separate callable MCP tool by mcp-sqlite.

For example, a query named my_canned_query will become a tool my_canned_query.

The canned queries functionality is still in active development with more features planned for development soon:

Roadmap

Datasette query featureSupported in mcp-sqlite?
Displayed in catalog✅
Executable✅
Titles✅
Descriptions✅
Parameters✅
Explicit parameters❌ (planned)
Hide SQL✅
Write restrictions on canned queries✅
Pagination❌ (planned)
Cross-database queries❌ (planned)
Fragments❌ (not planned)
Magic parameters❌ (not planned)

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.