Skip to Content

MCP Server

Build a custom chart with the CLI

Create, test and upload a custom chart type from your terminal.

The @databrainhq/mcp-server package includes a databrain command for chart authors. It makes a chart project, builds it and uploads it to Databrain.

Before you start

  • Node.js 20 or later.
  • Custom charts are on for your company, and you are an Admin. You see Settings > Custom charts.
  • A service token from Settings > Tokens > Service Tokens, for the upload step.

Steps

  1. Create a chart project:

    npx -p @databrainhq/mcp-server databrain custom-chart init my-chart
    cd my-chart
    npm install

    The folder has manifest.json, chart.ts, chart.css, icon.svg, sample data and AGENTS.md, the full author guide. npm install adds the databrain command to the project, so the next steps run it with npx. Each command is also an npm script, for example npm run validate.

  2. Edit chart.ts. Then check the manifest, icon and CSS:

    npx databrain custom-chart validate
  3. Build the chart:

    npx databrain custom-chart build

    This writes dist/index.js, manifest.json, icon.svg, index.css and bundle.zip.

  4. Look at it with the sample data:

    npx databrain custom-chart dev

    This opens a local sandbox page, by default on http://127.0.0.1:4174. Pick the theme and size at the top. After you edit chart.ts, select Rebuild and reload.

    Custom chart dev page for Revenue funnel with Theme light, Size 600 x 320 and the highlighted Rebuild and reload button. The chart shows bars for eight countries with value labels, and the Events panel shows ready.
    The local sandbox draws the chart with the sample data. Events from the chart show on the right.
  5. Upload it as a private chart:

    DATABRAIN_SERVICE_TOKEN=<your-service-token> npx databrain custom-chart upload

    The command builds, checks the bundle on the server, shows the plan and asks you to confirm. On a self-hosted instance, also set DATABRAIN_API_URL.

The command prints Created custom:my-chart (v1, private). The chart is now in Settings > Custom charts as a private version. To make it available to every builder, publish it there, or upload with --publish.

Custom chart card Revenue funnel with a bar chart preview, the highlighted Private badge, and the line 1 version, by Service token, Just now.
The uploaded chart in Settings > Custom charts, still Private.

Options

OptionCommandWhat it does
--key <key>, --name <name>initSet the chart key and name
--forceinitWrite into a folder that is not empty
--port <port>devUse another port
--publishuploadPublish the uploaded version at once
--yesuploadSkip the confirmation prompt

If something goes wrong

Each problem prints as one line: path code message. The command ends with exit code 1 when there is any problem. Fix the file at the path and run the command again.

From an AI app, the same work runs through the custom_chart_* tools. See the tools reference.