add_calculated_field
Add a calculated field to the datasource.
For formula syntax and best practices, read: read_resource('cwtwb://skills/calculation_builder')
Author Tableau workbooks as files — charts, calculated fields, dashboards, actions — then validate against the XSD and the REST API before publishing.
LABSCO SUMMARY
Two guards do most of the work. Calculated fields are checked against a packaged function catalog before the XML changes — CHR(10) comes back rejected with a CHAR() suggestion — and repairs default to a dry run. Write commands need an explicit output path unless you deliberately ask to edit in place, and the cloud semantic check runs without publishing, so a malformed workbook is caught without leaving a copy on the server.
A Python toolkit and MCP server that builds .twb and .twbx workbooks by patching XML with lxml, from a packaged template or from scratch. It reads existing workbooks too: analyse them, audit their calculated fields, and repoint them at a new data source.
Python 3.10 or higher. Install with pip install cwtwb, or let the client launch it with uvx cwtwb; cwtwb mcp and python -m cwtwb.mcp_server are equivalent. Local authoring needs no credentials at all. Cloud validation and publishing need the validate extra installed and Tableau credentials, resolved in a fixed order: an explicit env_path first, then environment variables, then TABLEAU_ENV_FILE, then a .env beside the workbook, the working directory, and finally your home directory.
One command — uvx cwtwb
USE CASES
Create the workbook, add the worksheets and their charts, compose the dashboard, and save to an explicit path.
Analyse the file, audit the calculated fields against the function catalog, then run the repair — dry run first.
Read the target schema, propose the field mapping, preview what would change, then apply it.
Check structure and XSD conformance locally, then run the REST API semantic check without publishing the file.
State the requirements, read the ranked templates with their reasons and penalties, then bind real worksheet names into the layout.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
add_calculated_fieldAdd a calculated field to the datasource.
For formula syntax and best practices, read: read_resource('cwtwb://skills/calculation_builder')
add_dashboardCreate a dashboard combining multiple worksheets.
Recommended workflow for complex dashboards:
Layout options:
For dashboard design best practices, read: read_resource('cwtwb://skills/dashboard_designer')
add_dashboard_actionAdd a filter, highlight, URL, navigation, or parameter dashboard action.
For `action_type="parameter", provide source_field, target_parameter, and a Tableau-serialized clear_value such as d:2026-02-12, i:0, or s:LROOT:All`.
add_dashboard_set_actionAdd a Set Action (edit-group-action) to a dashboard.
The set fills with the marks under the pointer and clears when it leaves, enabling hover-driven labels and calculations.
add_groupCreate a categorical dimension by grouping source-field members.
add_hierarchyCreate an ordered Tableau drill hierarchy from bare dimension fields.
add_parameterAdd a parameter to the workbook.
add_reference_lineAdd a field-backed reference line to a configured worksheet pane.
add_setCreate a Tableau set (datasource filter-group) for membership logic.
Use basis_field + top_n to build a top-N set (e.g. Top Central ranked by SUM(Central - Qty)); omit both to create an empty set used as a Set Action target (e.g. Highlighted Manufacturer).
add_worksheetAdd a new blank worksheet to the workbook.
analyze_twbAnalyze an existing TWB/TWBX file against cwtwb's declared capabilities.
This tool requires a file_path that already exists on disk. It cannot analyze the active in-memory workbook directly and it does not save the current workbook. For a newly generated workbook, call save_workbook first, then pass that saved path to analyze_twb.
apply_twb_migrationApply a workbook migration and write a migrated TWB plus reports.
apply_worksheet_refactorRewrite one worksheet to use replacement fields without touching others.
audit_calculated_fieldsReport calculated-field datatype/role contradictions without mutation.
clone_worksheetClone an existing worksheet and its worksheet window.
configure_chartConfigure chart type and field mappings for a worksheet.
For chart type selection and encoding best practices, read: read_resource('cwtwb://skills/chart_builder')
configure_chart_recipeConfigure a showcase recipe chart through the shared recipe registry.
For recipe chart patterns, read: read_resource('cwtwb://skills/chart_builder')
configure_dual_axisConfigure a dual-axis chart composition.
For dual-axis chart patterns and best practices, read: read_resource('cwtwb://skills/chart_builder')
configure_layered_chartBuild an explicit multi-pane worksheet, including Multiple Values axes.
configure_subtotalsConfigure visual subtotals and per-dimension subtotal labels.
configure_worksheet_styleApply worksheet-level styling: background color, axis/grid/border visibility.
For formatting best practices, read: read_resource('cwtwb://skills/formatting')
create_workbookCreate a new workbook from a TWB or TWBX template file.
describe_capabilityDescribe one declared capability and its support tier.
diff_template_gapSummarize the non-core capability gap of a TWB template.
enable_domain_completionAdd an INDEX() detail table calculation to trigger Tableau densification.
generate_gallery_layoutBind exact worksheet names to a Gallery template and validate the layout DSL.
generate_layout_jsonGenerate and save a dashboard layout file.
Recommended workflow:
The layout_tree uses the declarative container DSL:
generate_layout_yamlGenerate and save a dashboard layout YAML file.
Recommended workflow:
The layout_tree uses the same declarative container DSL as generate_layout_json.
get_mcp_statusReport cwtwb MCP server version, workbook state, and safe usage guardrails.
Use this when an AI client seems stale, cannot see expected tools, or is about to edit MCP configuration to switch Tableau credentials. This tool never returns secret values.
inspect_excel_connectionPreview how an Excel workbook will be interpreted before connection setup.
inspect_target_schemaInspect the first-sheet schema of a target Excel datasource.
list_capabilitiesList cwtwb's declared capability boundary.
This reports what workbook features/charts are supported by cwtwb. It does not enumerate callable MCP tools and should not be used to infer whether a tool like add_dashboard or save_workbook exists.
list_dashboardsList dashboards and their worksheet zones in the current workbook.
list_fieldsList all available fields in the current workbook datasource.
list_gallery_templatesList packaged Gallery layouts and their explicit worksheet slots.
list_worksheetsList worksheet names in the current workbook.
open_workbookOpen an existing workbook (.twb or .twbx) for in-place worksheet editing.
preview_twb_migrationPreview a workbook migration onto a target datasource.
preview_worksheet_refactorPreview worksheet-scoped field rewrites without mutating the workbook.
profile_twb_for_migrationProfile workbook datasources and worksheet scope before migration.
propose_field_mappingScan source and target schema and propose a field mapping.
recommend_gallery_templatesRecommend compatible Gallery templates with scores and reasons.
remove_calculated_fieldRemove a previously added calculated field.
repair_calculated_field_issuesPreview or explicitly apply selected calculated-field metadata repairs.
save_workbookSave the active workbook as a .twb or .twbx file. Use a .twbx extension to produce a packaged workbook (ZIP) that bundles the XML with any data extracts and images carried over from the source .twbx.
This is the only default MCP tool that writes the active in-memory workbook to disk. After create_workbook/open_workbook plus worksheet/chart/dashboard edits, call save_workbook with the desired output_path to create the final .twb or .twbx file. validate_workbook and analyze_twb do not save files.
screenshot_workbookScreenshot a published workbook's view for human review.
Use after upload_workbook to capture a visual snapshot. The screenshot is saved locally for human inspection.
Args: workbook_id: The workbook ID returned by upload_workbook. output_dir: Directory to save screenshot (default: output/validation). view_index: Index of the view to screenshot (default: 0). view_name: Name of the view to screenshot (overrides view_index). env_path: Optional path to a .env file with Tableau credentials. Explicit env_path takes priority over process environment variables.
Returns: {success, path, view_name, view_id, size_kb, error}
set_csv_connectionConfigure the workbook datasource to use a local CSV connection.
set_excel_connectionConfigure the workbook datasource to use a local Excel connection.
set_hyper_connectionConfigure the workbook datasource to use a local Hyper extract connection.
set_mysql_connectionConfigure the workbook datasource to use a local MySQL connection.
set_tableauserver_connectionConfigure the workbook datasource to use a Tableau Server connection.
This edits the workbook datasource connection only. It does not configure Tableau REST API/PAT credentials for validate_workbook_api, upload_workbook, or screenshot_workbook; pass env_path to those validation tools instead.
set_worksheet_captionSet or clear a plain-text worksheet caption.
set_worksheet_titleSet or clear the visible plain-text worksheet title.
upload_workbookPublish a .twb/.twbx to Tableau Cloud for openability or screenshots.
Prefer validate_workbook_api for the default cloud semantic validation path because it does not publish or store the workbook. Use upload_workbook only when you explicitly need a published workbook_id, visual screenshot, TWBX packaging validation, or publish/openability evidence.
Args: twb_path: Path to .twb or .twbx file. data_path: Optional data file (.xlsx/.xls/.hyper) to package. name: Workbook name on Tableau Cloud (defaults to filename stem). overwrite: Whether to overwrite existing workbook with same name. env_path: Optional path to a .env file with Tableau credentials. Explicit env_path takes priority over process environment variables.
Returns: {success, workbook_id, workbook_url, views, twbx_path, twbx_size_kb, error}
validate_formulaCheck Tableau function names without mutating the active workbook.
validate_workbookValidate a workbook against the official Tableau TWB XSD schema.
Checks whether the generated XML conforms to Tableau's published schema. This tool does not save or export the active workbook. If file_path is omitted, it validates the current in-memory workbook before save; if file_path is provided, it validates an existing .twb/.twbx file on disk. Call save_workbook when you need to write the workbook to a file.
Args: file_path: Path to a .twb or .twbx file to validate. If omitted, validates the currently open workbook (in memory, before save).
Returns: PASS/FAIL summary with error details.
validate_workbook_apiValidate a .twb file via Tableau Cloud REST API (no publish).
This performs semantic validation that checks whether the workbook will actually open in Tableau — beyond what local XSD schema validation can detect (calculated field formulas, field references, data source connectivity, etc.). The file is NOT stored on the server.
Only .twb files are supported. For .twbx files, use upload_workbook.
Requires Tableau Cloud June 2026+ / Server 2026.2+ (API version 3.29+).
Args: twb_path: Path to .twb file. validation_level: "syntactic" (XSD only) or "semantic" (full, default). env_path: Optional path to a .env file with Tableau credentials. Explicit env_path takes priority over process environment variables.
Returns: {success, validation_level, valid, errors, warnings, error}
BEFORE YOU INSTALL
58 tools when we connected. The guide's MCP Tools table covers 34; add_group, inspect_excel_connection, list_gallery_templates, repair_calculated_field_issues, set_csv_connection and set_worksheet_title are undocumented.
uvx on PATH
Both documented clients run the server on your machine.
CONTEXT COST
Rated by the size of the 58 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
uvx cwtwbclaude mcp add cwtwb -- uvx cwtwb{
"mcpServers": {
"cwtwb": {
"command": "uvx",
"args": [
"cwtwb"
]
}
}
}