x402scan MCP Tools

Connect an agent or researcher team to x402scan for wallet inspection and paid API access.

Connect to the x402scan MCP server to inspect a wallet, discover endpoints, and make paid API requests.

x402scan_mcp_tools.py
"""
x402scan MCP Tools
==================
Give your agent money. Agents pay for APIs autonomously using USDC on Base.
Access 100+ paid data sources: enrichment, scraping, maps, social media, media generation.

Installation: npx @x402scan/mcp install
Documentation: https://x402scan.com/mcp

First run auto-generates a wallet at ~/.x402scan-mcp/wallet.json.
Fund with USDC on Base to start using paid APIs.
"""

import asyncio

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.team import Team
from agno.tools.mcp import MCPTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


async def run_agent(message: str) -> None:
    async with MCPTools("npx -y @x402scan/mcp@latest") as x402:
        agent = Agent(
            model=Claude(id="claude-sonnet-4-20250514"),
            tools=[x402],
            markdown=True,
        )
        await agent.aprint_response(message, stream=True)


async def run_team(message: str) -> None:
    async with MCPTools("npx -y @x402scan/mcp@latest") as x402:
        researcher = Agent(
            model=Claude(id="claude-sonnet-4-20250514"),
            tools=[x402],
            name="Researcher",
            role="Data Researcher",
            instructions=(
                "Gather data from paid APIs.\n"
                "Check balance before spending.\n"
                "Stay under $2 per task."
            ),
        )
        analyst = Agent(
            model=Claude(id="claude-sonnet-4-20250514"),
            name="Analyst",
            role="Data Analyst",
            instructions="Analyze data from the researcher. Create summaries and recommendations.",
        )
        team = Team(
            members=[researcher, analyst],
            instructions="Researcher gathers paid data, Analyst synthesizes findings.",
        )
        await team.aprint_response(message, stream=True)


# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    # Onboarding: wallet setup and API discovery
    asyncio.run(run_agent("Show me my wallet info and available APIs"))

    # People enrichment (Apollo)
    # asyncio.run(run_agent("Find information about the CEO of Anthropic"))

    # Web scraping (Firecrawl)
    # asyncio.run(run_agent("Scrape the content of https://docs.agno.com/introduction"))

    # Search (Exa)
    # asyncio.run(run_agent("Search for recent AI agent framework comparisons"))

    # Google Maps
    # asyncio.run(run_agent("Find coffee shops near Times Square, New York"))

    # Social media (Grok/Twitter)
    # asyncio.run(run_agent("Search Twitter for recent posts about AI agents"))

    # Multi-agent team: researcher + analyst sharing a wallet
    # asyncio.run(run_team("Research VC funding trends in AI agents over the past 6 months"))

The active request inspects wallet information and API availability; the paid examples and team are commented out. Only the researcher has MCP tools. The team coordinator uses the default OpenAI model, which is why the setup includes both provider keys.

For a wallet-only first run, use MCPTools("npx -y @x402scan/mcp@0.3.1", include_tools=["get_wallet_info"]) inside run_agent and ask only for wallet information. This pins the inspected npm version. The server creates a wallet under ~/.x402scan-mcp on first start; Agno does not manage its keys. Use the server’s current endpoint-discovery results rather than assuming every named API is available.

The researcher’s “Stay under $2” instruction is model guidance, not an enforced spending limit. Enable payment tools only with a wallet and spending controls appropriate for your application. Select a supported Claude model ID from your provider account before running the historical model configurations.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U "agno[mcp]" anthropic openai

Prepare Node.js

The MCP server runs with npx. Install Node.js 20 or newer, then verify the commands:

node --version
npx --version

Export your API keys

export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

Save the code above as x402scan_mcp_tools.py, then run:

python x402scan_mcp_tools.py

Full source: cookbook/91_tools/x402scan_mcp_tools.py