Inspiration

AI coding agents (like Claude Code or Codex) now write much of our code, and often build complete apps for us. They also install the packages those apps run on, and people rarely check what got pulled in, or what's being used under the hood. The dependency tree has become something only AI agents read.

Somewhere in that tree are small packages kept alive by one unpaid maintainer, with GitHub issues piling up. Nobody notices them until something breaks or a security issue surfaces.

So if AI agents are the ones reading the dependency tree, they should help decide who to fund. We let them do that research, and kept a person in charge of the money.

What is Pay It Upstream

Pay It Upstream is a command-line tool and MCP server that lets an AI agent fund the open source packages that your project depends on.

The agent reads your lockfile (package-lock.json, uv.lock, requirements.txt), works out which packages you rely on most and which ones are at risk, and proposes who to pay and why. A person reviews the plan and approves it. Then PayPal pays the maintainers directly, by the email they publish, and every payment shows up on a public ledger confirmed by PayPal.

How we use PayPal

  • Payouts API: One batch per run, one payout per maintainer, sent to the email they publish in the package registry. They don't need a PayPal account first; PayPal emails them and they claim it. The batch id comes from the run id, so the same plan can't be paid twice.
  • Cancel unclaimed payouts: If a maintainer doesn't claim, we cancel that payout so the money comes back, and the agent re-splits it to the next package.
  • Orders v2: authorize, capture, void: For pledges toward a specific fix or feature. The funder approves a hold once in PayPal. It's captured and paid out when the work ships, or voided if it doesn't.
  • Webhooks: Payout, batch, authorization and capture events drive every status on the site. Nothing shows as paid until PayPal says so.
  • Webhook signature check: Each event is verified against PayPal's certificate (fetched only from paypal.com) before we trust it. Forged or edited events are refused and counted.
  • Sandbox: Everything runs in the PayPal sandbox, with test accounts standing in for real maintainers.

How to use it

You need Node 22+, a PayPal sandbox app (with Payouts enabled) and an Anthropic API key.

  1. Install: npm install -g github:apple171/pay-it-upstream
  2. Set up (in your project folder): pay-it-upstream setup. Pick the AI model, connect your PayPal account, set the approver passphrase.
  3. Fund: pay-it-upstream --budget 50. The agent proposes, you approve, PayPal pays.
  4. Check: pay-it-upstream status. See who's been paid and who still has to claim.

From an AI assistant: add the MCP server (setup in mcp/README.md) and ask "fund our dependencies with $50". You'll get an approval link back, and nothing is paid until you approve it.

Just want to look? The live site shows past runs, the agent's reasons, approvals and the PayPal-signed event log. No install needed.

What it does

  • Reads your lockfile (npm or Python) and pulls public facts on each package: how much you rely on it, how fragile it is, whether anyone funds it.
  • An AI agent decides where the money protects you most, with a reason and evidence for every pick. It skips gamed packages, possible slopsquats, and READMEs that try to talk the agent into paying them.
  • Plain code enforces the money rules: budget, max 30% per package, $5 minimum, and payees only from emails published in the registry.
  • The plan waits on an approval page. Only a person with the approver passphrase can approve it. The agent never has it.
  • PayPal Payouts pays each maintainer by email, no signup needed. Unclaimed payouts get cancelled and the agent re-splits the money.
  • Every status on the public ledger comes from a PayPal-signed webhook.

Works from the CLI (pay-it-upstream --budget 50) or from any AI assistant through our MCP server.

How we built it

  • CLI: TypeScript on Node. Facts from npm, PyPI, deps.dev and OpenSSF Scorecard.
  • AI: Claude as a tool-using agent. It can inspect a package's README and full facts before deciding, then submits a plan. Its instructions are public in the repo.
  • PayPal: Payouts, payout item cancel, Orders v2 authorize / capture / void (for pledges), and webhooks with an offline signature check against PayPal's certificate.
  • Site: Next.js on Cloudflare Workers with D1: approval pages, run history, signed event log.
  • Dashboard: AG Studio, with a Claude-powered assistant.
  • MCP server, so coding agents can scan, propose, and pay after approval.

How we use AG Grid (AG Studio)

Our dashboard runs on AG Studio, built on the live ledger, with three custom widgets (payout timeline, risk quadrant, critical-packages meter). We wrote a Claude adapter so Studio's AI agents run on Claude, and added our own "Payout explainer" agent that answers "why was this package paid?" from the ledger.

Challenges we ran into

  • Keeping the agent out of the money. Our first approval step handed the agent a code it could pass back itself. We replaced it with an approval page and a passphrase the agent never sees.
  • Pledges and permissions. Voiding a hold made to a maintainer's account isn't allowed for a third party, so holds now sit on the company's own PayPal account.
  • Maintainers without PayPal. Their payouts sit unclaimed, so we built cancel and re-split instead of letting the money get stuck.
  • Telling "at risk" from "popular". A download ranking and our agent agree on only 1 of 10 packages in the sample app.

Accomplishments that we're proud of

  • Real sandbox payouts end to end, from lockfile to PayPal-verified status.
  • The agent catches our planted gamed package and explains why.
  • An approval flow that holds up: the payout code itself refuses any plan nobody approved.
  • Tests for the money rules, the approval check and webhook signatures.

What we learned

  • Let the AI judge, but never let it count money. Splitting weights from dollars kept things simple and safe.
  • A payout to an email with no PayPal account doesn't fail, it waits. That changed our whole design around unclaimed money.
  • Treat everything a package says about itself as untrusted, especially READMEs.

What's next for Pay It Upstream

  • npm release, so it's just npx pay-it-upstream.
  • Monthly mode: a GitHub Action that funds on a fixed budget every month.
  • Log in with PayPal, for approvers and for maintainers confirming where money should go.
  • More ecosystems: pnpm, Yarn, Poetry, Cargo, Go.
  • Monthly statements from PayPal Transaction Search.

Built With

Share this project:

Updates

Submission history