What the agent does
This is for a software agency that builds and runs web apps for its clients and hosts their databases in its own PlanetScale organization: a booking platform for a chain of physiotherapy clinics, a parts catalogue for a wholesaler, a members' area for a sports club. PlanetScale sends the agency one invoice a month; the agency passes each client their share at cost plus its hosting fee. Splitting that invoice by hand means matching every line to a database and every database to a client, and the staging branches nobody remembers make it worse. The agent does the split each month, from the invoice's own line items.
An organization admin 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 MCP docs let an organization admin set MCP query access to no query access, read-only or read and write for new sign-ins, and say billing and other non-query tools are not affected by that setting. Since this job reads only invoices, the admin sets no query access before connecting, so this sign-in can never run SQL against a client's data.
On a run the agent calls planetscale_list_organizations and planetscale_list_databases to see every database in the agency's organization, then planetscale_list_invoices to find last month's invoice and planetscale_get_invoice_line_items for it. PlanetScale describes those line items as prorated costs broken down by database branch, which is what makes a per-client split possible. The agent maps each database to a client using the table in the prompt, sums each client's branches, and puts any database the table does not name, and any line not tied to a branch, under Unassigned.
The agent changes nothing. The prompt forbids planetscale_execute_read_query, planetscale_execute_write_query and planetscale_update_payment_method along with every other tool that writes, so a run never touches a client's data or the agency's card. It does not draft the client invoices themselves: the split goes to the office manager, who adds the agency's fee in the accounting system.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Split our PlanetScale invoice for October 2026 by client. Use the planetscale connection. Call planetscale_list_organizations and planetscale_list_databases for our organization, then planetscale_list_invoices and planetscale_get_invoice_line_items for the October 2026 invoice. Clients by database: Kestrel Physio (kestrel-booking, kestrel-reports), Ashby Wholesale (ashby-catalogue), Fenwick Sports Club (fenwick-members). Sum each client's line items across all their branches, production and others, and list each branch's amount. Put lines for databases not in this list, and lines with no branch, under Unassigned. Write invoice-split-2026-10.csv (client, database, branch, description, amount) and invoice-split-2026-10.md with each client's total, the Unassigned lines, every database with no line this month, and a check that the client totals plus Unassigned equal the invoice total. Do not call planetscale_execute_read_query, planetscale_execute_write_query, planetscale_update_payment_method or any tool that changes PlanetScale. If an invoice tool is refused, stop and say so instead of estimating a split.",
"connections": [
"planetscale"
]
}- 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.
- 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.
- 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
The session returns invoice-split-2026-10.csv and a short Markdown summary as artifacts. The summary gives each client's total for the month, the branches it came from, the Unassigned lines with their databases, and a line confirming that the client totals plus Unassigned add up to the invoice. A database listed in the prompt with no line this month is named too, since that usually means it was deleted or moved.
What the office manager checks before rebilling: the Unassigned lines first (a new client's database not yet in the table, or the agency's own internal tools), that a large development branch charged to a client was work the client asked for, and that the totals match the invoice in PlanetScale's dashboard. The agency's fee and the client invoices are added in the accounting system after that.
Run it on every third of the month, after PlanetScale's invoice
The office manager saves the agent with POST /o/{org}/agents, naming the planetscale connection and the client table, and adds a console automation with a schedule trigger on the third of each month (0 8 3 * * in the agency's timezone), a couple of days after the invoice is normally issued. The saved instructions say "the most recent invoice", since a schedule fills nothing into the prompt.
When a client joins or leaves, the office manager edits the client table in the saved agent with PATCH /o/{org}/agents/{id}, and the next month's split uses 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 split needs a PlanetScale sign-in that can read the organization's invoices, and on Rush it stays in the agency's connection, set up with no query access, rather than in a service token on someone's laptop that could also read client databases. Each run reads PlanetScale as that sign-in and nothing more.
Each month's run has its own computer and a record of every PlanetScale call it made and what its model calls cost. When a client asks why their database line rose in October, the office manager can show the invoice line items the split came from, branch by branch.
Frequently asked questions
Why not use the Insights-only server?
PlanetScale publishes a second address, https://mcp.pscale.dev/mcp/planetscale-insights-only, that leaves out the two query tools. Rush lists the full server, so this page uses it with the organization's MCP query access set to none, which PlanetScale says applies to new sign-ins. An agency that prefers the other address can connect it as its own MCP server.
Does the sign-in need billing permissions?
PlanetScale's docs list payment-method access as a separate permission and do not say which role reads invoices. The person who connects should be someone who can see invoices in PlanetScale's dashboard. If the invoice tools are refused, the run stops and says so rather than guessing a split.
How are shared costs split?
This prompt does not split them. A line PlanetScale ties to no branch goes under Unassigned, and the office manager decides whether to absorb it or share it. An agency with a fixed rule, such as splitting by each client's share of the total, can write that rule into the saved instructions.
Will it notice a client database we forgot about?
Yes. Every database in the organization that the client table does not name appears under Unassigned with its cost, which is often how a forgotten staging database or an old prototype gets noticed.
More PlanetScale jobs
- How Many Subscribers Did We Gain and Lose This Week? A Meal-Kit Company's Monday Report From PlanetScale
- Which Orders Are Stuck Between Paid and Shipped? A Back-Office App's Morning Check of Each Marketplace's PlanetScale Database
- Which Upcoming Shows Are Selling Slower Than Usual? A Ticketing Platform's Monday Check of Its PlanetScale Database