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
-
Create a chart project:
npx -p @databrainhq/mcp-server databrain custom-chart init my-chart cd my-chart npm installThe folder has
manifest.json,chart.ts,chart.css,icon.svg, sample data andAGENTS.md, the full author guide.npm installadds thedatabraincommand to the project, so the next steps run it withnpx. Each command is also an npm script, for examplenpm run validate. -
Edit
chart.ts. Then check the manifest, icon and CSS:npx databrain custom-chart validate -
Build the chart:
npx databrain custom-chart buildThis writes
dist/index.js,manifest.json,icon.svg,index.cssandbundle.zip. -
Look at it with the sample data:
npx databrain custom-chart devThis opens a local sandbox page, by default on
http://127.0.0.1:4174. Pick the theme and size at the top. After you editchart.ts, select Rebuild and reload.
The local sandbox draws the chart with the sample data. Events from the chart show on the right. -
Upload it as a private chart:
DATABRAIN_SERVICE_TOKEN=<your-service-token> npx databrain custom-chart uploadThe 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.

Options
| Option | Command | What it does |
|---|---|---|
--key <key>, --name <name> | init | Set the chart key and name |
--force | init | Write into a folder that is not empty |
--port <port> | dev | Use another port |
--publish | upload | Publish the uploaded version at once |
--yes | upload | Skip 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.