Skip to main content
Glama
PyMC Marketing MCP

PyMC Marketing MCP

by funnelscript

Optimize Flighting

optimize_flighting
Read-onlyIdempotent

Optimize weekly media flighting schedules across channels and weeks to maximize response or net profit while honoring adstock carryover, budget limits, target iROAS floors, and per-channel spend constraints.

Instructions

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.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "config": "<config>"
    },
    "name": "optimize_flighting"
  }
}

Input Schema

NameRequiredDescriptionDefault
configYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changed
    • removedInput schema / $defs
      Removed value: -{
      -  "FlightingOptimizationInput": {
      -    "properties": {
      -      "channel_constraints": {
      -        "description": "Per-channel weekly spend floor/cap and pattern constraints",
      -        "items": {
      -          "$ref": "#/$defs/WeeklyFlightingConstraint"
      -        },
      -        "title": "Channel Constraints",
      -        "type": "array"
      -      },
      -      "margin_pct": {
      -        "default": 1,
      -        "description": "Revenue margin fraction for net-profit objective (revenue × margin − spend)",
      -        "maximum": 1,
      -        "minimum": 0,
      -        "title": "Margin Pct",
      -        "type": "number"
      -      },
      -      "model_id": {
      -        "description": "Approved MMM model ID to use for response estimation",
      -        "title": "Model Id",
      -        "type": "string"
      -      },
      -      "objective": {
      -        "default": "maximize_response",
      -        "description": "Optimization objective function",
      -        "enum": [
      -          "maximize_response",
      -          "maximize_net_profit",
      -          "target_roas"
      -        ],
      -        "title": "Objective",
      -        "type": "string"
      -      },
      -      "planning_weeks": {
      -        "default": 12,
      -        "description": "Planning horizon in weeks",
      -        "maximum": 52,
      -        "minimum": 2,
      -        "title": "Planning Weeks",
      -        "type": "integer"
      -      },
      -      "target_iroas_min": {
      -        "anyOf": [
      -          {
      -            "minimum": 0,
      -            "type": "number"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Minimum acceptable posterior median iROAS across the planning period",
      -        "title": "Target Iroas Min"
      -      },
      -      "total_budget": {
      -        "description": "Total budget to allocate across all channels and weeks",
      -        "exclusiveMinimum": 0,
      -        "title": "Total Budget",
      -        "type": "number"
      -      }
      -    },
      -    "required": [
      -      "model_id",
      -      "total_budget"
      -    ],
      -    "title": "FlightingOptimizationInput",
      -    "type": "object"
      -  },
      -  "WeeklyFlightingConstraint": {
      -    "properties": {
      -      "channel": {
      -        "description": "Channel name this constraint applies to",
      -        "title": "Channel",
      -        "type": "string"
      -      },
      -      "max_weekly": {
      -        "anyOf": [
      -          {
      -            "minimum": 0,
      -            "type": "number"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Maximum weekly spend cap",
      -        "title": "Max Weekly"
      -      },
      -      "min_weekly": {
      -        "anyOf": [
      -          {
      -            "minimum": 0,
      -            "type": "number"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Minimum weekly spend floor",
      -        "title": "Min Weekly"
      -      },
      -      "pattern": {
      -        "default": "flat",
      -        "description": "Preferred spend pattern for this channel across the planning horizon",
      -        "enum": [
      -          "flat",
      -          "frontloaded",
      -          "backloaded",
      -          "pulsed"
      -        ],
      -        "title": "Pattern",
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "channel"
      -    ],
      -    "title": "WeeklyFlightingConstraint",
      -    "type": "object"
      -  }
      -}
    • addedInput schema / additionalProperties
      Added value: +false
    • removedInput schema / properties / config / $ref
      Removed value: -"#/$defs/FlightingOptimizationInput"
    • addedInput schema / properties / config / properties
      Added value: +{
      +  "channel_constraints": {
      +    "description": "Per-channel weekly spend floor/cap and pattern constraints",
      +    "items": {
      +      "properties": {
      +        "channel": {
      +          "description": "Channel name this constraint applies to",
      +          "title": "Channel",
      +          "type": "string"
      +        },
      +        "max_weekly": {
      +          "default": null,
      +          "description": "Maximum weekly spend cap",
      +          "title": "Max Weekly",
      +          "type": "number"
      +        },
      +        "min_weekly": {
      +          "default": null,
      +          "description": "Minimum weekly spend floor",
      +          "title": "Min Weekly",
      +          "type": "number"
      +        },
      +        "pattern": {
      +          "default": "flat",
      +          "description": "Preferred spend pattern for this channel across the planning horizon",
      +          "enum": [
      +            "flat",
      +            "frontloaded",
      +            "backloaded",
      +            "pulsed"
      +          ],
      +          "title": "Pattern",
      +          "type": "string"
      +        }
      +      },
      +      "required": [
      +        "channel"
      +      ],
      +      "title": "WeeklyFlightingConstraint",
      +      "type": "object"
      +    },
      +    "title": "Channel Constraints",
      +    "type": "array"
      +  },
      +  "financial": {
      +    "default": null,
      +    "description": "Canonical financial contract. When supplied, takes precedence over margin_pct.",
      +    "type": "object"
      +  },
      +  "margin_pct": {
      +    "default": 1,
      +    "description": "Legacy revenue margin fraction (use financial.gross_margin_rate for new work)",
      +    "maximum": 1,
      +    "minimum": 0,
      +    "title": "Margin Pct",
      +    "type": "number"
      +  },
      +  "model_id": {
      +    "description": "Approved MMM model ID to use for response estimation",
      +    "title": "Model Id",
      +    "type": "string"
      +  },
      +  "objective": {
      +    "default": "maximize_response",
      +    "description": "Optimization objective function",
      +    "enum": [
      +      "maximize_response",
      +      "maximize_net_profit",
      +      "target_roas"
      +    ],
      +    "title": "Objective",
      +    "type": "string"
      +  },
      +  "planning_weeks": {
      +    "default": 12,
      +    "description": "Planning horizon in weeks",
      +    "maximum": 52,
      +    "minimum": 2,
      +    "title": "Planning Weeks",
      +    "type": "integer"
      +  },
      +  "target_iroas_min": {
      +    "default": null,
      +    "description": "Minimum acceptable posterior median iROAS across the planning period",
      +    "title": "Target Iroas Min",
      +    "type": "number"
      +  },
      +  "total_budget": {
      +    "description": "Total budget to allocate across all channels and weeks",
      +    "exclusiveMinimum": 0,
      +    "title": "Total Budget",
      +    "type": "number"
      +  }
      +}
    • addedInput schema / properties / config / required
      Added value: +[
      +  "model_id",
      +  "total_budget"
      +]
    • addedInput schema / properties / config / title
      Added value: +"FlightingOptimizationInput"
    • addedInput schema / properties / config / type
      Added value: +"object"
  2. First observedv0.4.0

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover the safety profile (readOnlyHint=true, idempotent, non-destructive, closed-world), so the bar is lower. The description adds useful behavior beyond them: the model-approval gate and the shape of the result (week-by-week spend table, posterior response distribution, net-profit estimates). It does not say whether the call blocks synchronously or hands off to a job, nor any cost/runtime expectation for a multi-week optimization.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three dense sentences, front-loaded with the operation and followed by the prerequisite and the return contents. No filler, though the middle prerequisite sentence could be placed before the modeling detail for faster triage.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description correctly spends a sentence on return values and states the preconditions for a valid call. The remaining gap is orchestration-level: nothing tells the agent whether this is the direct-invocation path or whether the job-submission sibling is preferred for long horizons.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Top-level schema coverage is 0% — the single `config` parameter carries no description — but its nested fields are documented in the schema itself. The description adds meaning by mapping its narrative to nested settings (channel constraints, target_iroas_min, the planning horizon, the optimization objective), though it never explains how objective values interact with target_iroas_min or what the planning_weeks bounds imply.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Optimize a dynamic weekly media flighting schedule over a planning horizon') and enumerates the modeling elements it handles: adstock carryover, channel spend constraints, iROAS floors, profit maximization. It does not name a sibling to differentiate from, so an agent cannot tell from this text alone whether to use it instead of optimize_budget or submit_flighting_optimization_job.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives one concrete prerequisite ('The model must be approved or approved_with_caution before optimization'), which is genuine when-to-use guidance. It offers no exclusion or alternative routing, though, and the presence of a job-submission sibling makes the missing synchronous-vs-async guidance a real gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.