Cursor and Vizro-MCP tutorial
About this tutorial
This tutorial uses a public dataset about winners of the Booker prize, which is a literary award conferred each year for the "best sustained work of fiction written in English and published in the UK and Ireland".
To work through the tutorial, you'll need to download the .xlsx dataset of Booker prize winners from 1969 to 2023 from Kaggle. The tutorial illustrates how to work with the data locally.
The tutorial uses Cursor as the MCP host, but if you prefer to use Microsoft VS Code, you can also follow the instructions since the environments are very similar.
The tutorial uses the host to generate an initial set of Python chart code, runs it to inspect the chart, then modifies the code by hand. The prompts and chart output at the time of writing are shown to illustrate the process. The nature of working with an LLM is that your output may be slightly different.
Set up Vizro-MCP
If you haven't already done so, follow our instructions to set up Vizro-MCP to work with Cursor, which this tutorial uses. Follow the instructions to set up Vizro-MCP with Microsoft VS Code if you prefer to use that host, or use our basic setup configuration for your preferred host.
To check that your host is correctly set up to use Vizro-MCP, pass in a prompt:
You should receive a response similar to the following:

Strategy
There is no single correct way to use Vizro-MCP, and the style of interaction also depends on the underlying LLM that you have chosen. Assuming you are using Cursor, select Open Folder from the File menu. Navigate to the folder you've stored the data, which is where you'll create Vizro code to visualize it.
Prompt to generate a Vizro chart
As a first prompt, type something similar to the following:
Use Vizro-MCP to build a butterfly chart for the
Booker Prize Dataset Final.xlsx using GENDER
(M on left hand side, F on right hand side),
with the count of each gender for each AGE BIN.
Here is the prompt as it was typed. Before you submit it, we recommend you check that the model selected is claude-4-sonnet and the mode is Agent:

When you submit this prompt to Cursor, you will see some output, which will pause and wait for you to give permission to continue. The pause is a security measure to prevent rogue MCP servers from executing code:

You can grant permission for Vizro-MCP tools to run as shown. If you don't want to have to select Run each time you submit a prompt, you can add Vizro-MCP's get_vizro_chart_or_dashboard_plan tool to the Allowlist by opening the dropdown indicated next to Ask Every Time:

When you select Use Allowlist you'll be shown the following disclaimer. Select Continue to confirm the tool.

You will be asked to give similar permission for additional Vizro-MCP tools to run, and can similarly add these to the Allowlist. When you have done this, Cursor uses Vizro-MCP to generate some code for the chart requested.

Save the code
Ask Cursor to save the code into a .py file. For convenience, save it in the same directory as the data:
Execute the code
Open a new terminal within Cursor from the Terminal menu and navigate to the code and data directory within it. Create a new virtual environment to run the Vizro code, and install the necessary dependencies. In the below, we use the uv package manager:
uv venv cursorenv
source cursorenv/bin/activate
uv pip install pandas
uv pip install openpyxl
uv pip install vizro
Next, if the final line of code (fig.show()) is commented out, uncomment it so the chart is displayed, and save the code change.
In the terminal, type the following to execute the code:
The output we received was as follows:

Code iteration by hand
At first sight, the butterfly chart is already almost complete, but in the code we received, there was a missing line that meant that the number of women in each age bin was missing. It is possible to ask Cursor to make a fix, but it is a trivial change to make manually.
We added this line in the fig.add_trace() call (see a later section for the complete code).
Executing the chart again, we received the following:

Code iteration by prompt
We can now modify the code again, but since this is a more complex change, we can ask Cursor to do it:
When we submitted the prompt, Cursor spent some time working through the changes, and finally returned this information:

Re-running the code showed the following:

Final iteration
The chart is looking great. We can make a final tweak to change the color of the female bin to make it pink (hex code #ff0eef). Change the marker_color specification (for us, in line 107), and save the code, then re-run it. Our result was as follows:

The chart is complete!
Final chart code
When you are happy with the chart, you can store the code, for example, in GitHub. Here it is for reference:
The final code for the completed chart.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
Save the prompt for your dashboard
You can ask Cursor, or your preferred host, to give you a comprehensive prompt to store alongside the code for future reference.
Can you give me the text of a complete prompt that would
lead you to generate this chart with Vizro-MCP?
This is the output we received:
Use Vizro-MCP to build a butterfly chart using Booker Prize Dataset Final.xlsx. The chart should show GENDER distribution with males (M) on the left-hand side and females (F) on the right-hand side, displaying the count of each gender for each AGE BIN.
Requirements:
Use AGE BIN column for grouping (not AGE WHEN WON)
Male bars should appear on the left side in blue color
- Female bars should appear on the right side in magenta color (#ff0eef)
- Include detailed hover text that shows the actual WINNER names and NOVEL titles for each bar
- The hover text should list each winner and their novel that falls into that specific age bin and gender combination
- Chart title should be "Booker Prize Winners by Gender and Age Bin"
- Y-axis should show "Age Bin" and X-axis should show "Count"
- Use categorical y-axis ordering for age bins
- Save the complete code as a .py file in the current folder
- The file should include proper documentation, imports, and example usage code
- Make sure the chart displays immediately when the script is run (fig.show())
Summary
Congratulations! You have seen how to work with Vizro-MCP and Cursor to build a Vizro chart. If you used Microsoft VS Code, you would have seen a similar result, although the exact results depend on the underlying LLM you selected.
In this tutorial, the chart is a very simple example, but it can be further customized or added to a Vizro dashboard alongside additional charts and controls, as described in the Vizro documentation. You can use Vizro-MCP with Cursor to help you achieve these further customizations.
To learn more about the main elements of Vizro dashboard code, we recommend you work through the introductory "Explore Vizro" tutorial. The tutorial, and accompanying video, enable you to explore the dashboard code generated by Vizro-MCP and give you ideas of how to modify it by hand rather than through a prompt, should you prefer to fine-tune it manually.