Skip to main content
Version: 8.3.2

LightningChart and AI

Generating code with large language models (LLMs) is a rapidly growing area of interest for developers. While LLMs are often capable of generating working code it can be a challenge to consistently generate code for libraries like LightningChart JS that have several different versions and use cases.

This section is dedicated to hosting resources to help developers use AI tools with LightningChart JS better.

tip

Please share your own experiences with AI/LLM tools capability to work with LightningChart JS API at [email protected]

LightningChart MCP Server

By far the easiest way to transform your AI Agents to high-performance charting specialists, is to install the LightningChart MCP server, found open source at GitHub.

What does this do?

  • It strongly urges your agent to refer to the official LightningChart documentation, instead of hallucinated training data memories or random Stack Overflow searches.
  • Your agent receives an LLM-optimized Index of the entire LightningChart documentation, which is very effective for finding the most suitable documentation page depending on the task at hand, rather than using up a lot of context by reading massive chunks of documentation.
  • Last, but not least, we share our hand-written "common mistakes" section with the Agent context, which prevents majority of recurring mistakes that Agents otherwise tend to do

How to install it?

Refer to GitHub for latest updates.

// Example, Claude MCP
claude mcp add --scope user lightningchart-js -- npx -y @lightningchart/mcp-server@latest

For Codex, write following configuration to .codex/config.toml

[mcp_servers.lightningchart]
command = "npx"
args = ["-y", "@lightningchart/mcp-server"]
enabled = true

Or add it through the user interface, with following specs:

  • Name: LightningChart
  • Transport: STDIO
  • Command: npx
  • Arguments: -y
  • Arguments: @lightningchart/mcp-server

After installation, your Agent will automatically pull in the LightningChart knowledge context when it identifies a charting related prompt!

LightningChart Agent Skill

An alternative flavour to the MCP Server, is the official LightningChart JS Agent Skill. This is also found as open-source in GitHub.

It does the exact same thing, only the installation and use flavour is different:

Installation

Copy the lightningchart-js folder into a skills directory supported by your agent.

  • Project-local Agent Skills location: .agents/skills/lightningchart-js/
  • OpenAI Codex local skills location: .codex/skills/lightningchart-js/
  • Claude local skills location: .claude/skills/lightningchart-js

Restart the agent/tool. Some times, skills need to be explicitly invoked by mentioning them in your prompt. But in our experience, agents tend to pick the skill up proactively, as long as the task is related to charting.

Importance of type checking

As LightningChart JS is a strongly typed library, probably the single best thing you can do to improve the work quality of your agents is to instruct them to run a type check after any code change:

- After any code change, confirm that typings are OK using `npm run typecheck`

Where typecheck script will just run tsc --noEmit or equivalent. Then, if there are type errors (which are extremely common due to hallucinations or outdated training data), the agent will reattempt immediately rather than waiting for you to tell that it doesn't work.

This is automatically suggested if you use the official LightningChart skill or MCP server.

llms.txt

In our experience LLM's are very poor at working with specific 3rd party libraries out of the box, because their training data is a mix of all the existing versions of that library. They also tend to hallucinate results by mixing data from various different libraries.

For this purpose, we provide versions of our developer documentation and API reference in LLM friendly formats here:

Our recommendation is to ensure your LLM has access to these files and specifically instruct the LLM to use them as the source of truth on all matters LightningChart JS.

This is also what the LightningChart Agent skill and MCP server do behind the scenes.

If in practice your LLM attempts un-optimal approaches such as:

Then it is most likely a sign that you should tweak or alter your prompt and reattempt the command.

If not already using the LightningChart Skill or MCP server, then you can simply download lcjs-docs-llms.txt and lcjs-api-llms.txt to your repository and add following section to your AGENTS.md, CLAUDE.md or equivalent:

- You MUST always use the local files lcjs-docs-llms.txt and lcjs-api-llms.txt as the only sources of truth for all matters regarding how to use LightningChart JS library / lcjs

Working with chat-based LLMs

In our experience, chat-based LLMs have much more trouble following a seemingly simple instruction like "refer to X for guidance". Furthermore, there are great differences between platforms. For example:

  • GPT-5.2 - the LLM tells you that it will stick strictly to the specified documentation, then proceeds to dump hallucinated API usages that have never existed in the library
  • Sonnet 4.5 / Opus 4.5 - these models were able to follow the instructions well and provide up to date and well referenced recommendations

You can confirm whether the model is listening to your requirement by additionally asking it to cite all references, and checking if it lists external sources. When receiving non-working results, the reason is often referencing several years old API documentation pages or just answering directly from training data.

Ideally it would be sufficient to just include this in every new chat context:

- You MUST always use the https://lightningchart.com/js-charts/docs/llms.txt and https://lightningchart.com/js-charts/api-documentation/llms.txt as the only sources of truth for all matters regarding how to use LightningChart JS library / lcjs

Some chat tools also support loading skills / connecting MCP servers!

info

No one likes hallucinated chart code - please help us maintain an effective instruction set by sharing what works best for you at [email protected]

Here is also an alternate version of developer documentation intended for LLMs where all text content is put into one large file. In our experience, this doesn't work too well but you can give it a try.