Allows the programmatic generation of Tableau Prep data flows that connect to and extract data from MySQL databases as input sources.
Enables the definition of Tableau Prep data flows that integrate PostgreSQL databases for automated data preparation and ingestion.
cwprep - Text-to-PrepFlow Engine
cwprep is a Python-based engine that enables Text-to-PrepFlow generation.
By reverse-engineering the .tfl JSON structure and providing a built-in MCP (Model Context Protocol) server, cwprep acts as a bridge between LLMs (like Claude, Gemini) and Tableau Prep. You can now generate, modify, and build data cleaning flows simply through natural language conversations or Python scripts, without ever opening the GUI!
Installation
pip install cwprepQuick Start
from cwprep import TFLBuilder, TFLPackager
# Create builder
builder = TFLBuilder(flow_name="My Flow")
# Add database connection
conn_id = builder.add_connection(
host="localhost",
username="root",
dbname="mydb"
)
# Add input tables
orders = builder.add_input_table("orders", "orders", conn_id)
customers = builder.add_input_table("customers", "customers", conn_id)
# Join tables
joined = builder.add_join(
name="Orders + Customers",
left_id=orders,
right_id=customers,
left_col="customer_id",
right_col="customer_id",
join_type="left"
)
# Add output
builder.add_output_server("Output", joined, "My_Datasource")
# Build and save
flow, display, meta = builder.build()
TFLPackager.save_tfl("./my_flow.tfl", flow, display, meta)By default, both the SDK and MCP output only the final .tfl/.tflx archive. Use save_to_folder() only when you explicitly want the exploded folder for inspection.
Features
Feature | Method | Description |
Database Connection |
| Connect to MySQL/PostgreSQL/SQL Server |
File Connection |
| Connect to Excel (.xlsx/.xls) or CSV files |
SQL Input |
| Custom SQL query input |
Table Input |
| Direct table connection |
Excel Input |
| Read from Excel worksheet |
CSV Input |
| Read from CSV file |
CSV Union |
| Merge multiple CSV files |
Join |
| left/right/inner/full joins (single or multi-column) |
Union |
| Merge multiple tables |
Filter |
| Expression-based filter |
Value Filter |
| Keep/exclude by values |
Keep Only |
| Select columns |
Remove Columns |
| Drop columns |
Rename |
| Rename columns |
Calculation |
| Tableau formula fields |
Quick Calc |
| Quick clean (lowercase/uppercase/trim/remove) |
Change Type |
| Change column data types |
Duplicate Column |
| Duplicate (copy) a column |
Aggregate |
| GROUP BY with SUM/AVG/COUNT |
Pivot |
| Rows to columns |
Unpivot |
| Columns to rows |
Output |
| Publish to Tableau Server |
TFLX Packaging |
| Generate .tflx with embedded data files |
SQL Translation |
| Translate TFL flows to equivalent ANSI SQL |
Examples
See the examples/ directory for complete demos:
demo_basic.py- Input, Join, Outputdemo_cleaning.py- Filter, Calculate, Renamedemo_field_operations.py- Quick Calc, Change Type, Duplicate Columndemo_aggregation.py- Union, Aggregate, Pivotdemo_comprehensive.py- All features combinedprompts.md- 8 ready-to-use MCP prompt templates for AI-driven flow generation
MCP Server
cwprep includes a built-in Model Context Protocol server, enabling AI clients (Claude Desktop, Cursor, Gemini CLI, etc.) to generate TFL files directly.
Prerequisites
Method | Requirement |
| Install uv — it auto-downloads |
| Python ≥ 3.8 + |
Quick Start
# Local (stdio)
cwprep-mcp
# Remote (Streamable HTTP)
cwprep-mcp --transport streamable-http --port 8000Upgrading? If you previously used uvx with an older version, clear the cache to pick up the latest release:
uv cache clean cwprepClient Configuration
All clients below use the uvx method (recommended). Replace uvx with cwprep-mcp if you prefer a local pip install.
Edit config file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"cwprep": {
"command": "uvx",
"args": ["--from", "cwprep[mcp]", "cwprep-mcp"]
}
}
}Settings → MCP → Add new MCP server, or edit ~/.cursor/mcp.json:
{
"mcpServers": {
"cwprep": {
"command": "uvx",
"args": ["--from", "cwprep[mcp]", "cwprep-mcp"]
}
}
}Create .vscode/mcp.json in project root:
{
"servers": {
"cwprep": {
"command": "uvx",
"args": ["--from", "cwprep[mcp]", "cwprep-mcp"]
}
}
}Edit ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"cwprep": {
"command": "uvx",
"args": ["--from", "cwprep[mcp]", "cwprep-mcp"]
}
}
}claude mcp add cwprep -- uvx --from "cwprep[mcp]" cwprep-mcpEdit ~/.gemini/settings.json:
{
"mcpServers": {
"cwprep": {
"command": "uvx",
"args": ["--from", "cwprep[mcp]", "cwprep-mcp"]
}
}
}Edit ~/.continue/config.yaml:
mcpServers:
- name: cwprep
command: uvx
args:
- --from
- cwprep[mcp]
- cwprep-mcpStart the server:
cwprep-mcp --transport streamable-http --port 8000Then configure your client with the endpoint: http://your-server-ip:8000/mcp
Available MCP Capabilities
Type | Name | Description |
🔧 Tool |
| Generate .tfl/.tflx file from flow definition |
🔧 Tool |
| Translate flow definition or .tfl file to ANSI SQL |
🔧 Tool |
| List all supported node types |
🔧 Tool |
| Validate flow definition before generating |
📖 Resource |
| SDK API reference |
📖 Resource |
| Tableau Prep calculation syntax |
📖 Resource |
| Common pitfalls and flow design rules |
💬 Prompt |
| Interactive flow design assistant |
💬 Prompt |
| TFL file structure explanation |
AI Skill Support
This project includes a specialized AI Skill for assistants like Claude or Gemini to help you build flows.
Location:
.agents/skills/tfl-generator/Features: MCP server index with fallback SDK usage guide. Detailed API and syntax references are served via MCP Resources from
src/cwprep/references/.
Directory Structure
cwprep/
├── .agents/skills/ # AI Agent skills (MCP index)
├── src/cwprep/ # SDK source code
│ ├── builder.py # TFLBuilder class
│ ├── packager.py # TFLPackager class
│ ├── translator.py # SQLTranslator class
│ ├── expression_translator.py # ExpressionTranslator class
│ ├── config.py # Configuration utilities
│ ├── mcp_server.py # MCP Server (Tools, Resources, Prompts)
│ └── references/ # MCP Resource documents (.md)
├── examples/ # Demo scripts
├── docs/ # Documentation
└── tests/ # Unit testsConfiguration
Create config.yaml for default settings:
# MySQL (default)
database:
host: localhost
port: 3306
dbname: mydb
type: mysql
# SQL Server (Windows Authentication)
# database:
# host: localhost
# type: sqlserver
# authentication: sspi
# schema: dbo
# PostgreSQL
# database:
# host: localhost
# port: 5432
# dbname: mydb
# type: postgres
tableau_server:
url: http://your-server
default_project: DefaultChangelog
See changelog.md for version history.
License
AGPL-3.0 License
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.