Adds a /-/mcp MCP server to any Datasette instance
Project description
datasette-mcp
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_databaseslists the databases available to the current Datasette actor.get_database_schemareturns the complete SQL schema for a database, including tables, indexes, views, and triggers.execute_sqlexecutes 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17c776f698dfd4096cf94ddfa735b0d6fa1217869d1df0bd29cecc7629c3b891
|
|
| MD5 |
9487cc8c4819d96a5141a214e0b64340
|
|
| BLAKE2b-256 |
cd1659642bb6739161f4e4baf81ade662e30e1fcc870b108faedd5719a6116fd
|
Provenance
The following attestation bundles were made for datasette_mcp-0.1a0.tar.gz:
Publisher:
publish.yml on datasette/datasette-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_mcp-0.1a0.tar.gz -
Subject digest:
17c776f698dfd4096cf94ddfa735b0d6fa1217869d1df0bd29cecc7629c3b891 - Sigstore transparency entry: 2275534531
- Sigstore integration time:
-
Permalink:
datasette/datasette-mcp@56ff825713e19c9b7a76a5664cd5b14bb10571f5 -
Branch / Tag:
refs/tags/0.1a0 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@56ff825713e19c9b7a76a5664cd5b14bb10571f5 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8568e82ed49f181c0fd76aca21df313a059f9d45ff5fe02284beca982d387694
|
|
| MD5 |
84c47c43f20ce5ad40fa75599ca2e3f0
|
|
| BLAKE2b-256 |
bd95534e659e0c168a50645ef8bca2dd752388bed1d393d34e4b82273b09f127
|
Provenance
The following attestation bundles were made for datasette_mcp-0.1a0-py3-none-any.whl:
Publisher:
publish.yml on datasette/datasette-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_mcp-0.1a0-py3-none-any.whl -
Subject digest:
8568e82ed49f181c0fd76aca21df313a059f9d45ff5fe02284beca982d387694 - Sigstore transparency entry: 2275534705
- Sigstore integration time:
-
Permalink:
datasette/datasette-mcp@56ff825713e19c9b7a76a5664cd5b14bb10571f5 -
Branch / Tag:
refs/tags/0.1a0 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@56ff825713e19c9b7a76a5664cd5b14bb10571f5 -
Trigger Event:
release
-
Statement type: