Files
baserow/docs/development/mcp-server.md
T
alamin-br 4654019e22 feat(mcp): add search, row comment, view config and audit log tools (#6593)
* refactor(mcp): share the tool error messages

The row comment, row colour and audit log tools need licence errors to reach the client, and the item error helper outside automation.

* fix(assistant): show shared tool errors to Kuma

A licence or input error from a shared tool ended the chat run instead of reaching the model.

* feat(mcp): search the workspace

Lets MCP clients and Kuma find a table or row by name without walking every database.

* feat(mcp): read and post row comments

Lets MCP clients and Kuma read what people said about a row and add to it, in plain text.

* feat(mcp): change view sorts, field visibility and row colours

Lets MCP clients and Kuma configure views, and delete views and filters. list_views now returns the ids those tools take.

* feat(mcp): read the workspace audit log

Lets MCP clients and Kuma answer who did what in a workspace. It stays off until a user turns it on, even though it only reads.

* fix(mcp): run the field visibility change in a transaction

Over MCP and Kuma it failed on select_for_update, as they call tools outside a transaction.

* fix(mcp): only take row colours a row can show

A row takes its colour from a CSS class per palette name, so a hex value reported success and coloured nothing.

* fix(mcp): undo a row colour that fails halfway

The tool adds to a view's colours, so a client retrying after an error would end up with a second colour.

* fix(mcp): show how a view's filters combine

A view matching any filter, or one with filter groups, read as one matching all of them.

* fix(mcp): mark set_view_sorts as overwriting

It replaces a view's sorts and an empty list removes them, so clients should confirm it.

* fix(mcp): read comments with a mention without a label

The API accepts such a mention, and one of them made every comment of the row unreadable.

* fix(mcp): refuse a blank workspace search

The API trims the query too, and a space would match most names.

* docs(mcp): say why reordered sorts are recreated

* test(mcp): expect how filters combine in the listed views

* fix(mcp): handle bad input to the audit log tools

A reversed range and a blank query read as nothing having happened, and an unknown browser timezone ended Kuma's run.

* fix(mcp): read comments with no content

The API accepts such a comment, and one of them made every comment on the page unreadable.

* fix(mcp): show when a view's filters are switched off

Those filters hide no rows, so listing them as active misled the client.

* docs(mcp): correct what the view tools say they do

Row colours work on every view with rows, and Kuma was told to skip list_views when it needs the filters and colours.

* fix(mcp): leave IP addresses out of the audit log tools

Who did what doesn't need them, and Kuma sends tool results to the LLM provider.

* fix(mcp): keep what a restricted view hides out of the view tools

A member below builder could read a restricted view's filters, hidden sorts and colours from list_views, and a field's name from an error before permissions were checked.

* fix(mcp): replace a view's sorts one call at a time

Two calls could each read the old sorts and add to them, leaving a list neither asked for.

* fix(mcp): read a mention whose label isn't a string

The API accepts such a label, and one comment holding it stopped the row's comments from being listed.

* fix(mcp): limit the row comments of a call to 100

Each comment runs about nine queries in its own transaction, and a commenter could ask for any number.

* fix(mcp): show Kuma that set_field_visibility needs a field

Both clients now reject an empty list from the schema, so the checks after it can't run.

* docs(mcp): correct the audit log tools' licence and fields

An advanced licence also has the audit log, and entries no longer hold an IP address.

* refactor(mcp): rename set_row_colours to add_row_colours

It adds to the colours a view has, while set_view_sorts replaces the sorts.

* fix(mcp): stop set_view_sorts deadlocking with a new sort

A new sort checks its view when it commits, which the view lock blocked while
the sort rows it needed were held. Sort writers now share a weaker view lock.

* fix(mcp): title add_row_colours Add row colours

* refactor(mcp): merge search_audit_log into list_audit_log

The two differed only by a text query and a 90 day cap. Timestamps now need an
offset, as nothing tells MCP the user's timezone.

* feat(mcp): let a date filter carry its timezone

MCP has no timezone for the user, so relative date modes would follow UTC. An
offset can't express those, so the caller names the IANA timezone.
2026-11-04 14:05:50 +01:00

14 KiB

MCP Server

Baserow ships a built-in Model Context Protocol (MCP) server that exposes database operations as tools so that AI assistants can read and write Baserow tables directly.

Architecture

LLM / MCP client
      │ POST /mcp (Streamable HTTP, bearer token)   GET /mcp/{key}/sse (legacy SSE)
      ▼
Starlette app, ASGI only           ← backend/src/baserow/core/mcp/__init__.py
      │
BaserowMCPServer                   ← backend/src/baserow/core/mcp/__init__.py
      │
MCPToolRegistry                    ← backend/src/baserow/core/mcp/registries.py
      │
services.py                        ← backend/src/baserow/contrib/database/mcp/services.py
      │
ActionTypes → Django ORM
  • MCPTool (registries.py) — Base class for all tools. Subclasses define a type, a Pydantic input_schema, and implement _sync_call(). Tools with enabled = False are registered but hidden from MCP clients.
  • Services layer (services.py) — Workspace-scoped database operations. Shared by both MCP tools and the enterprise AI assistant.
  • Shared tools (baserow/core/tools/, baserow/contrib/database/tools/) — Tool functions that MCP, Kuma and the Agent Builder all call. A shared tool takes a ToolContext (user, workspace, status callback) plus arguments annotated with Annotated[..., Field(description=...)], and knows nothing about the client. FunctionMCPTool builds its MCP input schema from the signature and its description from the docstring; MCP-only metadata (title, group, read-only) is set where it is registered, for example contrib/database/mcp/views/tools.py. Kuma wraps the same function in its own tool, which adds Kuma's argument (thought) and guidance.
  • Action types — All mutations go through Baserow's action-type layer, so operations are undoable and audit-logged.
  • Workspace isolation — Every service function enforces workspace-scoped access. Tools cannot touch data outside the endpoint's workspace.
  • SSE transport (backend/src/baserow/core/mcp/sse.py) — DjangoChannelsSseServerTransport serves the legacy GET /mcp/{key}/sse stream and POST /mcp/messages/.
  • OAuth (backend/src/baserow/core/mcp/oauth/) — Authorization server, client registration and token views for POST /mcp. The consent and connected-apps APIs used by the frontend are in backend/src/baserow/api/mcp/oauth_views.py.

Endpoint model

An MCPEndpoint links a user to one workspace and to the tools they allowed (allowed_tools, a list of tool names). Tools added later stay off until the user turns them on. Endpoints created before tool lists existed were given the original database tools in LEGACY_DEFAULT_TOOLS, and a null list still means that list. There are two kinds:

  • OAuth grants: created when a client signs in through the consent page (see OAuth sign-in). The client calls POST /mcp with an access token. They are listed, and can be disconnected, on the OAuth tab of My settings > MCP server.
  • Endpoint keys: a 32-character secret key, created under My settings > MCP server (on the Endpoint tab when OAuth is on). A new key gets every read-only tool plus the LEGACY_DEFAULT_TOOLS. Its tools can be changed with PATCH on the endpoint, like an OAuth connection's. Older clients use it in the SSE URL, GET /mcp/{key}/sse. POST /mcp also accepts it as Authorization: Bearer <key>.

Users install the client side, the MCP server config plus a skill, from baserow/baserow-mcp. Its README has the setup steps for each agent.

Running the server

The MCP server requires ASGI mode (Django Channels).

# Start dependencies
just dcd up -d db redis

# Run in dev or ASGI mode
cd backend
# dev mode
just run-dev-server
# or ASGI mode
just run-asgi

OAuth sign-in

MCP clients can sign in with OAuth instead of a pasted key. See ADR 009 for the design.

Set BASEROW_MCP_OAUTH_ENABLED=true to turn it on. It is off by default.

All clients share one URL, <PUBLIC_BACKEND_URL>/mcp. The user picks a workspace and the allowed tools on the consent screen.

Each grant is stored as an MCPEndpoint row with oauth_client_id set. Its tokens carry the scope mcp endpoint:<id>, which ties them to that row. Deleting the row revokes the tokens. Grants are also revoked when the user leaves the workspace. A password change or reset deletes the user's tokens but keeps the grants, so the apps have to sign in again.

Client registration

  • CIMD: the client URL is the client id. On by default; set BASEROW_MCP_OAUTH_CIMD_ENABLED=false to turn it off. BASEROW_MCP_OAUTH_CIMD_ALLOWED_HOSTS is a comma-separated host list and defaults to *. Its redirect URIs must also be https or loopback.
  • DCR: on by default. Set BASEROW_MCP_OAUTH_DCR_ENABLED=false to turn it off. It only accepts public clients that use the authorization code grant, with at most 10 https or loopback redirect URIs and a body of at most 16 KB. Other redirect URIs are dropped; the registration fails only when none is left.

A Celery task deletes clients that have no grant: DCR clients once they have not been used for 30 days (issuing or refreshing a token counts as use), CIMD clients one day after they were first fetched, since they are fetched again when needed. An app whose client was deleted gets a 400 asking the user to remove the Baserow server from the app and add it again.

Rate limits and tokens

The limits are per IP, as comma-separated lists. The consent API also applies the authorize limits per user, as it can fetch CIMD documents too. Only failed token calls count, since hosted apps refresh every user's token from a few IPs. Token revocation has its own limit with the token values, because it loads the client and so can fetch a CIMD document.

Variable Default
BASEROW_MCP_OAUTH_AUTHORIZE_RATE_LIMITS 30/m,300/h
BASEROW_MCP_OAUTH_REGISTRATION_RATE_LIMITS 10/m,60/h
BASEROW_MCP_OAUTH_TOKEN_RATE_LIMITS 30/m,300/h

Access tokens last one hour. Clients always get a refresh token, whether or not they ask for offline_access; refresh tokens rotate and expire after 30 days. Replaying a used refresh token revokes the whole family.

Running it locally

BASEROW_MCP_OAUTH_ENABLED=true just run-dev-server
claude mcp add --transport http baserow http://localhost:8000/mcp

ALLOW_LOCALHOST_LOOPBACK is already on in the settings, so clients can use http://localhost redirect URIs.

See the test plan for other clients, the plugin and the skill.

ChatGPT app domain verification

OpenAI verifies the domain of a submitted ChatGPT app by fetching /.well-known/openai-apps-challenge. Set BASEROW_MCP_OPENAI_APPS_CHALLENGE to the token shown in OpenAI's portal and the backend returns it as plain text. When it's empty the route returns a 404. Like the other OAuth routes, it only exists with BASEROW_MCP_OAUTH_ENABLED=true.

Tools

Some tools are currently disabled (enabled = False) and hidden from MCP clients. The consent page does not list them.

Tool Status Description
search_workspace enabled Search the workspace by name or content, optionally by type (shared with Kuma)
list_applications enabled List the workspace's databases, a page at a time (shared with Kuma)
list_databases enabled List all databases in the workspace (kept for existing connections, until 2.6)
list_tables enabled List tables, optionally filtered by database or table name (shared with Kuma)
get_table_schema enabled Get field definitions for one or more tables (shared with Kuma)
list_table_rows enabled List rows with optional search and pagination
create_rows enabled Create one or more rows using field names
update_rows enabled Update rows by ID using field names
delete_rows enabled Delete rows by ID
list_views enabled List the views of a table (shared with Kuma)
list_row_comments enabled List a row's comments as plain text. Needs premium (shared with Kuma)
create_row_comments enabled Post plain text comments on rows. Needs premium (shared with Kuma)
create_tables enabled Create tables with their fields (shared with Kuma)
create_fields enabled Add fields to a table (shared with Kuma)
update_fields enabled Rename fields or change their settings (shared with Kuma)
delete_fields enabled Delete (trash) fields (shared with Kuma)
create_views enabled Create views in a table (shared with Kuma)
create_view_filters enabled Add filters to views (shared with Kuma)
set_view_sorts enabled Replace the sorts of a view (shared with Kuma)
set_field_visibility enabled Hide or show fields in a view (shared with Kuma)
add_row_colours enabled Colour rows by a single select field or by conditions. Needs premium (shared with Kuma)
delete_views enabled Delete (trash) views (shared with Kuma)
delete_view_filters enabled Delete filters from views (shared with Kuma)
delete_row_colours enabled Remove row colours from views (shared with Kuma)
list_workflows enabled List the automations of the workspace and their workflows (shared with Kuma)
list_nodes enabled List a workflow's nodes in order, with their branches and output paths (shared with Kuma)
create_workflows enabled Create workflows with a trigger and nodes (shared with Kuma)
add_nodes enabled Add nodes to a workflow (shared with Kuma)
update_nodes enabled Change node labels, settings and router conditions (shared with Kuma)
delete_nodes enabled Delete (trash) workflow nodes (shared with Kuma)
list_audit_log enabled List who did what in this workspace, with an optional text search of at most 90 days. Needs advanced or enterprise and a workspace admin (shared with Kuma)
list_dashboards enabled List the dashboards of the workspace with their widget count
list_widgets enabled List a dashboard's widgets with the table, view, fields and aggregations they read
get_widget_data enabled Read the figures widgets show
create_dashboards enabled Create empty dashboards
create_widgets enabled Add summary, chart and pie chart widgets to a dashboard
update_widgets enabled Change a widget's title, chart type, or what it shows
delete_widgets enabled Delete (trash) widgets
update_table disabled Rename a table
delete_table disabled Delete (trash) a table

Typical LLM workflow

list_databases
  └─ list_tables(database_id)
       └─ get_table_schema([table_id])   ← learn field names and types
            ├─ create_rows(table_id, [{Name: "Alice"}])
            ├─ update_rows(table_id, [{id: 1, Name: "Bob"}])
            └─ delete_rows(table_id, [1, 2])

The automation tools are in their own groups (automation_read, automation_edit, automation_delete) and are not part of the "Read only" preset, so a user turns them on at consent or later under Settings. A value that takes a formula is stored as written when it is a valid formula and quoted when it is a literal. A formula is invalid when it doesn't parse, or reads a previous_node path the node doesn't output (the paths list_nodes shows). An invalid formula comes back in formula_errors for the client to fix with update_nodes: on a new node the value is left empty, on an update it keeps what it had. A formula can name a node created earlier in the same call by its ref, as in get('previous_node.trigger.0.id'). Over MCP no model is called; Kuma repairs those values with its formula generator after the nodes are committed.

The dashboard tools are in the dashboard_read, dashboard_edit and dashboard_delete groups. dashboard_read is part of the "Read only" preset, because it only returns figures the user can already see on the dashboard. A widget is a summary (one field aggregated over the rows), a chart or a pie_chart (one or more series, optionally grouped by a field). Charts need a premium licence; without one the widget fails with the licence message. Each widget is saved on its own, so one that fails is listed in errors and the others are kept. An aggregation that doesn't fit a field, like sum on a text field, comes back in errors with the aggregations that do. A widget filters its rows through a view (view_id); filters on the data source itself are not offered. New widgets go where the dashboard places them by default.

The audit log tools are in their own group (audit_log_read), registered by the enterprise app. They are off in the "Read only" preset and on new endpoint keys (off_by_default), so a user has to turn them on. They only read the audit log of the endpoint's workspace, not the instance-wide log.

Adding a new tool

  1. Create a class extending MCPTool in the appropriate mcp/*/tools.py file.
  2. Define a Pydantic model for the input and assign it to input_schema.
  3. Implement _sync_call(self, endpoint, args).
  4. Register it in backend/src/baserow/contrib/database/apps.py.
  5. Add tests in backend/tests/baserow/contrib/database/mcp/.

Set enabled = False on the class if the tool should not be exposed to MCP clients yet.

Testing

See docs/testing/mcp-test-plan.md for manual testing instructions.

# Server, transports and OAuth
just b test tests/baserow/core/mcp/

# Tools and services
just b test tests/baserow/contrib/database/mcp/

# Endpoint API
just b test tests/baserow/api/test_mcp_views.py

# OAuth audit log (enterprise)
just b test ../enterprise/backend/tests/baserow_enterprise_tests/audit_log/test_mcp_oauth_audit_log.py

# Service layer only
just b test tests/baserow/contrib/database/mcp/test_mcp_services.py