cwtwb
cwtwb is a Python-based MCP server for programmatically building, editing, validating, and migrating Tableau workbooks (.twb/.twbx) from code or agent tool calls (e.g., Claude, Cursor, VSCode).
Workbook Management
Create workbooks from templates or scratch, open existing ones, save as
.twbor.twbx, and validate against the official Tableau XSD schema.
Worksheet Operations
List, add, clone, hide/unhide, caption, and refactor worksheets; list available datasource fields.
Chart Building
Configure bar, line, pie, map, KPI, text, and dual-axis charts with full control over rows, columns, marks, colors, labels, filters, tooltips, sorting, and axes. Apply styles and use preset chart recipes.
Data Connections
Set up Excel, Hyper, MySQL, or Tableau Server datasource connections.
Calculated Fields & Parameters
Add/remove calculated fields with custom formulas and add parameters with ranges and allowed values.
Dashboard Authoring
Combine worksheets into dashboards with layout control, add filter/highlight/URL actions, and generate layout JSON with ASCII preview.
Guided Authoring (Agentic Workflow)
Multi-stage pipeline: datasource intake → schema inspection → analysis brief → authoring contract → wireframes → execution plan → workbook generation, with human-in-the-loop confirmation at each stage.
Migration Tools
Profile a TWB, inspect a target schema, propose field mappings, preview and apply migration, or run a guided migration with blocker/warning detection.
Analysis & Capability Inspection
Analyze TWB files against cwtwb's capability registry, diff template gaps, and list/describe server capabilities.
Allows inspecting .hyper file schemas, resolving physical table names, and using Hyper as a datasource for guided workbook authoring.
The cwtwb package is distributed via PyPI for installation with pip.
The toolkit is a Python library and MCP server that allows programmatic generation of Tableau workbooks using Python code.
Provides XML engine (lxml) for patching, validating, and saving Tableau workbook XML files.
cwtwb
Tableau workbook engineering for reproducible
.twb/.twbxgeneration, validation, and migration.
cwtwb is a Python toolkit and Model Context Protocol (MCP) server for building Tableau Desktop workbooks from code or agent tool calls.
It is meant to be a workbook engineering layer, not a conversational analytics agent. The focus is reproducibility, inspectability, and safe automation in local workflows, scripts, and CI.
The cw in cwtwb comes from Cooper Wenhua.
Latest update (0.18.8): date-like fields now keep date bindings such as MONTH(Order Date) while raw numeric measures still default to SUM(...).
Author: Cooper Wenhua <imgwho@gmail.com>
Try the example workflow · Read the guide
Quick Start
Install
pip install cwtwbIf you want the bundled Hyper-backed example too:
pip install "cwtwb[examples]"Run As An MCP Server
uvx cwtwbAdd the server to your MCP client with the same command. For example:
{
"mcpServers": {
"cwtwb": {
"command": "uvx",
"args": ["cwtwb"]
}
}
}For Claude Code:
claude mcp add cwtwb -- uvx cwtwbFor VSCode, add cwtwb to your workspace or user mcp.json and use uvx cwtwb as the command.
For client-specific details and the full reference, see https://github.com/imgwho/cwtwb/blob/master/docs/guide.md.
Highlights
Area | What you get |
Workbook authoring | Generate |
Chart building | Build bar, line, pie, map, KPI, and dual-axis workbooks |
Safety | Validate structure and Tableau XSD before publishing |
Migration | Repoint existing workbooks to new data sources with explicit steps |
MCP support | Drive workbook workflows from Claude, Cursor, VSCode, or other MCP clients |
See It In Action
This GIF shows the MCP tool flow that builds a dashboard step by step.
Architecture
Interfaces
┌───────────────────────────────────────────────────────────────┐
│ ┌──────────────────────────┐ ┌───────────────────────────┐ │
│ │ MCP Server │ │ Python Library │ │
│ │ tools_workbook │ │ from cwtwb.twb_editor │ │
│ │ tools_layout │ │ import TWBEditor │ │
│ │ tools_migration │ │ │ │
│ │ tools_support │ │ editor.add_...() │ │
│ │ │ │ editor.configure_...() │ │
│ │ (Claude / Cursor / │ │ editor.save(...) │ │
│ │ VSCode / Claude Code) │ │ │ │
│ └─────────────┬────────────┘ └──────────────┬────────────┘ │
│ └──────────────┬────────────────┘ │
└───────────────────────────── ┼ ─────────────────────────────┘
▼
┌───────────────────────────────────────────────────────────────┐
│ TWBEditor │
│ ParametersMixin · ConnectionsMixin │
│ ChartsMixin · DashboardsMixin │
└──────────┬──────────────────┬──────────────────┬─────────────┘
▼ ▼ ▼
┌──────────────────┐ ┌──────────────┐ ┌──────────────────────┐
│ Chart Builders │ │ Dashboard │ │ Analysis & │
│ │ │ System │ │ Migration │
│ Basic DualAxis │ │ │ │ │
│ Pie Text │ │ layouts │ │ migration.py │
│ Map Recipes │ │ actions │ │ twb_analyzer.py │
│ │ │ dependencies│ │ capability_registry │
└────────┬─────────┘ └──────┬───────┘ └──────────┬───────────┘
└───────────────────┼──────────────────────┘
▼
┌───────────────────────────────────────────────────────────────┐
│ XML Engine (lxml) │
│ template.twb/.twbx → patch → validate → save │
└───────────────────────────────┬───────────────────────────────┘
▼
output.twb / output.twbxFAQ
What is the difference between .twb and .twbx?
.twb is the workbook XML. .twbx is the packaged version that bundles the workbook together with extracts and images.
Does validate_workbook save files?
No. validate_workbook() checks the workbook in memory or on disk, but it does not write output. save_workbook() is the tool that writes files.
When should I use uvx cwtwb versus python -m cwtwb.mcp?
Use uvx cwtwb for the normal MCP workflow. Use python -m cwtwb.mcp for local testing without uvx.
Where is the full guide?
See the online guide.
Documentation
License
AGPL-3.0-or-later
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/imgwho/cwtwb'
If you have feedback or need assistance with the MCP directory API, please join our Discord server