AI Agent Payments with MCP Integration
TL;DR: T402's MCP server (@t402/mcp) gives AI agents the ability to discover paid APIs, authorize payments, and access resources — all through standard Model Context Protocol tool calls. Agents can autonomously pay for weather data, compute, or any T402-protected service.
Why AI Agents Need Payments
As AI agents become more autonomous, they need to interact with the real economy. An agent researching a topic might need premium data. An agent completing a task might need compute resources. An agent booking travel might need to make purchases.
Today, this requires human intervention at every payment step. T402's MCP integration changes that — agents can discover what services cost, decide if the value is worth the price, and pay autonomously within budget constraints.
The Model Context Protocol
MCP (Model Context Protocol) is a standard for giving AI models access to external tools and resources. It defines a JSON-RPC interface where models can:
- Discover tools: Learn what capabilities are available
- Call tools: Execute actions with structured parameters
- Read resources: Access data sources
T402 extends MCP with payment capabilities. When a tool requires payment, the agent receives a 402-equivalent response with payment requirements, signs an authorization, and retries — all within the MCP tool call lifecycle.
How T402 + MCP Works
sequenceDiagram
participant Agent as AI Agent
participant MCP as MCP Server
participant API as Paid API
Agent->>MCP: tools/call { tool: "weather" }
MCP->>API: GET /weather
API-->>MCP: 402 + accepts
MCP-->>Agent: PaymentRequired { accepts: [...] }
Agent->>MCP: tools/call { tool: "t402_pay" }
Note right of Agent: amount: "10000"<br/>network: "eip155:8453"
MCP->>API: GET + X-Payment
API-->>MCP: 200 + data
MCP-->>Agent: { temperature: 22 }
The MCP server exposes T402 payment as a tool. When the agent encounters a 402 response, it can autonomously decide to pay based on its budget constraints and task requirements.
MCP Tools Provided
The @t402/mcp server exposes these tools to AI agents:
t402_fetch
Fetch a URL with automatic 402 payment handling. Discovers payment requirements, signs authorization, and returns the resource.
t402_check_price
Check what a URL costs without paying. Returns payment requirements so the agent can decide before committing.
t402_balance
Check the agent’s wallet balance across supported networks. Helps agents budget their spending.
t402_history
View recent payment history. Enables agents to track spending and avoid duplicate payments.
Budget Controls
Autonomous payments require guardrails. T402's MCP server supports configurable budget controls:
- Per-request limit: Maximum amount the agent can spend on a single request
- Session budget: Total spending cap for the current session
- Domain allowlist: Restrict which domains the agent can pay
- Network preference: Preferred chains for payment (cost optimization)
- Approval mode: Require human approval above a threshold
// MCP server configuration
{
"budget": {
"perRequest": "0.10",
"sessionTotal": "5.00",
"approvalThreshold": "1.00"
}
}
Use Cases
Research Agents
Agents that gather data from premium APIs (weather, financial, scientific) and pay per query.
Code Generation
Agents that use paid compute services for testing, compilation, or deployment.
Content Creation
Agents that purchase stock images, music, or reference materials for creative work.
Agent-to-Agent
Agents that hire other agents for specialized subtasks, creating an AI service economy.
Bazaar: Service Discovery for Agents
T402's Bazaar extension enables agents to discover paid services programmatically. Instead of hardcoding API endpoints, agents can query the Bazaar registry to find services that match their needs:
// Agent discovers available paid weather APIs
const services = await bazaar.search({
category: 'weather',
maxPrice: '0.01',
network: 'eip155:8453'
});
This creates an open marketplace where service providers register their APIs and agents discover them based on price, capability, and reliability. No API key management, no billing accounts — just sign and pay.
Build AI-Powered Payments
Add the T402 MCP server to your AI agent stack and enable autonomous payments.