Skip to main content

datasette-mcp

PyPI Changelog Tests License

Adds a /-/mcp MCP server to any Datasette instance

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-mcp

Usage

Start Datasette as normal, then configure an MCP client to connect to:

http://localhost:8001/-/mcp

The endpoint uses MCP Streamable HTTP and exposes three read-only tools by default:

  • list_databases lists the databases available to the current Datasette actor.
  • get_database_schema returns the complete SQL schema for a database, including tables, indexes, views, and triggers.
  • execute_sql executes one read-only SQL statement and returns structured columns, column-keyed row objects, and a truncation indicator.

Datasette database visibility and execute-sql permissions are enforced for every tool call. SQL uses the same validate_sql_select() and read-only Database.execute() path as Datasette's custom SQL interface.

Canned queries

Datasette canned queries (called stored queries in Datasette 1.0), including writable canned queries, can be exposed as MCP tools by enabling this plugin setting:

plugins:
  datasette-mcp:
    canned_queries: true

This adds three more tools:

  • list_canned_queries lists the canned queries the current actor can view, optionally filtered to one database. Each entry includes the query's name, title, description, SQL (omitted if hide_sql is set), the parameters it accepts and whether it writes data.
  • execute_canned_query runs a read-only canned query with a dictionary of parameters and returns the same structured results as execute_sql.
  • execute_writable_canned_query runs a writable canned query and returns its success message and number of affected rows. This tool is annotated as destructive, so MCP clients can ask for confirmation before running it.

Canned queries follow the same permission checks as Datasette's own query pages for the actor making the MCP request: the actor needs view-database and view-query permission. On Datasette 1.0, untrusted stored queries also need execute-sql, or execute-write-sql plus the relevant table permissions for writes. Missing parameters default to empty strings, as they do in Datasette, and magic parameters such as :_actor_id are resolved from the MCP HTTP request.

Registering additional MCP tools

Other Datasette plugins can add tools to this MCP server by implementing the register_mcp_tools(datasette, mcp) plugin hook. The mcp argument is the MCPServer for that Datasette instance, so implementations use the MCP Python SDK's normal @mcp.tool() decorator:

from datasette import hookimpl


@hookimpl
def register_mcp_tools(datasette, mcp):
    @mcp.tool()
    async def database_count() -> int:
        """Return the number of user-facing databases."""
        return len(
            [name for name in datasette.databases if name != "_internal"]
        )

The hook itself is synchronous because tools are registered while the MCP server is being constructed. Tool functions can be synchronous or asynchronous and can use all of the input, output, context, and annotation features provided by the MCP Python SDK.

Datasette-mcp registers list_databases, get_database_schema, and execute_sql through this same hook.

Development

To set up this plugin locally, first checkout the code. You can confirm it is available like this:

cd datasette-mcp
# Confirm the plugin is visible
uv run datasette plugins

To run the tests:

uv run pytest

Metadata

Release files for datasette-mcp 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-mcp 0.3
File Size Uploaded Provenance Actions
datasette_mcp-0.3.tar.gz 20.6 kB With provenance Details for datasette_mcp-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for datasette-mcp 0.3
File Interpreter ABI Platform Actions
datasette_mcp-0.3-py3-none-any.whl Python 3 none any Details for datasette_mcp-0.3-py3-none-any.whl

Total release size: 34.1 kB

Release files / datasette_mcp-0.3.tar.gz

Download URL datasette_mcp-0.3.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
87d62476d0408d0064ff073cd0de9e28f4b17e9f5eb9cd3f221d19a80861b0a5
BLAKE2b-256 checksum
How to use checksums
d564a4fbe63b8ae1949f7daa659609e2a40ba7ef0263baeb17abb2a7b8d4ea2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / datasette_mcp-0.3-py3-none-any.whl

Download URL datasette_mcp-0.3-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b66f5dd82edcb411449ed46451cd6b5d56d1fcce49c59c10ed0f1448986d987
BLAKE2b-256 checksum
How to use checksums
33bb6ec19e2871b1971b5fb18660f470412f21a1a9bbec6cc441379f39828bbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for datasette-mcp 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for datasette_mcp-0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page