Skip to main content

Tableau Workbook (.twb) generation toolkit and MCP server

Project description

cwtwb

Datacooper logo

Tableau workbook engineering for reproducible .twb / .twbx generation, validation, and migration.

cwtwb hero image

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.

Author: Cooper Wenhua <imgwho@gmail.com>

Website · Source · Changelog

Website Source License Python

Star History Chart

Try the example workflow · Read the guide

Quick Start

Install

pip install cwtwb

If you want the bundled Hyper-backed example too:

pip install "cwtwb[examples]"

If you want cloud validation (upload to Tableau Cloud/Server):

pip install "cwtwb[validate]"

Run As An MCP Server

uvx cwtwb

Add 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 cwtwb

For 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 .twb / .twbx files from templates or from scratch
Chart building Build bar, line, pie, map, KPI, and dual-axis workbooks
Safety Validate structure and Tableau XSD before publishing
Cloud validation Upload to Tableau Cloud/Server to verify .twb is structurally valid, with optional screenshot
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.

cwtwb demo GIF

Architecture

                            Interfaces
  ┌───────────────────────────────────────────────────────────────┐
  │  ┌──────────────────────────┐  ┌───────────────────────────┐  │
  │  │        MCP Server        │  │      Python Library       │  │
  │  │  tools_workbook          │  │  from cwtwb.twb_editor    │  │
  │  │  tools_validate          │  │  import TWBEditor         │  │
  │  │                          │  │                           │  │
  │  │                          │  │  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.twbx
                                  ▼
  ┌───────────────────────────────────────────────────────────────┐
  │               Cloud Validation (optional)                    │
  │    upload_workbook → Tableau Cloud/Server → screenshot_workbook      │
  │    Confirms .twb is structurally valid and captures preview   │
  └───────────────────────────────────────────────────────────────┘

FAQ

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.

What is upload_workbook for?

upload_workbook uploads a .twb to Tableau Cloud/Server to verify it is structurally valid. Upload success means Tableau Cloud/Server can parse the workbook. Requires pip install "cwtwb[validate]" and a .env file with Tableau credentials (see .env.example).

How do I set up Tableau Cloud/Server validation?

  1. Install: pip install "cwtwb[validate]"
  2. Copy .env.example to .env
  3. Fill in your Tableau Cloud/Server PAT credentials
  4. After save_workbook, call upload_workbook to validate

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cwtwb-0.21.0.tar.gz (19.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cwtwb-0.21.0-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file cwtwb-0.21.0.tar.gz.

File metadata

  • Download URL: cwtwb-0.21.0.tar.gz
  • Upload date:
  • Size: 19.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for cwtwb-0.21.0.tar.gz
Algorithm Hash digest
SHA256 7c27db42e11e85ee807725a219020dfa76055b0c23739a5fea0193d6135749c8
MD5 779e15684a9ad3334f6690dd708b0b46
BLAKE2b-256 5ae442a932a3dd35526f3e48a6203d7eb7386301cc21707f8215d4804f392c5d

See more details on using hashes here.

File details

Details for the file cwtwb-0.21.0-py3-none-any.whl.

File metadata

  • Download URL: cwtwb-0.21.0-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for cwtwb-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99f38f36284e28ad2894ad54ebf2cc5930bd6a211bb043aa7ce6497ce0a590c0
MD5 8ff3675eb2c383c9b114bc0787d7ef2c
BLAKE2b-256 477a95c51343c49f5bf01fce63ec3f91bd866dfe9568574ab46dfa0f888580e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page