Skip to main content

Web Search Tools

Web search tools enable agents to find information online, scrape web content, and access knowledge repositories like Wikipedia and arXiv. Search the web using multiple providers (Google Custom Search or Brave Search).
query
string
required
Search query (1-500 characters)
num_results
integer
default:"10"
Number of results to return (1-20 for Brave, 1-10 for Google)
country
string
default:"us"
Country code for localized results (us, uk, de, etc.)
language
string
default:"en"
Language code for results (en, es, fr, etc.) - Google only
provider
string
default:"auto"
Search provider: “auto”, “google”, or “brave”
result = web_search(
    query="FastMCP tutorial",
    num_results=10
)

for item in result["results"]:
    print(f"{item['title']}: {item['url']}")
    print(item['snippet'])

print(f"Provider used: {result['provider']}")

Configuration

Set up credentials for your preferred provider:
When provider="auto", the tool tries Brave first for backward compatibility, then falls back to Google.

Web Scraping

web_scrape

Scrape and extract content from web pages.
url
string
required
URL to scrape
extract_text
boolean
default:"true"
Extract clean text content
Extract all links from the page
extract_metadata
boolean
default:"false"
Extract meta tags and page metadata
Example
result = web_scrape(
    url="https://example.com/article",
    extract_text=True,
    extract_links=True,
    extract_metadata=True
)

if result["success"]:
    print(f"Title: {result['metadata']['title']}")
    print(f"Text length: {len(result['text'])} chars")
    print(f"Links found: {len(result['links'])}")
Respect robots.txt and website terms of service when scraping. Add appropriate delays between requests.

Wikipedia

search_wikipedia

Search Wikipedia for pages and summaries.
query
string
required
Search query
limit
integer
default:"5"
Maximum number of results (1-10)
language
string
default:"en"
Wikipedia language edition (en, es, fr, de, etc.)
result = search_wikipedia(
    query="Artificial Intelligence",
    limit=3,
    language="en"
)

for page in result["results"]:
    print(f"{page['title']}")
    print(page['summary'])
    print(f"URL: {page['url']}\n")

Academic Papers

search_papers

Search arXiv for scientific papers.
query
string
required
Search query
max_results
integer
default:"10"
Maximum papers to return (1-100)
sort_by
string
default:"relevance"
Sort order: “relevance”, “lastUpdatedDate”, or “submittedDate”
Example
result = search_papers(
    query="large language models",
    max_results=5,
    sort_by="submittedDate"
)

for paper in result["papers"]:
    print(f"{paper['title']}")
    print(f"Authors: {', '.join(paper['authors'])}")
    print(f"Published: {paper['published']}")
    print(f"arXiv ID: {paper['arxiv_id']}\n")

download_paper

Download a PDF from arXiv.
result = download_paper(
    arxiv_id="2301.00001",
    output_path="papers/"
)

if result["success"]:
    print(f"Downloaded to: {result['file_path']}")
    print(f"Size: {result['size_bytes']} bytes")

Scholarly Search (SerpAPI)

Search Google Scholar for academic papers.
Requires SerpAPI credentials: SERPAPI_API_KEY
result = scholar_search(
    query="machine learning",
    num_results=10
)

for paper in result["results"]:
    print(f"{paper['title']}")
    print(f"Citations: {paper['cited_by']}")
    print(f"Authors: {paper['authors']}")

scholar_get_citations

Get citations for a specific paper.
result = scholar_get_citations(
    paper_id="12345678",
    num_results=20
)

scholar_get_author

Get author profile and publications.
result = scholar_get_author(author_id="ABC123")

print(f"Name: {result['name']}")
print(f"Affiliation: {result['affiliation']}")
print(f"H-index: {result['h_index']}")

Patent Search (SerpAPI)

Search for patents using SerpAPI.
result = patents_search(
    query="artificial intelligence",
    country="US",
    num_results=10
)

for patent in result["results"]:
    print(f"{patent['title']}")
    print(f"Patent Number: {patent['patent_number']}")
    print(f"Filed: {patent['filing_date']}")

patents_get_details

Get detailed information about a specific patent.
result = patents_get_details(patent_id="US1234567")

Semantic Search (Exa)

Perform semantic search using Exa AI.
Requires Exa API key: EXA_API_KEY
query
string
required
Natural language search query
num_results
integer
default:"10"
Number of results (1-100)
type
string
default:"auto"
Search type: “auto”, “keyword”, or “neural”
Example
result = exa_search(
    query="best practices for AI agent development",
    num_results=5,
    type="neural"
)

for item in result["results"]:
    print(f"{item['title']}")
    print(f"Relevance: {item['score']}")
    print(f"URL: {item['url']}\n")

exa_answer

Get direct answers to questions using Exa.
result = exa_answer(
    query="What is the Model Context Protocol?"
)

print(result["answer"])
print(f"Sources: {len(result['sources'])}")

exa_find_similar

Find pages similar to a given URL.
result = exa_find_similar(
    url="https://example.com/article",
    num_results=10
)

exa_get_contents

Retrieve full content for a list of URLs.
urls = [
    "https://example.com/page1",
    "https://example.com/page2"
]

result = exa_get_contents(urls=urls)

for content in result["contents"]:
    print(f"{content['url']}")
    print(content['text'][:200])
Search for news articles.
query
string
required
Search query
language
string
default:"en"
Language code
country
string
default:"us"
Country code
from_date
string
Start date (YYYY-MM-DD)
to_date
string
End date (YYYY-MM-DD)
Example
result = news_search(
    query="artificial intelligence",
    language="en",
    country="us",
    from_date="2024-01-01"
)

for article in result["articles"]:
    print(f"{article['title']}")
    print(f"Source: {article['source']}")
    print(f"Published: {article['published_at']}")

news_headlines

Get top headlines by category.
result = news_headlines(
    category="technology",
    country="us",
    language="en"
)

news_by_company

Get news articles about a specific company.
result = news_by_company(
    company="Tesla",
    num_results=20
)

news_sentiment

Analyze sentiment of news articles.
result = news_sentiment(
    query="OpenAI",
    num_results=50
)

print(f"Positive: {result['positive']}%")
print(f"Negative: {result['negative']}%")
print(f"Neutral: {result['neutral']}%")

Rate Limits & Best Practices

Most search APIs have rate limits:
  • Brave Search: 1,000 queries/month (free tier)
  • Google Custom Search: 100 queries/day (free tier)
  • SerpAPI: Varies by plan
Implement exponential backoff on 429 errors.
Cache search results to avoid redundant API calls:
# Use save_data to cache results
result = web_search(query="...")
save_data(
    filename="search_cache.json",
    data=json.dumps(result),
    data_dir="/data/cache"
)
All search tools use 30-second timeouts. Handle timeout errors gracefully:
result = web_search(query="...")
if "error" in result and "timeout" in result["error"].lower():
    # Retry or use cached results
Use specific queries and filters to get relevant results:
  • Add date ranges for recent content
  • Specify language and country codes
  • Use boolean operators: AND, OR, NOT

Next Steps

Communication Tools

Email, Slack, Discord integration

Cloud APIs

Google services and GitHub

Build docs developers (and LLMs) love