Mode Analytics MCP Server
An MCP server that lets you browse reports, manage queries, and fetch results from Mode Analytics from any MCP-compatible AI assistant or agent.
Tools
| Tool | Description |
|---|---|
list_data_sources |
List all database connections in the workspace |
list_spaces |
List all spaces (collections) |
list_reports |
List reports in a given space (archived ones hidden unless include_archived=true) |
search_reports |
Search for reports by name or description across all spaces (client-side; archived ones hidden unless include_archived=true) |
get_report |
Get report details including its SQL queries, who wrote each one, and the report's registered form parameters. include_charts=true adds each query's charts |
list_report_runs |
List recent runs for a report (state, timestamps) |
get_run_results |
Fetch results from a specific or latest report run. Failed queries return their warehouse error and query_token; pass include_failed=true to read the latest run even if it failed. columns returns only the named columns |
run_report |
Run a report and return per-query results or errors. Runs every query in the report (warehouse cost). Reports applied_parameters and warns when parameters were probably ignored. Preview first, then confirm. Off unless MODE_ENABLE_RUNS=true |
list_charts |
List the charts in a report (or on one query): token, type, title |
get_chart |
Get one chart's type, title and what it plots; include_vegas=true adds the raw settings |
create_chart |
Add a line, bar, area, pie, table or big-number chart to a query. Undocumented endpoint |
update_chart |
Change a chart's type, columns, title or raw settings, keeping the rest of its formatting. Undocumented endpoint |
create_report |
Create a new report in a space, optionally with initial queries |
update_report |
Update a report's name, description, or move it to a different space |
archive_report |
Archive (hide) a report — reversible |
unarchive_report |
Restore an archived report |
delete_report |
Permanently delete a report (preview first, then confirm). Off unless MODE_ENABLE_DELETES=true |
add_query |
Add a SQL query to an existing report |
update_query |
Update a query's SQL, name, or data source |
delete_query |
Permanently delete a query (preview first, then confirm). Off unless MODE_ENABLE_DELETES=true |
Setup
1. Get Mode API credentials
Use a Member API key (recommended). Create your own under Workspace Settings > Personal > My API Keys and save the token and secret. Member keys respect your own Mode permissions, so the agent can only see and change what you can. If you can't create one, a Workspace admin needs to enable them under Workspace Settings > Features > API Keys > Member keys.
Mode also offers Workspace API tokens, created by admins under Workspace Settings > Privacy & Security > API. These act with admin access to the whole Workspace, so only use one if you need that — see Limitations / Safety below. (Older personal API tokens can no longer be created, but existing ones keep working.)
Both kinds of key expire after 90 days by default. When yours expires, the server reports "Authentication failed"; create a new key and update your MCP config.
2. Install uv
The server is launched with uvx, which comes with uv. Install it with brew install uv or curl -LsSf https://astral.sh/uv/install.sh | sh.
3. Add the server to your MCP client
The server runs over stdio via uvx mode-mcp. Add it to your MCP client's config; most clients use this mcpServers shape:
{
"mcpServers": {
"mode-analytics": {
"command": "uvx",
"args": ["mode-mcp"],
"env": {
"MODE_WORKSPACE": "your-workspace-name",
"MODE_API_TOKEN": "${MODE_API_TOKEN}",
"MODE_API_SECRET": "${MODE_API_SECRET}"
}
}
}
}
uvx installs the package from PyPI on first run and reuses that version afterwards. To pick up new releases automatically, use "args": ["mode-mcp@latest"] instead.
The ${MODE_API_TOKEN} / ${MODE_API_SECRET} references are expanded from your shell environment by clients that support it, so no secrets land in the config file. Set them wherever you keep shell secrets, e.g. in ~/.zshrc:
export MODE_API_TOKEN="..."
export MODE_API_SECRET="..."
Env var syntax differs by client
Some clients expand ${VAR}, some use another syntax (e.g. ${env:VAR}), and some don't expand references at all; check your client's docs. If a reference isn't expanded, the server stops at startup with an error naming the variable, rather than failing later with a confusing authentication error.
Environment Variables
| Variable | Required | Description |
|---|---|---|
MODE_WORKSPACE |
Yes | Your Workspace's username, as in app.mode.com/<workspace>/... |
MODE_API_TOKEN |
Yes | API token (from a Member API key, ideally) |
MODE_API_SECRET |
Yes | API secret |
MODE_ENABLE_DELETES |
No | Set to true to enable delete_report and delete_query. Off by default |
MODE_ENABLE_RUNS |
No | Set to true to enable run_report. Off by default |
MODE_READ_ONLY |
No | Set to true to disable every tool that writes to Mode (overrides MODE_ENABLE_DELETES and MODE_ENABLE_RUNS) |
MODE_DISABLED_TOOLS |
No | Comma-separated tool names to disable, e.g. create_report,update_query |
Choosing which tools are available
Disabled tools are never registered, so the agent doesn't see them at all.
- Default: everything except the two delete tools and
run_report. The agent can browse, author, chart, and archive, but can't permanently delete anything or run reports. - Allow deletes: add
"MODE_ENABLE_DELETES": "true"toenv. - Allow runs: add
"MODE_ENABLE_RUNS": "true"toenv. - Read-only: add
"MODE_READ_ONLY": "true"to only allow browsing and fetching results. This also disablesrun_report, even withMODE_ENABLE_RUNS=true. - Anything else: list tool names in
MODE_DISABLED_TOOLS.
A misspelled tool name in MODE_DISABLED_TOOLS stops the server with an error rather than silently leaving the tool enabled.
Limitations / Safety
Running reports. The Mode API has no endpoint for running a single query. run_report calls POST /reports/{token}/runs, which runs every query in the report at once, spends warehouse compute, and adds to the report's run history. It is off unless you set MODE_ENABLE_RUNS=true.
- Every run takes two calls. The first runs nothing and returns a preview (the queries that will run, the last run's duration, the parameters) and a
confirm_code. The second call, with that code, starts the run. The code changes if a query is added, removed, edited or moved to another data source, or if the parameters change. - Keep reports small (or split them) while an agent iterates on SQL.
- Rows are truncated to 50 per query by default, since the usual goal is checking that the SQL works. A failed query returns its warehouse error and
query_token, which maps straight toupdate_query. - Parameters only take effect when the report has registered form fields: a
{% form %}block in a query's SQL, saved in Mode. Queries created through the API aren't registered until someone saves them in the editor, and Mode then runs with the form defaults.get_reportlists the registeredparameters, andrun_reportwarns when it sent parameters to a report with none. columnskeeps wide results (emails, impersonation links) out of the transcript.- If a run outlasts
timeout_seconds, the result hastimed_out: true; fetch it later withget_run_results.
Charts use undocumented endpoints. Mode's public Charts API is read-only (list_charts, get_chart). create_chart and update_chart call the same endpoints Mode's own editor does (create a chart on a query, then patch its view_vegas), with your normal API token. They can break without notice; turn them off with MODE_DISABLED_TOOLS=create_chart,update_chart (or MODE_READ_ONLY=true).
- Columns are checked against the query's latest succeeded run (run the report first), ignoring case. Each y column is plotted as
SUM(column). update_chartonly changes what you pass and keeps the chart's colors and formats. If you change the type or columns of a chart built in Mode's editor, and it has a shape the server can't read back, it asks for the full set of fields or for the change throughview.- This server can't render charts, so check what it makes. Smoke test after upgrading Mode-facing code, on a scratch report with one succeeded run:
create_charta bar chart, then open itsweb_pathunderapp.mode.comand confirm it renders with the right axes.update_chartwith a newtitleand confirm the title changed and the colors didn't.update_chartwithtype="line"and confirm the chart is rebuilt as a line.get_chartwithinclude_vegas=trueand checkview_vegasis still version 2.- Delete the chart in Mode's UI. There is no delete-chart tool.
Deletes are permission-scoped, not owner-scoped. The server does not check who created a report or query; what you can delete is whatever your API token is allowed to delete in Mode. With a Member API key that's limited to your own permissions, but a Workspace API token has admin access and can delete any report or query in the Workspace. That's why the delete tools are off unless you set MODE_ENABLE_DELETES=true.
Deletes can't skip the preview. When enabled, delete_report and delete_query are always two calls:
- The first call deletes nothing. It returns a preview (the report's name, whether it's already archived, and its queries with who wrote each one; or a query's name, author, and SQL) plus a short
confirm_code. Mode's API doesn't say who created a report, only who wrote each query. - The delete only happens when the same tool is called again with that
confirm_code. The code is a fingerprint of what the preview showed, so it can't be guessed, and if the report or query changed after the preview (renamed, SQL edited, queries added), the code no longer matches and the delete is refused.
Archive instead of delete. archive_report hides a report and unarchive_report brings it back. The delete tool tells the agent to suggest archiving first.
Credentials never touch the committed config. The ${MODE_API_TOKEN} / ${MODE_API_SECRET} references in your MCP config are expanded from your shell environment at launch (in clients that support it), so the file is safe to commit. Keep the raw secrets in env vars and don't commit them.
Development
git clone https://github.com/nataliemona/mode_mcp.git
cd mode_mcp
uv sync --dev
uv run pytest
Metadata
Release files for mode-mcp 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mode_mcp-0.2.0.tar.gz | 33.6 kB | Without provenance | Details for mode_mcp-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mode_mcp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for mode_mcp-0.2.0-py3-none-any.whl |
Total release size: 57.5 kB
Release files / mode_mcp-0.2.0.tar.gz
| Download URL | mode_mcp-0.2.0.tar.gz |
|---|---|
| Size | 33.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
247bed6959cc5102f1661d91f03dfb8549bfe19afa53b3d610bf41deee4c3366
|
|
BLAKE2b-256 checksum How to use checksums |
72d79d5b2bda733f463f5b0cfd9a6c2c7764f48600636dddd8aabe41237d756e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mode_mcp-0.2.0-py3-none-any.whl
| Download URL | mode_mcp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
388edba17e2b21446889004035ef84f806fa1165ae36a6e3613f5d484e753abc
|
|
BLAKE2b-256 checksum How to use checksums |
3d00b2b76ea94c5d262d44df655999cff9346d236d87b0bcb386b573f2259e84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for mode-mcp 0.2.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.