duckdb-spatial-docsbox-mcp read-only

An MCP (Model Context Protocol) server that lets an LLM agent safely explore and query a DuckDB database with the spatial extension. File-mode databases are opened with read_only=True; all SQL is statically validated before execution and bounded by a per-statement wall-clock timeout (enforced via connection.interrupt()).

Endpoints

Tools

ToolPurpose
list_tablesUser tables/views with row count & geometry flag.
get_table_schemaDDL + sample rows + indexes for one table.
get_column_valuesDistinct sample values for one column.
list_sridsSRIDs in active use (DuckDB stores all geometry as SRID 0).
get_relationshipsForeign-key edges.
list_extensionsLoaded/installed DuckDB extensions (spatial, parquet, ...).
pick_interesting_tablesScore by rows + geometry + R-Tree + FK hubness.
validate_sqlStatic SQL safety check (no DB needed).
explain_sqlEXPLAIN [ANALYZE] text plan.
execute_sqlRead-only SELECT/WITH/EXPLAIN with row caps.
list_gdal_driversInstalled GDAL drivers exposed via ST_Drivers().
probe_external_filePeek schema/sample of a CSV / Parquet / GeoJSON / SHP / GPKG file.
duckdb_helpCurated DuckDB+spatial recipe reference.
list_sections / get_documentationDoc manifest browser.
run_locallyPlan-only execution recipes (duckdb CLI, EXPORT DATABASE, ST_Read, ...).

Configure

export DUCKDB_DOCSBOX_PATH=/path/to/file.duckdb   # or :memory:
duckdb-spatial-docsbox-mcp

opencode / Claude Code

{
  "mcpServers": {
    "duckdb-spatial-docsbox": {
      "type": "http",
      "url": "http://127.0.0.1:7821/mcp"
    }
  }
}