PyMC Marketing MCP

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.

Category
Visit Server

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_mmm evaluates out-of-sample predictive accuracy across temporal folds with PyMC-Marketing's TimeSliceCrossValidator.
  • Prior Sensitivity Analysis: evaluate_prior_sensitivity quantifies channel rank shifts under alternative adstock and saturation priors.
  • Lift Test Calibration: calibrate_mmm incorporates 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 h5netcdf and h5py
  • 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

  1. register_dataset
  2. inspect_dataset
  3. validate_dataset
  4. fit_mmm
  5. diagnose_mmm
  6. get_channel_contributions
  7. get_incremental_roas
  8. get_response_curves
  9. simulate_budget
  10. optimize_budget
  11. cross_validate_mmm
  12. evaluate_prior_sensitivity
  13. calibrate_mmm
  14. compare_models
  15. archive_model
  16. 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured