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-chartThe folder has
manifest.json,chart.ts,chart.css,icon.svg, sample data andAGENTS.md, the full author guide. -
Edit
chart.ts. Then check the manifest, icon and CSS:databrain custom-chart validate -
Build the chart:
databrain custom-chart buildThis writes
dist/index.js,manifest.json,icon.svg,index.cssandbundle.zip. -
Look at it with the sample data:
databrain custom-chart devThis opens a local sandbox page, by default on
http://127.0.0.1:4174. -
Upload it as a private chart:
DATABRAIN_SERVICE_TOKEN=<your-service-token> 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 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.