PyMC Marketing MCP
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| MARKETING_MCP_API_KEY | No | API key required when the security profile is set to 'http-private-api-key'. | |
| MARKETING_MCP_INGEST_DIR | No | Directory where ingested datasets are stored. | |
| MARKETING_MCP_METADATA_DB | No | Path to the SQLite database for metadata, jobs, and credentials. | |
| MARKETING_MCP_ARTIFACT_DIR | No | Directory where model artifacts are stored. | |
| MARKETING_MCP_MAX_DATASET_MB | No | Maximum allowed dataset size in megabytes. | |
| MARKETING_MCP_SHARED_SQL_URL | No | Connection URL for the shared SQL database when using the shared_sql backend. | |
| MARKETING_MCP_SECURITY_PROFILE | No | Security profile to use (e.g., 'http-private-api-key', 'http-production-oauth'). | |
| MARKETING_MCP_PERSISTENCE_BACKEND | No | Persistence backend to use (e.g., 'sqlite' or 'shared_sql'). |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Bayesian marketing science server (media mix modeling, budget decisions, lift calibration, customer lifetime value) backed by PyMC-Marketing. Operating rules:
Start every task with get_skill_guidance(task=<the user's request>). It routes to one workflow skill and returns its guidance inline: tool order, argument templates, gates, error recovery, and how to explain results to marketers. Follow it.
Check existing state before creating new work: list_datasets, list_jobs, get_model_status. The server keeps datasets, models, and jobs across sessions.
Every model-dependent number (contributions, iROAS, response, allocations, CLV, diagnostics) must come from a tool result. Never estimate them yourself.
diagnose_mmm must approve a model before get_incremental_roas, simulate_budget, optimize_budget, or optimize_flighting. A rejected model gets no budget answer.
Remote clients: send data as content, content_base64, or a public url; path means a file on the server. Use submit_*_job tools with an idempotency_key for fits, cross-validation, and prior sensitivity, and poll at most three times in a row.
Keep every warning, interval, and caution status in the answer. Keep user budget constraints exactly; report conflicts instead of relaxing them. Shared references: get_skill_guidance(reference_name='agent-operating-protocol') and get_skill_guidance(reference_name='marketing-decision-playbook').
Toolset guidance:
Datasets: register_dataset -> inspect_dataset -> validate_dataset before modeling.
Modeling: prefer submit_fit_mmm_job for async MCMC fits; inspect with get_model_status.
Diagnostics: run diagnose_mmm and verify approval before any budget decision.
Decisions: keep user budget constraints exact and surface all caution/interval caveats.
CLV: fit purchase and value models before predicting customer lifetime value or churn.
Jobs: pass idempotency_key on submit_*_job and poll at most 3 consecutive times with poll_job_progress.
Skills: call discover_tools or get_skill_guidance(task=...) to route workflows.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| fit_purchase_modelB | Fit a Bayesian purchase/transaction frequency model (BG/NBD or Shifted Beta-Geometric). Normalizes user column names to canonical RFM attributes. |
| fit_value_modelA | Fit a Bayesian monetary value transaction model (Gamma-Gamma) on repeat customer spending. Requires frequency and average monetary value columns. |
| predict_expected_purchasesA | Predict expected future purchase counts per customer from a fitted purchase model (BG/NBD). |
| predict_probability_aliveB | Estimate probability of customer retention/alive from a fitted purchase or churn model. |
| predict_expected_spendA | Predict average transaction monetary spend per customer from a fitted Gamma-Gamma value model. |
| estimate_customer_lifetime_valueB | Estimate discounted net present Customer Lifetime Value (CLV) by combining a fitted purchase model (e.g. BG/NBD) and monetary value model (e.g. Gamma-Gamma). |
| fit_clv_modelA | Fit a Bayesian Customer Lifetime Value (CLV) model on RFM transaction data. (Deprecated: prefer fit_purchase_model or fit_value_model). |
| predict_customer_clvA | Generate per-customer CLV predictions from a fitted BG/NBD model. (Deprecated: prefer predict_expected_purchases or estimate_customer_lifetime_value). |
| get_churn_risk_cohortsA | Identify customers at churn risk from a fitted CLV model. Returns customers whose Bayesian P(alive) is below the specified threshold. Lower threshold = higher confidence of churn. Default threshold: 0.3. |
| fit_bass_modelC | Fit a Bayesian Bass diffusion model on product adoption/sales counts over time to estimate innovation (p), imitation (q), market potential (m), and peak adoption. |
| predict_bass_adoptionB | Forecast incremental and cumulative product adoption over a future horizon from a fitted Bass diffusion model. |
| analyze_interrupted_time_seriesC | Estimate Bayesian Multivariate Interrupted Time Series (MVITS) causal impact and counterfactuals for a product launch, campaign, or pricing intervention. |
| compare_modelsB | Compare diagnostics, predictive metrics, and lineage across multiple fitted MMMs. |
| select_best_modelA | Compare multiple fitted MMMs using PSIS-LOO, WAIC, or Bayesian stacking weights via ArviZ. All models must be fitted on the same dataset. Returns ranked specifications, LOO/WAIC scores, and recommended model ID. Methods: loo (PSIS-LOO), waic (WAIC), stacking (BMA weights), all (run all three). |
| get_channel_contributionsB | Return posterior channel contribution summaries from the fitted PyMC-Marketing model. Does not fabricate estimates. |
| get_incremental_roasB | Return total and marginal iROAS from PyMC-Marketing's official incrementality API, including posterior uncertainty. No ad-hoc LLM ROAS calculation. |
| get_response_curvesB | Return response/saturation information sampled by PyMC-Marketing rather than raw posterior arrays. |
| simulate_budgetC | Evaluate the exact requested channel or dimension-cell scenario with posterior response sampling. Rejected models are blocked. |
| optimize_budgetB | Use PyMC-Marketing budget optimization under channel or dimension-cell constraints, then compare baseline and recommended posterior responses. Requires a diagnosed model. |
| recommend_next_measurementB | Recommend evidence-gathering options when model/data signals imply material uncertainty. It can explicitly return that no single experiment is implied. |
| optimize_flightingA | Optimize a dynamic weekly media flighting schedule over a planning horizon, accounting for adstock carryover dynamics, channel spend constraints, target iROAS floors, and profit-maximization objectives. The model must be approved or approved_with_caution before optimization. Returns a week-by-week spend table per channel, posterior response distribution, and net-profit estimates. |
| predict_mmmA | Generate out-of-sample posterior predictive forecasts on an approved MMM for future media spend and control schedules. Rejected models are blocked. |
| fit_mmmB | Fit a real Bayesian Marketing Mix Model with PyMC-Marketing using typed, controlled configuration. No arbitrary Python is accepted. Supports adstock types: geometric (default), delayed, weibull_cdf, weibull_pdf, binomial, none. Supports saturation types: logistic (default), tanh, tanh_baselined, michaelis_menten, hill, hill_sigmoid, inverse_scaled_logistic, log, root, none. Per-channel adstock/saturation overrides can be set via channel_priors. |
| get_model_statusB | Get persisted model fit state, lineage, and safe failure information. |
| diagnose_mmmA | Mandatory diagnostic gate. Checks sampler health plus posterior predictive coverage, predictive error, and residual behavior before decision tools may run. |
| cross_validate_mmmB | Run rolling Time-Slice Cross-Validation with PyMC-Marketing. Evaluates out-of-sample predictive RMSE/NRMSE across multiple temporal folds. |
| evaluate_prior_sensitivityC | Evaluate sensitivity of commercial conclusions (channel rank order and iROAS) under alternative adstock and saturation priors. |
| calibrate_mmmB | Calibrate an existing MMM using experimental lift test measurements. Produces a new calibrated model artifact linked via lineage. |
| archive_modelC | Archive a model record and update its lifecycle state. |
| get_posterior_plotsA | Generate posterior visualization plots from a fitted and approved MMM. Returns bounded plot metadata and authorized MCP resource URIs, including format and SHA-256. Retrieve the image bytes from each returned URI. Supported plot types: saturation_curves, waterfall_decomposition, actual_vs_predicted, channel_contribution_share. |
| register_datasetA | Register a marketing dataset for MMM or CLV analysis and return a stable dataset reference. For chat sessions (Claude.ai, web clients), pass raw CSV text directly in 'content' with 'filename'. Supports binary/parquet in 'content_base64', remote download in 'url', or server paths in 'path'. |
| list_datasetsB | List datasets in the active tenant; trusted local stdio can also list server inbox files. |
| inspect_datasetB | Inspect a registered dataset before MMM configuration. Returns candidate targets, channels, controls, frequency, and data issues. |
| validate_datasetB | Run MMM-specific data quality, panel-shape, and identifiability checks. This must pass before fitting. |
| transform_ad_exportC | Transform raw long-form advertising exports (e.g. from Google Ads, Meta Ads, LinkedIn) into a clean, wide-format modeling dataset. Pivots channel spend, enforces ratio non-summation invariants (CTR, CPA, ROAS recomputed from numerators/denominators), ensures calendar continuity, and generates cryptographic provenance with financial reconciliation. |
| submit_fit_mmm_jobC | Submit an asynchronous MMM fitting job that executes in the background without blocking. |
| submit_transform_ad_export_jobC | Submit an asynchronous job to transform raw long-form advertising exports into wide-form modeling format without blocking. |
| submit_budget_optimization_jobC | Submit an asynchronous budget optimization job under channel/cell constraints without blocking the event loop. |
| submit_flighting_optimization_jobB | Submit an asynchronous dynamic media flighting optimization job over a planning horizon. |
| submit_cross_validate_mmm_jobB | Submit an asynchronous Time-Slice Cross-Validation job across multiple temporal folds. |
| submit_prior_sensitivity_jobC | Submit an asynchronous prior sensitivity evaluation job exploring channel rank order stability. |
| get_job_statusB | Retrieve the execution status, results, or error details of an asynchronous job. |
| poll_job_progressC | Non-blocking heartbeat poll waiting up to timeout_seconds for progress to avoid AI client timeout collapses. |
| recover_execution_stateB | Recover execution state and intermediate checkpoints after an unexpected disconnect or restart. |
| resume_jobB | Resume an interrupted or failed job from its last valid checkpoint without repeating completed work. |
| cancel_jobB | Cancel a currently queued or running background job. |
| list_jobsB | List recent asynchronous background jobs for the active tenant. |
| export_artifact_to_sandboxB | Push/stage a model or dataset artifact (up to 1GB) for the AI client sandbox to download, providing streaming URLs, curl commands, python snippets, and SHA256 integrity checksums. |
| cleanup_server_storageB | Collect aged, unreferenced artifacts within the authorized namespace; expire download leases without deleting live references. |
| record_agent_insightB | Record structured findings, hypotheses, diagnostic warnings, anomalies, or budget decisions to persistent institutional memory for subsequent coding agents and runs. |
| get_agent_insightsB | Retrieve previously recorded agent insights, hypotheses, diagnostic notes, or decisions, filter by model, dataset, category, or tag. |
| create_viz_specB | Create and validate a declarative, renderer-agnostic visualization dashboard spec referencing registered datasets or fitted MMM models. Persists a compact handle (e.g. 'viz:1') and returns LTTB-downsampled series and Unicode sparklines. |
| query_viz_specB | Evaluate a visualization spec ('viz:' handle or encoded_spec) with optional viewport zoom ranges and cross-filter SelectionState predicates. Supports 'update' and 'overlay' cross-filter modes and optionally records a new handle revision. |
| read_viz_stateA | Read back the active InteractionState (zoomed viewports, brushed ClauseFilter predicates, cross_filter_mode, revision) and filtered row counts for a 'viz:' handle or encoded_spec without transferring raw dataset rows or screenshots. |
| get_skill_guidanceA | Start here. Route a marketing-science task to one workflow skill and receive its full operating guidance inline (tool order, argument templates, gates, error recovery, and marketing interpretation). Pass task for routing, skill_name to fetch a named skill, or reference_name to fetch a shared reference such as 'agent-operating-protocol' or 'marketing-decision-playbook' when the client cannot read MCP resources. |
| list_agentic_skillsA | List all registered agentic skills with summaries, maturity, triggers, and primary tools. |
| get_skill_workflow_mapB | Retrieve the dependency graph, prerequisites, decision gates, and continuations for all scientific skills. |
| discover_toolsB | Search active MCP tools by intent, domain, or parameter name. Respects active read-only and toolset filters. |
| get_server_instructionsA | Return the active MCP server operating manual, including mode, toolset, and read-only policies. |
| get_server_configA | Inspect active server configuration, enabled domains, operating modes, response limits, and per-tool token usage telemetry. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| skill_catalog | Compact scientific workflow skill catalog. Load one selected skill lazily. |
| skill_tool_map | Coverage classification for every public MCP tool. |
| skill_workflow_map | Prerequisites, gates, fallbacks, and continuations for scientific skills. |
| skill_decision_gates | Decision-gated operations derived from the capability registry. |
| scientific_answer_contract | Shared analytical answer and uncertainty communication contract. |
| scientific_source_ledger | Authoritative-source ledger for Skill Pack scientific rules. |
| agent_operating_protocol | How an agent operates this server: bootstrap, envelopes, IDs, jobs, polling, error recovery. |
| marketing_decision_playbook | Translate marketing questions into server workflows and results into decision-ready language. |
TDQS
Scored across 60 tools
Most tools target a distinct model lifecycle stage, and the async submit_*_job variants are explicitly marked as non-blocking counterparts to their sync tools. However several genuine overlaps remain: compare_models vs select_best_model both compare multiple fitted MMMs, get_job_status/poll_job_progress/list_jobs/recover_execution_state blur together, and the deprecated fit_clv_model/predict_customer_clv still sit alongside their successors (fit_purchase_model, estimate_customer_lifetime_value). An agent must read descriptions carefully to route correctly.
Nearly everything follows a snake_case verb_noun convention (fit_mmm, predict_mmm, get_channel_contributions, list_datasets, register_dataset, cancel_job). Minor deviation: the async mirror tools use inconsistent stems (submit_fit_mmm_job vs submit_budget_optimization_job vs submit_cross_validate_mmm_job), so the sync/async pairing is not mechanically derivable from the name.
60 tools is far beyond what a coherent surface needs, driven partly by duplication: six async submit_*_job wrappers shadowing existing sync tools, two deprecated CLV tools, and four job-state tools. The domain is broad (MMM, CLV, diffusion, ITS, budget optimization, viz, skills), but pruning duplicates would materially improve discoverability.
Coverage is unusually thorough end-to-end: ingest/register/validate/transform data, fit, diagnose, cross-validate, calibrate, select, forecast, optimize budget and flighting, visualize, export artifacts, and manage jobs and insights. Remaining gaps are modest — no dataset/model delete or update tools, and no explicit list_models to enumerate fitted artifacts before compare_models.