DEV Community

Cover image for Give your LangChain agent live web search and real-time news
nestdaddy
nestdaddy

Posted on Edited on Originally published at nestdaddy.com

Give your LangChain agent live web search and real-time news

A LangChain agent is only as current as the model behind it. Ask about something that happened this morning and the model either says it does not know or, worse, guesses with confidence.

The fix is to give the agent tools that reach today's internet. This guide uses langchain-nestdaddy, a LangChain integration for NestDaddy's own search index and real-time news collection, to add:

Class What it gives the agent
NestDaddySearch Web search: title, url, snippet and domain of each result
NestDaddyNewsSearch Real-time news by key words, with an optional country and time window
NestDaddyReadPage The clean main text of any page or article, without menus or ads
NestDaddyNewsRetriever News as LangChain Documents for RAG, optionally with the full article text

Everything below was run against the live API with LangChain 1.5.

Install

pip install -U langchain langchain-nestdaddy
export NESTDADDY_API_KEY="your-key"
Enter fullscreen mode Exit fullscreen mode

Get a key from the NestDaddy MCP page (the Free plan gives 1,000 calls a month, no card). The same key works for the REST API, the MCP server and this package.

Try the tools on their own

from langchain_nestdaddy import NestDaddyNewsSearch, NestDaddySearch

NestDaddySearch(max_results=2).invoke({"query": "model context protocol"})
Enter fullscreen mode Exit fullscreen mode
{
  "query": "model context protocol",
  "count": 2,
  "results": [
    {"title": "Roadmap - Model Context Protocol",
     "url": "https://modelcontextprotocol.io/development/roadmap",
     "snippet": "Our plans for evolving Model Context Protocol",
     "domain": "modelcontextprotocol.io", "type": "web"},
    {"title": "Model Context Protocol",
     "url": "https://en.wikipedia.org/wiki/Model_Context_Protocol",
     "snippet": "Protocol for communicating between LLMs and applications: The Model Context Protocol (MCP) is an open standard...",
     "domain": "en.wikipedia.org", "type": "wiki"}
  ]
}
Enter fullscreen mode Exit fullscreen mode

News works the same way. Keep the query to a few key words, the way a headline would say it:

NestDaddyNewsSearch(max_results=3, days=2).invoke({"query": "ChatGPT Wallet"})
Enter fullscreen mode Exit fullscreen mode

That returned, a few hours after the announcement:

2026-11-13 23:06  cryptobriefing.com  OpenAI introduces ChatGPT wallet for Pro subscribers
2026-11-13 23:00  cnbc.com            OpenAI launches ChatGPT Wallet, allowing its 'dots' AI agents to make purchases for users
2026-11-13 23:48  investing.com       OpenAI launches ChatGPT Wallet, letting AI agents pay for purchases
Enter fullscreen mode Exit fullscreen mode

Add "country": "US" (or GB, IN, SG, ID and others) to limit news to one country. Local news works in the local language, for example {"query": "banjir Jakarta", "country": "ID"}.

Give an agent live search and news

from langchain.agents import create_agent
from langchain_nestdaddy import NestDaddyNewsSearch, NestDaddyReadPage, NestDaddySearch

agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=[NestDaddySearch(max_results=5), NestDaddyNewsSearch(days=7), NestDaddyReadPage()],
    system_prompt=(
        "Use news search for anything recent, web search for everything else. "
        "Read a page in full before you explain its details, and cite the urls you used."
    ),
)

result = agent.invoke({"messages": [{"role": "user", "content": "What did OpenAI announce this week?"}]})
print(result["messages"][-1].content)
Enter fullscreen mode Exit fullscreen mode

Any chat model with tool calling works: swap the model string for OpenAI, Gemini, a local model through Ollama, and so on.

The system prompt matters more than it looks. Without it, many models never call a tool for "this week" questions, because they do not know their knowledge is out of date. One routing line ("news for recent, web for everything else") fixes most of those answers.

RAG over today's news

When you want documents rather than a tool-calling loop, use the retriever:

from langchain_nestdaddy import NestDaddyNewsRetriever

retriever = NestDaddyNewsRetriever(k=3, days=2, full_text=True)
docs = retriever.invoke("ChatGPT Wallet")

for d in docs:
    print(d.metadata["source_domain"], d.metadata["full_text"], len(d.page_content))
Enter fullscreen mode Exit fullscreen mode
cryptobriefing.com  True   2611
cnbc.com            True   4328
investing.com       False  67
Enter fullscreen mode Exit fullscreen mode

With full_text=True each article is read in full (one extra API call per article). The third article could not be read as clean text, so the retriever kept its summary instead of dropping it: you still get k documents, and metadata["full_text"] tells you which ones are complete.

Feed docs into any LangChain chain or prompt as context. Because every document carries its url and published_timestamp, the model can cite sources and say how fresh they are.

Async

Every tool and the retriever support ainvoke. The retriever reads full articles in parallel:

docs = await NestDaddyNewsRetriever(k=5, full_text=True).ainvoke("AI regulation")
Enter fullscreen mode Exit fullscreen mode

Errors you might see

API errors raise NestDaddyAPIError with the HTTP status and a hint: a bad key points you to the dashboard, a plan limit to the plans page. The key is stored as a SecretStr, so it never shows up in logs or reprs.

Prefer MCP?

If you use Claude, Cursor, VS Code or n8n instead of LangChain, the same tools are available as one remote MCP server. Setup for each client is on the NestDaddy MCP page.

Links


Originally published on the NestDaddy blog. NestDaddy gives your AI today's internet: live web search and real-time breaking news from its own index. nestdaddy.com/mcp


Building AI agents or MCP servers? Join **Agent Builders, our Discord community: daily MCP news, alerts when MCP servers change their tools, and help from our team. Join on Discord

Top comments (0)