manage_dashboards
Share live dashboards in Supermetrics Studio — self-contained pages that re-query the user's data on each view, so a shared link always shows current numbers.
Before uploading, show a STATIC inline preview (data hard-coded, no smQuery), then confirm before uploading the LIVE smQuery version. smQuery and window.fetch work only inside Studio, so a preview using them renders empty in the chat — the inline preview must hard-code the data you already fetched, and the upload must fetch via smQuery (see the 'code' param), never the hard-coded preview. After building a dashboard, offer this upload; do not just show the preview and stop. Skip the confirmation only when the user EXPLICITLY asked to publish (e.g. "put this in Studio and give me a link").
Campaign actions (pause, budget change) go in only when the user asks: add the campaign tools to allowed_tools and only the managed accounts to allowed_accounts, confirm each change in the page, and warn that viewers act on the owner's connections, so share only with people who may make those changes.
BigQuery dashboards: before writing the code, fetch supermetrics_guide(mode="dashboard_bigquery") — the response shape and allowed_accounts key differ from Supermetrics sources.
Actions:
'upload': Upload a new dashboard or replace an existing one. Requires title, code, allowed_tools, allowed_accounts; description is optional. The code format (HTML or JSX) is detected automatically.
'edit': Apply targeted anchor-based patches to dashboard code. Call get_dashboards first to see the current code, then send patches.
Edit patch types (pick the smallest that fits):
region replace (PREFER for changing a section's logic/content): {"from": "// #region charts", "to": "// #endregion charts", "replace": "// #region charts\n\n// #endregion charts"} — replaces the WHOLE region from 'from' to 'to', anchor lines INCLUDED. Write the COMPLETE new block in 'replace' and reproduce the 'from' and 'to' marker lines inside it (normally unchanged) so they survive; omitting a marker deletes it. Restating an anchor does NOT duplicate it. 'from' must be unique; 'to' is the first match after it.
find/replace (small unique swap): {"find": "old text", "replace": "new text"}
after/insert (a NEW element): {"after": "anchor text", "insert": "new content"}
before/insert: {"before": "anchor text", "insert": "new content"} Modifiers (find/replace only): "nth": N (target Nth occurrence), "all": true (replace all). Patches are applied sequentially and atomically.
Patchable code: When uploading, wrap each section in PAIRED region markers so edits can target them, and declare each variable/function inside the region that uses it:
HTML: …
CSS: /* #region kpi-cards /…/ #endregion kpi-cards */
JS: // #region chart-init … // #endregion chart-init
Tag key elements with data-sm attributes: data-sm="kpi-spend", data-sm="filter-date" Each anchor must be unique in the code.
Best practices:
Add a loading indicator (spinner or skeleton) while data is being fetched.
When it makes sense, add selectors (dropdowns, date pickers, toggles) that let viewers change query parameters such as date range, account, or metric.
Date controls: offer a genuinely flexible date range, not just a few fixed presets. smQuery's date_range_type accepts today, yesterday, this_month(_inc), last_month, this_year_inc, last_year(_inc), and the last_x_days / last_x_weeks_sun_sat / last_x_weeks_mon_sun / last_x_months / last_x_years families — substitute a number for x (e.g. last_90_days, last_3_months) and append _inc to include the current period. There is NO native quarter or year-to-date preset: deliver 'this/last quarter', 'year to date', and any viewer-picked custom range via date_range_type="custom" with start_date/end_date (YYYY-MM-DD) computed in the dashboard's own JS (derive the boundaries from new Date()). Prefer including a fully custom start/end picker alongside the presets.
Period comparison: when comparison is wanted, add ONE dashboard-wide comparison control and feed the SAME compare params into EVERY widget's smQuery — time-series charts too, not only scorecards. compare_type="prev_range" (previous period), "prev_year" (same period last year), "prev_year_weekday", or "custom" (with compare_start_date/compare_end_date, YYYY-MM-DD); compare_show="perc_change" (default), "abs_change", or "value". For a year-over-year time-series overlay, either use compare_type or issue a second smQuery for the prior period and plot it as an additional series.
Give each chart/table/KPI its own stable smQuery key (see the 'code' param) so rapidly changing a selector can't show stale data from a previous selection.
If an 'upload' response includes
code_warnings, the board will render empty/wrong data or never refresh — fix the issue it names (a static board with no smQuery calls, or column mapping via requested_field_ids) and re-upload before sharing the board.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "manage_dashboards"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | Complete dashboard code (HTML or JSX) — a self-contained page that visualizes the data. Required for 'upload'. Query data with the host-injected smQuery(tool, params); see supermetrics_guide(mode='dashboard_bigquery') for BigQuery. Wrap each section in paired region markers so 'edit' can patch it. | |
| title | No | Display name of the dashboard ('upload'). If omitted or blank, a title is derived from the code (its <title>, else the first heading). | |
| action | Yes | 'upload' to publish a new dashboard or replace an existing one, 'edit' to apply targeted patches to dashboard code | |
| patches | No | Anchor-based patches for 'edit'. Types: region replace, find/replace, after/insert, before/insert. Applied sequentially and atomically. | |
| description | No | Optional short description of the dashboard itself (what it shows, its purpose), stored on the board and shown in the board list ('upload'). | |
| dashboard_id | No | UUID of the dashboard. Required for 'edit'. For 'upload', omit to publish a new dashboard or provide to replace an existing one. | |
| allowed_tools | No | MCP tool names the dashboard is allowed to call ('upload'). Must be an explicit list, e.g. ["data_query"]; never null or empty. | |
| change_summary | No | Optional one-line summary of this version, shown in the dashboard changelog | |
| allowed_accounts | No | Per-data-source allow-list of the account IDs the dashboard queries ('upload'), e.g. {"AW": ["123"]}. This is a security boundary: viewers query on the owner's credentials, so list only the accounts the board uses. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | ||
| error | No | ||
| notes | No | ||
| success | Yes | ||
| business_context | No |