All jobs

Which Upcoming Shows Are Selling Slower Than Usual? A Ticketing Platform's Monday Check of Its PlanetScale Database

A ticketing platform for small venues has an agent compare each upcoming show's sales with that venue's past shows every Monday and list the ones falling behind.

Run this on RushOpens the console with this prompt ready to send. Connect PlanetScale there first.

What the agent does

This is for a company that runs a ticketing platform for small venues: community theatres, comedy clubs, a jazz bar, a folk club that books touring acts. Its own web app keeps everything in a MySQL database on PlanetScale, with tables for venues, events, ticket types and orders. A venue usually learns that a show is selling badly ten days out, too late for a newsletter or a two-for-one offer. The platform's account managers want to call those venues earlier, but they cannot read every venue's sales every week. An agent compares each show in the next three weeks with how that same venue's past shows had sold at the same point, and lists the ones falling behind.

The platform's head of operations connects PlanetScale once with POST /me/connections {"type": "mcp", "name": "planetscale", "url": "https://mcp.pscale.dev/mcp/planetscale", "auth": {"mode": "oauth"}} and signs in on PlanetScale's page. PlanetScale's docs say the sign-in chooses no access, read-only access or full access per organization or per database, so they grant read-only access to the production database alone. An organization administrator can also set MCP query access to read-only queries in the organization's settings, so nobody can later grant write queries to an MCP client.

On a run the agent calls planetscale_get_branch_schema on the main branch to read the real table and column names, then runs planetscale_execute_read_query with SELECT statements only. PlanetScale's docs say that tool runs SELECT, SHOW, DESCRIBE and EXPLAIN, sends reads to a replica by default when the branch has one, and marks each query with a source=planetscale-mcp comment so the engineering team can find it in Insights. It reads every event in the next 21 days with its venue, capacity and tickets sold so far, leaving out comps and refunded orders, and for each venue, the shows of the past year with how many tickets each had sold at the same number of days before the show.

A show is behind when its share of capacity sold is less than two thirds of the median for that venue's past shows at the same point, and the venue has at least five past shows to compare with. For each one it names the venue, the show, the date, capacity, tickets sold, the venue's usual share at this point and the gap in tickets, and reads the last seven days of orders to say whether sales have stopped or are only slow. Venues with too few past shows are listed separately rather than judged. It never writes to the database.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Monday slow-sales check. Today: 2026-11-23. Shows from 2026-11-24 to 2026-12-14. Use the planetscale connection, read only, database stagedoor-prod, branch main. 1) planetscale_get_branch_schema; tell me the tables and columns you used for venues, events, capacity, ticket types, orders, order status and comp tickets. 2) With planetscale_execute_read_query (SELECT only): for each upcoming show, venue, start time, capacity and paid tickets sold so far (exclude comps, refunded and cancelled orders), and paid tickets sold in the last 7 days. 3) For each venue with upcoming shows: its past shows from the last 365 days, and for each the share of capacity sold at the same number of days before the show as the upcoming show is now. 4) Behind: share sold now < 2/3 of the venue's median past share at that point, and the venue has 5 or more past shows. 5) Write slow-shows.md: behind shows sorted by date, each with venue, show, date, capacity, sold, sold in last 7 days, the venue's usual share at this point, and how many more tickets would bring it to the median; then venues with fewer than 5 past shows in one list; then a one-line count of shows on track. Never run INSERT, UPDATE, DELETE or DDL. Include no buyer names or emails.",
  "connections": [
    "planetscale"
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

slow-shows.md lists each show selling behind its venue's usual pace, with tickets sold, the usual count by now, and the gap. It comes back among the session's files, with a summary in the session's result that also names the columns the agent used. Each entry also says whether anything sold in the last week. Venues without enough history are listed apart, so a new venue's first show is not called a failure.

What the account manager checks before calling a venue: that the show is not one the venue deliberately sells late, like a festival night or a show with most tickets sold on the door; that its capacity is right, since a seated show set up with the standing capacity looks permanently behind; and the columns the agent named on the first run. What to suggest to the venue, a mailing, an offer or nothing, is the account manager's call.

Run it on every Monday morning

In the console, a Project automation with a schedule trigger, cron 0 8 * * 1 and the team's timezone, runs a saved agent whose connections name planetscale and whose instructions hold the rules above. A schedule fills in no date, so the instructions say "today" and "the next 21 days" and the agent works out the dates on each run.

In the busy weeks before the holidays, the head of operations can add a Thursday schedule to the same automation, so venues with weekend shows hear from their account manager before the weekend rather than after it.

The use case this job follows, with its automation and trigger: Produce a report or file, no repo.

Why run it on Rush?

The PlanetScale sign-in is held in Rush's connection with read-only access to one database, and PlanetScale's docs say each query runs with short-lived credentials created for it and deleted after, so no database password sits in a reporting script. Nobody on the engineering team has to build and maintain an internal sales dashboard for account managers.

Each Monday's run has its own computer and a record of every SQL statement it ran and every result it read, so when a venue asks why they got a call, the account manager can show the numbers. The session's total_cost_usd shows what each week's check costs.

Frequently asked questions

Why compare with the venue's own past shows?

A comedy club that sells out a week ahead and a folk club that sells half its tickets on the night have very different normal curves. Comparing each show with the same venue at the same number of days out flags what is unusual for that venue.

Does the query load the production database?

PlanetScale's docs say read queries from the MCP server go to a replica by default when the branch has one, so the check does not compete with ticket sales on the primary. On a branch with no replica they run on the primary, so schedule it outside the hours when big shows go on sale.

Can the agent email the venues itself?

This page keeps that with the account managers. They know which venues welcome a call about sales and which would rather not hear it, so the agent gives them the list and the numbers.

More PlanetScale jobs

More jobs like this: Produce a report or file, no repo

Keep reading