Skip to content

[RFC] Agent-native payment gating for Tavily MCP — pay-per-call via x402/MPP #139

Description

@QuinnYates

What this proposes

Adding pay-per-call payment gating to `tavily-mcp` so AI agents can pay for searches directly — without requiring human billing accounts.

Tavily already charges for API access. This extends that model to agent-native payments: agents pay small amounts per call via x402 (USDC on Base) or MPP (Stripe's Machine Payments Protocol), with zero changes to the existing server logic.

Working demo

I've built a payment-gated fork: github.com/tomopay/tavily-mcp

It adds a single src/index-paid.ts entry point using @tomopay/gateway. The original src/index.ts is completely untouched — this is purely additive.

import { withPayments } from "@tomopay/gateway";

const { server: gatedServer } = withPayments(server, {
  payTo: process.env.TOMOPAY_ADDRESS,
  protocols: ["x402", "mpp"],
  pricing: {
    tavily_search:   { amount: 2, currency: "USD" },  // $0.02/search
    tavily_extract:  { amount: 3, currency: "USD" },  // $0.03/extract
    tavily_crawl:    { amount: 5, currency: "USD" },  // $0.05/crawl
    tavily_map:      { amount: 2, currency: "USD" },  // $0.02/map
    tavily_research: { amount: 10, currency: "USD" }, // $0.10/research
  },
});

Why this matters

  • Agents don't have credit cards. x402 and MPP let agents pay in USDC or via Stripe directly — no human in the loop, no API key sharing.
  • You already charge for API access. This is the natural extension to agent-native payment rails — every tool call has a clear dollar value.
  • Zero breaking changes. The existing server stays as-is. index-paid.ts is a separate entry point for operators who want to enable payments. Users on the free path see no difference.
  • Operators set their own wallet. Payments go directly to TOMOPAY_ADDRESS — no intermediary cut.

Pricing rationale

Tavily API costs roughly $0.004–$0.008 per search call at current rates. The defaults in the fork give operators a small margin while keeping prices in the micropayment range that makes sense for agents (sub-cent to $0.10 depending on operation cost). All prices are configurable per-operator.

Current status

The fork is working. Happy to clean it up as a PR if there's interest, or discuss what integration path works best for the Tavily team.

A few open questions:

  1. Interest? Would you consider merging this as an opt-in entry point (index-paid.ts) alongside the current free version?
  2. Pricing feedback — the defaults are a starting point. What makes sense given Tavily's API cost structure?
  3. Wallet — if you want to route payments to a Tavily-controlled address by default (rather than leaving it to operators), happy to configure that in the fork.

Open to adjusting anything based on your use case.


Built with @tomopay/gateway — the payment terminal for AI agent tools. Same approach also applied to exa-mcp-server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions