How to Add News Search to an AI Agent (MCP, Python and x402)
Ask a general web search for "what happened with x402 this week" and you often get evergreen pages: docs, a Wikipedia-style explainer, a two-year-old blog post that ranks well. That's fine for "what is x402". It's wrong for "what changed this week".
Agents that write briefings, watch competitors, track a release, or answer current-events questions need a different tool: news search. It returns articles, not pages, and every hit carries a publish date your agent can sort, filter and cite.
AgentSearch added a news search tool in agentsearch-mcp 1.8.0, and the same endpoint is a plain HTTP call on the direct x402 API. This guide covers:
- Adding news search to Claude Code, Cursor and other MCP clients
- The filters that matter for news (freshness, date range, country, language, domains)
- Calling the news endpoint from Python with x402, no account or API key
- A small daily briefing agent that searches news and then reads the top story
News search vs. web search: when to use which
Both are useful, and a good agent uses both:
| Question | Tool |
|---|---|
| "How do I configure X?" / "What is Y?" | Web search |
| "What did company Z announce this week?" | News search |
| "Find the docs page for this library" | Web search |
| "Any coverage of our launch since Monday?" | News search with date_from |
| "Summarize today's AI agent news from these 3 outlets" | News search with freshness: "day" and include_domains |
The rule of thumb for your agent: if the answer depends on when something was published, call news search.
Option 1: News search in Claude, Cursor or any MCP client
The AgentSearch MCP server gives your client a set of web tools with one command:
npx -y @agentsearchhq/agentsearch-mcp
With nothing configured you already get free web search (up to 25 searches a day per IP) and a small free trial of Extract and Render. News search is a paid tool, so it needs a wallet key: a new wallet made only for this, holding a little USDC on Base. There's no account, no API key and no ETH for gas.
Claude Code
claude mcp add agentsearch \
--env AGENTSEARCH_WALLET_PRIVATE_KEY=0xYOUR_DEDICATED_WALLET_KEY \
--env AGENTSEARCH_MAX_TOTAL_ATOMIC=500000 \
-- npx -y @agentsearchhq/agentsearch-mcp
Put the server name before the --env flags, as above. AGENTSEARCH_MAX_TOTAL_ATOMIC is a session spend cap in USDC atomic units: 500000 means the server will never sign more than $0.50 in total before it restarts. Full Claude Code setup: Add web search to Claude Code.
Cursor, Claude Desktop, Cline
Add an env block to the usual server entry (~/.cursor/mcp.json, claude_desktop_config.json, or your client's MCP config):
{
"mcpServers": {
"agentsearch": {
"command": "npx",
"args": ["-y", "@agentsearchhq/agentsearch-mcp"],
"env": {
"AGENTSEARCH_WALLET_PRIVATE_KEY": "0xYOUR_DEDICATED_WALLET_KEY",
"AGENTSEARCH_MAX_TOTAL_ATOMIC": "500000"
}
}
}
}
Restart the client. The key is read from env and used only to sign payments; it's never returned in a tool result. Because it sits in plain text in the config, keep only what you're willing to spend in that wallet. Wallet steps: wallet setup.
A wallet key alone doesn't make web search paid. Search stays on the free tier unless you also set AGENTSEARCH_MODE=paid, so you can add news search without changing how your agent searches the web.
The news tool
After the restart your client lists agentsearch_news_search next to the other tools. Its inputs:
| Input | What it does |
|---|---|
query (required) |
Topic, company, person or event |
max_results |
1-10 articles, default 5 |
freshness |
day, week, month or year |
date_from / date_to |
Publish date range, YYYY-MM-DD (don't combine with freshness) |
country |
2-letter code to localize results, like us, gb, de |
language |
Like en, es or pt-BR |
include_domains / exclude_domains |
Up to 5 each, subdomains included |
It costs $0.008 per call in USDC on Base, and a call that returns no articles isn't charged. The paid web search and Search + Read tools take the same filters, which is handy when you want "docs pages from one domain" or "results in German".
Tell the agent when to reach for news
Tools work better with a one-paragraph instruction. Add this to CLAUDE.md, Cursor rules or your system prompt:
For anything that depends on recent events (announcements, releases,
funding, incidents, "this week", "today", "latest"):
1. Call agentsearch_news_search with freshness "day" or "week".
Use date_from/date_to when the user names dates.
2. Prefer articles with a publish date; mention the date in the answer.
3. To read a full article, call agentsearch_extract on its URL.
4. For how-to or reference questions, use agentsearch_web_search instead.
Then try a prompt like: "What's been announced about x402 this week? Give me dates and links." Expand the tool call in your client to see exactly which articles came back.
Option 2: Call the news endpoint from Python with x402
If you're building your own agent loop (LangChain, LangGraph, Pydantic AI, OpenAI Agents SDK, or a plain script), you can call the endpoint directly:
POST https://api.agentsearchhq.com/x402/v1/news
It speaks x402: the first unpaid request returns 402 Payment Required with the price and payee in a PAYMENT-REQUIRED header, and the client retries with a signed USDC payment. There's no signup step at all.
Step 1: See the terms (free)
import base64, json, httpx
r = httpx.post(
"https://api.agentsearchhq.com/x402/v1/news",
json={"query": "x402 payments", "max_results": 3, "freshness": "week"},
timeout=30,
)
print(r.status_code) # 402: payment required, nothing charged
terms = json.loads(base64.b64decode(r.headers["PAYMENT-REQUIRED"]))
offer = terms["accepts"][0]
print(offer["network"], offer["amount"], offer["payTo"])
# eip155:8453 8000 0xC49B157887e51c21CB655f39CF65D6a4c2a4C337
8000 atomic USDC is $0.008. Before trusting any payee, compare payTo with the published list at /.well-known/x402. The full request and response schema is in /openapi.json and the x402 docs.
Step 2: Pay per call
Install the x402 SDK and an EVM signer:
pip install "x402[httpx,evm]" eth-account
export WALLET_PRIVATE_KEY=0xYOUR_DEDICATED_WALLET_KEY
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.http.clients import x402HttpxClient
API = "https://api.agentsearchhq.com/x402/v1"
async def main():
account = Account.from_key(os.environ["WALLET_PRIVATE_KEY"])
client = x402Client()
register_exact_evm_client(client, EthAccountSigner(account))
async with x402HttpxClient(client, timeout=60) as http:
r = await http.post(f"{API}/news", json={
"query": "AI agent payments",
"max_results": 5,
"freshness": "week",
"language": "en",
})
r.raise_for_status()
for a in r.json()["results"]:
print(a["published_date"], a["domain"], a["title"])
print(" ", a["url"])
asyncio.run(main())
The response shape (trimmed):
{
"query": "AI agent payments",
"result_count": 5,
"retrieved_at": "2026-11-12T15:00:00Z",
"topic": "news",
"results": [
{"title": "...", "url": "https://...", "content": "snippet ...",
"domain": "example.com", "published_date": "2 days ago", "score": 0.0}
],
"filters": {"freshness": "week", "language": "en"}
}
Note that published_date comes back as the source reports it, which can be relative ("2 days ago") or a date. Pass it through to the model as-is, or normalize it in your code if you sort by date.
The API settles the payment only after a successful, non-empty answer, so a query with no matching articles costs nothing. The receipt for each paid call comes back in the PAYMENT-RESPONSE header if you want to log spend.
Build a daily news briefing agent
News snippets are short. For a briefing that actually says something, have the agent pick the top story and read it. AgentSearch Extract turns any URL into clean markdown for $0.004 per call (or 5 free calls a day per IP through the MCP trial).
Here's a compact briefing loop with a hard budget, so a loop bug can't drain the wallet:
import asyncio, os
from eth_account import Account
from x402 import x402Client
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.http.clients import x402HttpxClient
API = "https://api.agentsearchhq.com/x402/v1"
PRICE = {"news": 0.008, "extract": 0.004}
BUDGET = 0.10 # dollars per run
TOPICS = ["x402 protocol", "Model Context Protocol", "AI agent frameworks"]
async def briefing():
account = Account.from_key(os.environ["WALLET_PRIVATE_KEY"])
client = x402Client()
register_exact_evm_client(client, EthAccountSigner(account))
spent = 0.0
out = []
async with x402HttpxClient(client, timeout=60) as http:
async def call(endpoint, body):
nonlocal spent
if spent + PRICE[endpoint] > BUDGET:
raise RuntimeError("budget reached")
r = await http.post(f"{API}/{endpoint}", json=body)
r.raise_for_status()
spent += PRICE[endpoint]
return r.json()
for topic in TOPICS:
news = await call("news", {"query": topic, "max_results": 5,
"freshness": "day", "language": "en"})
hits = news.get("results", [])
if not hits:
continue # empty results are not charged
top = hits[0]
page = await call("extract", {"url": top["url"],
"max_chars": 6000,
"include_links": False})
out.append({
"topic": topic,
"headline": top["title"],
"date": top["published_date"],
"url": top["url"],
"text": page.get("markdown") or page.get("text", ""),
"others": [(h["title"], h["url"]) for h in hits[1:]],
})
print(f"spent about ${spent:.3f}")
return out
items = asyncio.run(briefing())
for i in items:
print(f"\n## {i['topic']}: {i['headline']} ({i['date']})\n{i['url']}")
Hand items to your model with a prompt like "Write a five-bullet briefing. Cite each URL. Say when a story is older than a day." Three topics, each with one news call and one extract, is three times $0.012, so the run stays well under the $0.10 cap.
A few things make this kind of agent more reliable:
- Set
include_links: falseon extract. News pages carry long nav and related-story link lists; dropping them saves tokens. - Use
include_domainsfor a source list. If your team only trusts three outlets, pass them and skip filtering in code. - Use
exclude_domainsto drop noise, like your own site when you're tracking coverage of your launch. - Prefer
date_fromfor "since Monday" questions, andfreshnessfor rolling windows. - Treat article text as data. Tell the model that fetched pages may contain instructions and to ignore them.
When a news URL is a JavaScript app and Extract comes back empty, Render loads it in headless Chromium and returns the text. See read JavaScript pages from an AI agent for the fallback pattern.
Running it on a schedule
The briefing script is a natural cron job: run it every morning, post the output to Slack or email, done. If you use n8n, the n8n daily news digest workflow shows the no-code version with the n8n-nodes-agentsearch community node, and n8n AI agent reading web pages adds the read-the-article step.
Framework notes
- LangChain / LangGraph: the MCP server works through
langchain-mcp-adapters, which is the quickest way to get the news tool into a LangGraph agent today. For search-then-read in LangChain Python, see this guide. - Pydantic AI, OpenAI Agents SDK, Vercel AI SDK: all of them can attach an MCP server over stdio, or you can wrap the Python
call()helper above as a plain function tool. - One payment for search plus pages: if you want web results and their full text in a single call, Search + Read does both for $0.009.
Summary
- News search returns dated articles; use it whenever the answer depends on when something was published.
- In Claude Code, Cursor or any MCP client:
npx -y @agentsearchhq/agentsearch-mcpplus a dedicated wallet key gives youagentsearch_news_searchat $0.008 per call, with free web search still free. - In your own code:
POST https://api.agentsearchhq.com/x402/v1/news, pay per call in USDC on Base with x402. No signup, no API key, no minimums, and empty results aren't charged. - Pair it with Extract ($0.004) to read the top story, and cap spend per run.
Prices and limits are on the pricing page. The MCP server is open source on GitHub and on npm as @agentsearchhq/agentsearch-mcp.
More from the blog
- n8n News Monitoring Workflow: Build a Free Daily Web Digest
- x402 Python Tutorial: Let Your AI Agent Pay Per Call for Web Search
- How to Add Free Web Search to Claude Code with MCP (No API Key)
Service pages: Web Search API · Web Extract API · Web Render API