docs-mintlify/docs/integrations/mcp-server.mdx
Cube MCP (Model Context Protocol) lets MCP-compatible AI clients connect to Cube over HTTPS using OAuth.
<Note>The MCP server is available on Premium and Enterprise plans. Users need the Viewer role or higher to interact with the MCP server. Which tools a user sees depends on their role — see Available actions.
</Note>Model Context Protocol (MCP) is an open standard that enables AI assistants to securely connect to external data sources and tools. The Cube MCP server acts as a bridge between your AI assistant and Cube's analytics platform, allowing you to ask data questions directly from your coding environment.
Cube hosts an MCP server endpoint. MCP clients connect over HTTPS and authenticate via OAuth.
https://cubecloud.dev/mcpclient_id = cube-mcp-client, scope = mcp-agent-access. Clients discover it automatically from the endpoint — there is nothing to configure by hand.https://cubecloud.dev/mcp is the same URL for every account, deployment and region. Cube
identifies your account from the OAuth token and routes each request to whichever
deployment serves it, so there is no per-tenant host to look up before you can connect.
If Cube runs in your own cloud account or on your own domain, use that console domain
instead — https://<your-console-domain>/mcp.
Each deployment also keeps a region-specific endpoint, shown under Admin → MCP Server. Both work. Prefer the single endpoint above unless you need a client to reach a deployment's region directly without passing through the control plane.
Before enabling MCP, make sure you have:
Go to Admin → MCP Server. The page shows the endpoint to hand to clients along with ready-made setup snippets for each supported client. If it reads “MCP configuration is unavailable,” the MCP server host isn’t configured for the account yet.
Go to Admin → MCP Server and use the Deployment Access section to control which deployments MCP clients can reach and where they connect by default:
Deployment access is always intersected with the user's role-based permissions — clients can only reach deployments the authenticated user is allowed to see.
</Note> <Frame> </Frame>claude mcp add --transport http cube-mcp-server https://cubecloud.dev/mcp
/mcp to list available servers.cube-mcp-server and choose Authenticate.https://cubecloud.dev/mcp{
"mcpServers": {
"cube-mcp-server": {
"command": "npx",
"args": ["-y", "mcp-remote", "--transport", "http", "https://cubecloud.dev/mcp"]
}
}
}
Add the MCP endpoint under Tools & MCP Settings, then complete the OAuth flow.
{
"mcpServers": {
"cube-mcp-server": {
"command": "npx",
"args": ["-y", "mcp-remote", "--transport", "http", "https://cubecloud.dev/mcp"]
}
}
}
Preferred (CLI):
codex mcp add cube-mcp-server --url https://cubecloud.dev/mcp
If this is your first time using MCP in Codex, enable the feature in ~/.codex/config.toml:
[features]
rmcp_client = true
Manual setup:
[features]
rmcp_client = true
[mcp_servers."cube-mcp-server"]
url = "https://cubecloud.dev/mcp"
Then run codex mcp login cube-mcp-server to authenticate.
For any MCP-compatible client:
An MCP client is not locked to a single deployment for the whole session. After connecting, it can discover the deployments and agents you can access and target a specific one on each request.
Three tools work together:
listDeployments — discovery. Returns every deployment you can access via MCP
(already filtered by the admin's deployment-access settings and your permissions) and
each deployment's agents. Use it to find valid deploymentId and agentId values
before calling chat. Every deployment offers an Auto agent (agentId: null) in
addition to any configured agents.chat — accepts two optional selection parameters:
deploymentId — the deployment to use for this request. When omitted, the chat
uses the deployment from the current session (the default resolved at connect time).agentId — the agent to use for this request. When omitted or null, the
deployment's Auto agent is used. Pass a specific agentId to route to a
configured agent.loadQueryResults — paginates through the results of a previous query on the same
deployment context.A typical client workflow:
<Steps> <Step title="Connect"> Complete the OAuth flow. The session is scoped to the tenant default deployment (or the first one you can access). </Step> <Step title="Discover"> Call `listDeployments` to see the available `deploymentId` / `agentId` values. </Step> <Step title="Chat"> Call `chat` with your `input`, optionally passing `deploymentId` and/or `agentId` to target a specific deployment or agent. Omit both to use the session default deployment with its Auto agent. </Step> </Steps>Requests are always validated against the admin's deployment-access settings. A deployment
that is outside the allow-list — or that you don't have permission to see — is rejected
with a 403 Forbidden (Deployment <id> is not available via MCP for this account), so
neither listDeployments nor the chat selection can reach an excluded deployment.
The MCP server exposes 20 tools, grouped below.
Every tool runs as the authenticated user. Queries respect the same permissions as the rest of Cube, including row-level security — MCP is a new way to reach your data, not a new access surface.
Each tool is annotated as read-only or destructive. MCP clients that honor these
annotations — including Claude — run read-only tools automatically and always ask for
confirmation before any of the four destructive ones: updateDashboard,
publishDashboard, writeDataModelFile, and deleteDataModelFile. Nothing that changes
a dashboard or your data model happens without an explicit approval.
| Tool | Description |
|---|---|
listDeployments | Lists the deployments and agents you can reach over MCP. |
chat | Asks a question of a Cube agent, optionally targeting a specific deployment and agent. |
loadQueryResults | Paginates through the results of a previous query. |
See Select a deployment and agent for how these three work together.
| Tool | Description | Access |
|---|---|---|
searchDataModel | Searches the semantic model by similarity — views and their measures and dimensions — to discover what is queryable. Returns compact records (name, title, description, type) to reference in runQuery. | Read-only |
runQuery | Runs a Cube SQL query (PostgreSQL dialect) against the SQL API. Returns a schema, a page of rows, and hasMore / totalRows for pagination via offset. | Read-only |
Call searchDataModel before runQuery to find exact view and member names rather than
guessing them.
These tools build workbooks and dashboards programmatically. Creating and editing workbooks requires the Explorer role or higher.
| Tool | Description | Access |
|---|---|---|
readWorkbook | Reads a workbook — its name and its current dashboard draft and published configs. | Read-only |
createWorkbook | Creates a new empty workbook, the container that holds reports and a dashboard. | Write |
createReport | Saves a query plus its visualization as a report inside a workbook, and returns the reportId a chart widget references. | Write |
updateDashboard | Saves the dashboard layout to the workbook draft. Replaces the full widget set and does not go live. | Destructive — prompts |
publishDashboard | Publishes the current draft to make it live. Idempotent — republishing an unchanged draft is a no-op. | Destructive — prompts |
Drafts are the safety net here: updateDashboard only ever writes to the draft, so a
published dashboard keeps serving its previous version until you approve
publishDashboard. See Build a dashboard for the full sequence.
These tools read and edit the semantic model source files. They are registered only for users whose role grants permission to edit the semantic model — Admin and Developer by default. Users without it never see them.
| Tool | Description | Access |
|---|---|---|
listDataModelFiles | Lists the semantic model source files (raw YAML, JavaScript, or Python). | Read-only |
readDataModelFile | Reads one file's raw source. | Read-only |
startDataModelEdit | Enters development mode, starts a dev worker, and returns the dev branchName that every write tool requires. | Write |
writeDataModelFile | Creates or overwrites a model source file on the dev branch (whole-file replacement). Recompiles the model and reports valid plus any validationError. | Destructive — prompts |
deleteDataModelFile | Deletes a model source file on the dev branch. | Destructive — prompts |
getDataModelChanges | Shows the diff of the dev branch against its parent — the pending changes, for review before committing. | Read-only |
getBranchDiff | Shows what any branch changed against the deploy branch: the changed-file list with per-file line counts, plus the unified diff. | Read-only |
getDeploymentEnv | Lists the deployment's environment variables, with every secret-looking value redacted to [ENCRYPTED]. Useful for confirming configuration is present and shaped as expected. | Read-only |
getDataModelChanges answers "what have I changed?" for your own dev branch against its
immediate parent. getBranchDiff answers "what did this branch change?" for any branch,
including feature branches — reach for it when a change edits existing cubes, where the
file list looks identical on both branches and listDataModelFiles reveals nothing.
getDeploymentEnv never returns secret values. Anything that looks like a credential is
replaced with [ENCRYPTED] before it leaves Cube, so an AI client can verify that a
variable is set without ever seeing what it is set to.
Letting an AI client edit your semantic model is safe because of four constraints built into the MCP server:
dev-<user>-<hash>. The write tools reject any branch that isn't a dev branch, so
the deploy branch is never writable over MCP.startDataModelEdit is the only entry point. It returns the dev branchName, and
writeDataModelFile and deleteDataModelFile require it. There is no way to write
without going through it first.getBranchDiff, getDeploymentEnv, and both pre-aggregation
tools — is offered only to users whose role allows editing the semantic model. A Viewer
never sees them at all.Review pending work with getDataModelChanges before you commit.
These tools inspect and trigger pre-aggregation builds. They are registered under the same semantic-model permission as the data model tools above.
| Tool | Description | Access |
|---|---|---|
getPreAggregationStatus | Lists the data model's pre-aggregations with their definitions and, for each, how many partitions exist, how many were built, when the newest build landed, and the exact error if a build failed. | Read-only |
buildPreAggregation | Queues an on-demand build of one pre-aggregation and returns once it is accepted. The build runs asynchronously. | Write |
Together these close the loop on pre-aggregation work: a query alone cannot prove a rollup
was used, and external pre-aggregations fail in configuration-specific ways — a missing
export bucket, denied bucket permissions — that only an actual build surfaces. Call
buildPreAggregation, then poll getPreAggregationStatus to see whether the partitions
built or to read the failure.
buildPreAggregation runs real queries against your data warehouse and, for external
pre-aggregations, writes through the export bucket. It consumes warehouse resources, so
expect a cost per build.
Ask a question in natural language and let the agent do the planning: chat returns the
answer along with the SQL it generated, and loadQueryResults pages through large result
sets. Use this for summaries, trends, and ad-hoc analysis.
To drive the query yourself instead, call searchDataModel to find the right view and
members, then run your own SQL with runQuery.
The five dashboard tools are designed to be used in order.
<Steps> <Step title="Create the workbook"> Call `createWorkbook` with a name. It returns the `workbookId` every later step needs. If you were given an existing workbook to build into, call `readWorkbook` instead and skip to the next step. </Step> <Step title="Create a report per chart"> Call `createReport` once per chart, KPI tile, or table, passing the `workbookId` and the SQL query that powers it. Each call returns a `reportId`. </Step> <Step title="Lay out the dashboard"> Call `updateDashboard` with the complete widget set, referencing each `reportId` from the previous step. This replaces the draft layout and saves to the workbook draft — the live dashboard is unchanged. Your client will ask you to confirm. </Step> <Step title="Publish"> Review the draft, then call `publishDashboard` to make it live. This also prompts for confirmation. It returns the dashboard URL. </Step> </Steps>To change a dashboard later, call readWorkbook first and edit on top of the current
draft rather than overwriting it.
Call startDataModelEdit to enter development mode and get a dev branchName. Explore
the current source with listDataModelFiles and readDataModelFile, then apply changes
with writeDataModelFile or deleteDataModelFile, passing that branchName. Each write
recompiles the model and reports validation errors, so you can iterate until it compiles.
Review the result with getDataModelChanges, then commit the branch from the Cube UI to
publish it.
To review a branch you didn't author — a colleague's feature branch, say — call
getBranchDiff with its name instead. It compares against the deploy branch and returns
the full changed-file list even when the patch itself is trimmed.
After adding or changing a pre-aggregation, call getPreAggregationStatus to see whether
its partitions exist and when they were last built. If nothing has been built yet — or you
want to confirm an external pre-aggregation's export bucket actually works — call
buildPreAggregation, then poll getPreAggregationStatus again. A failed build reports
the exact error, which is usually a configuration problem rather than a modeling one;
getDeploymentEnv will tell you whether the expected variables (CUBEJS_DB_EXPORT_BUCKET
and friends) are set.
Deployment <id> is not available via MCP for this account (403): The requested deployment is excluded by the deployment-access allow-list or by the user's permissions. Call listDeployments to see which deployments are reachable, or adjust the allow-list in Admin → MCP Server → Deployment Access.