Skip to main content

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

Project description

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, rows, 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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette_mcp-0.1a0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasette_mcp-0.1a0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file datasette_mcp-0.1a0.tar.gz.

File metadata

  • Download URL: datasette_mcp-0.1a0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for datasette_mcp-0.1a0.tar.gz
Algorithm Hash digest
SHA256 17c776f698dfd4096cf94ddfa735b0d6fa1217869d1df0bd29cecc7629c3b891
MD5 9487cc8c4819d96a5141a214e0b64340
BLAKE2b-256 cd1659642bb6739161f4e4baf81ade662e30e1fcc870b108faedd5719a6116fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_mcp-0.1a0.tar.gz:

Publisher: publish.yml on datasette/datasette-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file datasette_mcp-0.1a0-py3-none-any.whl.

File metadata

  • Download URL: datasette_mcp-0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for datasette_mcp-0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 8568e82ed49f181c0fd76aca21df313a059f9d45ff5fe02284beca982d387694
MD5 84c47c43f20ce5ad40fa75599ca2e3f0
BLAKE2b-256 bd95534e659e0c168a50645ef8bca2dd752388bed1d393d34e4b82273b09f127

See more details on using hashes here.

Provenance

The following attestation bundles were made for datasette_mcp-0.1a0-py3-none-any.whl:

Publisher: publish.yml on datasette/datasette-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page