PyMC Marketing MCP
Provides a controlled interface for Bayesian Marketing Mix Modeling, letting AI agents validate datasets, fit and diagnose MMMs, analyze channel contributions and ROI, simulate and optimize budgets, calibrate with lift tests, and cross-validate models—all with statistical verification, uncertainty reporting, and full provenance.
README
PyMC Marketing MCP
LLMs can explain marketing data. They should not invent marketing science.
PyMC Marketing MCP gives MCP-compatible agents a controlled interface to Bayesian Marketing Mix Modeling with PyMC-Marketing. It handles dataset checks, MMM fitting, diagnostic gating, posterior contribution analysis, total and marginal iROAS, counterfactual spend scenarios, and constrained budget allocation while keeping the statistical computation inside PyMC-Marketing.
The core boundary is simple: the agent frames the business question and explains evidence. PyMC-Marketing computes the statistical quantities. The MCP layer validates inputs, persists artifacts, applies decision gates, reports uncertainty, and records provenance.
User question
-> AI agent
-> MCP tool
-> dataset / model validation
-> PyMC-Marketing
-> posterior evidence
-> decision gate
-> structured result + uncertainty + provenance
-> AI explanation
Version 0.3.0 Release
Version 0.3.0 delivers comprehensive Bayesian statistical verification, model lineage, lift test calibration, cross-validation, and multi-core accelerated testing:
- Time-Slice Cross-Validation:
cross_validate_mmmevaluates out-of-sample predictive accuracy across temporal folds with PyMC-Marketing'sTimeSliceCrossValidator. - Prior Sensitivity Analysis:
evaluate_prior_sensitivityquantifies channel rank shifts under alternative adstock and saturation priors. - Lift Test Calibration:
calibrate_mmmincorporates real or synthetic experimental incrementality lift tests directly into model likelihood with full lineage tracking. - Extrapolation Risk Guard: Spend scenarios or optimization allocations exceeding 1.5x historical 95th percentile spend automatically trigger actionable warnings.
- Multi-Core Accelerated Testing: Pytest suite runs concurrently via
pytest-xdist, completing 46 unit, integration, and full Bayesian sampling tests in ~50 seconds. - Official MCP 2.0.0 Transports: Fully tested stdio and Streamable HTTP clients with dynamic port discovery and structured error envelopes.
See docs/DECISION-INTEGRITY.md and docs/VERIFICATION-MATRIX.md for details.
Current compatibility
- Python 3.12 to 3.13
- PyMC-Marketing
>=1.0.0 - PyMC
>=6.0.0 - ArviZ
>=0.21,<2.0 - Official MCP Python SDK v2 (
mcp>=2.0.0) - NetCDF4 storage via
h5netcdfandh5py - CSV and Parquet datasets
- SQLite metadata and NetCDF model artifacts for local deployment
Install
uv sync --extra dev
uv run pytest -n auto -v
Run with stdio
uv run marketing-mcp --transport stdio
Run with Streamable HTTP
uv run marketing-mcp --transport streamable-http --host 127.0.0.1 --port 8000
# endpoint: http://127.0.0.1:8000/mcp
Docker
docker compose up --build
Core flow
register_datasetinspect_datasetvalidate_datasetfit_mmmdiagnose_mmmget_channel_contributionsget_incremental_roasget_response_curvessimulate_budgetoptimize_budgetcross_validate_mmmevaluate_prior_sensitivitycalibrate_mmmcompare_modelsarchive_model- Explain the posterior result, diagnostics, assumptions, and provenance
Synthetic demo
uv run marketing-mcp-demo --fast
Repository map
src/marketing_mcp/
mcp/ protocol tools + resources
services/ application workflows (modeling, dataset, decision, diagnostics)
domain/ validation, diagnostics engine & gate, allocation & extrapolation
adapters/ PyMC-Marketing 1.0.0 boundary
storage/ SQLite metadata + NetCDF artifacts
schemas/ typed Pydantic contracts
tests/
statistical/ real NUTS sampling, panel MMM, calibration, cross-validation
integration/ MCP stdio/HTTP protocol, persistence lifecycle
unit/ domain logic, failure datasets, security guardrails
docs/ architecture, contracts, safety, security, verification matrix
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.