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

    The folder has manifest.json, chart.ts, chart.css, icon.svg, sample data and AGENTS.md, the full author guide.

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

    databrain custom-chart validate
  3. Build the chart:

    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:

    databrain custom-chart dev

    This opens a local sandbox page, by default on http://127.0.0.1:4174.

  5. Upload it as a private chart:

    DATABRAIN_SERVICE_TOKEN=<your-service-token> 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 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.

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.