Skip to content

Feature: agentpay-mcp — payment tool for LlamaIndex agents (x402, human-approval, spend caps) #21214

@up2itnow0822

Description

@up2itnow0822

What's missing

LlamaIndex agents can call APIs, query databases, and orchestrate complex workflows — but there's no standard way for them to handle payments. If your agent needs to call a paid API, trigger an invoice, or make a micropayment mid-workflow, you're writing custom code from scratch every time.

The proposal

Add agentpay-mcp as a supported MCP tool in LlamaIndex's tool integrations.

agentpay-mcp is an open-source MCP server that gives agents a pay tool for the x402 protocol (HTTP 402 Payment Required). It's MIT licensed, has 149 tests passing, and was recently merged into NVIDIA's NeMo-Agent-Toolkit-Examples: NVIDIA/NeMo-Agent-Toolkit-Examples#17

Key behaviors:

  • Human-approval mode: agent requests payment, human approves before funds move
  • On-chain spend caps: hard limits enforced by smart contract, not just config
  • Audit trail: every payment logged with agent ID, tool call, amount, timestamp
  • Non-custodial: you hold your own keys

What it looks like in practice

from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

# Connect agentpay-mcp server
mcp_client = BasicMCPClient("npx agentpay-mcp")
mcp_tool_spec = McpToolSpec(client=mcp_client)

tools = mcp_tool_spec.to_tool_list()
# Agent now has access to: pay, get_balance, list_transactions

Agent can then pay for premium API calls, trigger usage-based billing, or handle service-to-service payments — all without leaving the LlamaIndex workflow.

Why this matters for LlamaIndex specifically

A lot of LlamaIndex use cases touch paid services: document processing APIs, specialized data providers, SaaS integrations. Right now, payment handling is either ignored (dev pays manually out-of-band) or bolted on with custom code. A standard MCP payment tool makes this composable.

Existing MCP infrastructure

LlamaIndex already has solid MCP support via llama-index-tools-mcp. This would slot in naturally alongside existing MCP tool integrations — no new abstractions needed.

References

Happy to help draft documentation or example notebooks if this direction is interesting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions