Skip to Content

MCP Server

Use MCP for common tasks

What to ask your AI app to answer questions, embed a dashboard, edit a client dashboard and change the semantic model.

Ask in plain words. The AI app picks the tools. Each section shows what to ask and what happens.

Ask a question about your data

What was total revenue last month, by region?

The app calls ask_question. It turns the question into SQL, runs it, and returns the rows with a chart. On the hosted connector, apps that show MCP Apps draw the chart in the chat. Ask a follow-up, such as Only the top 5 regions.

To keep the answer, ask Save this as a dashboard. The app calls save_chart_as_dashboard, which makes a workspace metric and a new dashboard. It asks you for APPLY_TO_PRODUCTION first.

To show a metric that already exists, ask Show the Revenue metric from the Sales dashboard. The app calls render_metric_tile.

Embed a dashboard in your app

Embed my Sales dashboard in my Next.js app.

The app follows the embed-existing-dashboard prompt:

  1. Finds your data apps with list_data_apps, or creates one.
  2. Makes sure the data app has an API token.
  3. Lists the dashboards and creates the embed with create_embed.
  4. Generates a guest token on the server with generate_guest_token.
  5. Writes the frontend code with generate_embed_code.

Keep the API token on your server. Only the guest token goes to the browser.

The data app and its API token show in Data Studio > Data Apps, and the embed in the data app’s Embeds tab. Your app then shows the dashboard, as in Embed in React.

Partner portal data app, workspace Sales analytics, API tokens tab with one active token named Partner portal backend.
A data app and API token made by the AI app, in Data Studio > Data Apps.

Change one client’s dashboard

Add the Calls per day widget from the standard template to the dashboard of client acme-co.

The app calls list_tenants to check the client ID, then list_widgets and add_widget. Only that client’s dashboard changes. To check what the client sees, ask for a demo link (get_demo_link).

This workflow creates client end-user dashboards, even when it uses a template. Embedded end users can use existing Custom SQL metrics and filters, but cannot edit Custom SQL metrics or submit filter definitions containing Custom SQL. See the Dashboard Embed API for the restriction. To import a dashboard into your own workspace, use the separate Import Dashboard API.

Turn tested SQL into a metric

Make this SQL a metric on the Operations dashboard. Dry run first.

For a client dashboard the app uses create_or_update_metric_from_query. For an internal workspace metric with no client, it uses create_workspace_metric. Both:

  1. Check the SQL against the datasource.
  2. Return a dry run: whether the SQL is valid and its output columns. Nothing is saved yet.
  3. Save only after you type APPLY_TO_PRODUCTION.

A workspace metric is saved unpublished and is not on a dashboard yet. You find it in the workspace’s Metrics tab. Add it to a dashboard from there.

Metrics tab of the Subscription analytics workspace with one row: Revenue by plan, metric ID revenue-by-plan, marked Unpublished, created by Internal, edited seconds ago.
The saved workspace metric in the workspace's Metrics tab.

If the SQL is wrong, the error names the table or column and its line. See SQL errors.

Change the semantic model

Add a description to orders.amount: "Order total in USD".
  1. The app reads the model with search_semantic_model and get_semantic_entity.
  2. It checks the change with propose_semantic_change. You get the validation result, the new YAML and the content hash. Nothing is saved yet.
  3. It can test questions with eval_semantic_model.
  4. It applies the change with apply_semantic_change, after you type APPLY_TO_PRODUCTION.

The change goes live at once and applies to everyone who uses the model. In Databrain, the model shows Published and the change is in its YAML.

Semantic model Subscription metrics, marked Published 1m ago, Code view of subscription_orders.yaml with the new line description: Order total in USD under the amount column highlighted.
The applied change in the model's Code view.

The change applies to everyone who uses the model. If someone changed the model in the meantime, the apply stops with a conflict. Ask the app to propose the change again.

On the hosted connector you can also work in a saved draft with semantic_model_draft, and ask Bryn with ask_bryn_semantic_model. Publishing the model stays a step you do in Databrain.

Brand an embed

Make my embed match our brand: primary color #4F46E5, Inter font, dark mode.

The app calls customize_embed_theme. Guest tokens made before the change keep the old look until you make a new one or reload your app.

Next, look up any tool in the tools reference.