How to Add Web Search to a Microsoft Agent Framework Agent (Free Tier, No API Key)
Microsoft Agent Framework is Microsoft's open-source framework for building agents and multi-agent workflows. It's the successor to AutoGen and Semantic Kernel's agent features, and the Python package is agent-framework. You give an Agent a chat client, some instructions and a list of tools, and it decides when to call them. What it doesn't have out of the box is a cheap, keyless way to reach the live web. This guide adds Microsoft Agent Framework web search with the framework's built-in MCPStdioTool and the AgentSearch MCP server.
Search works right away with no API key, no signup and no wallet. You get 25 free searches per IP in total, then pay per call. The 25 is a lifetime allowance and it never resets. When the agent needs a whole page, it gets clean markdown back, with a small free daily trial (5 extracts and 3 renders a day per IP) and pay-per-call pricing after that.
You'll build:
- An
MCPStdioToolthat startsnpx -y @agentsearchhq/agentsearch-mcpover stdio. - A tool allow-list, so the model only sees search, extract and render.
- A full
Agentthat searches and reads pages. - A search-then-read script with no model in the loop.
- An optional paid setup with a hard budget.
What we actually ran (November 27, 2026): agent-framework 1.26.0 (with agent-framework-core 1.26.0, agent-framework-openai 1.18.2 and mcp 2.3.0) and @agentsearchhq/agentsearch-mcp 1.8.7 on Python 3.13 and Node 24. We connected MCPStdioTool, listed and filtered the tools, built the Agent with the filtered tool, and ran the search-then-read script below exactly as printed (two real free searches and one free-trial extract in total). We did not run a live model call. That step sends your prompt to the model provider, so it needs your own model key (for example OPENAI_API_KEY).
What the agent gets (and what it costs)
The AgentSearch MCP server exposes eight tools. For a research agent, three matter:
| Tool | What it does | Cost |
|---|---|---|
agentsearch_web_search |
Live web search, up to 5 results with title, URL and snippet | 25 free searches per IP in total (never resets), then $0.003 per call over x402 |
agentsearch_extract |
Any public URL as clean markdown | Free trial: 5 a day per IP, then $0.002 per call |
agentsearch_render |
Reads JavaScript-heavy pages that plain extract can't | Free trial: 3 a day per IP, then pay per call (see /render) |
There's no account and no API key at any tier, and no minimum spend. Paid calls use x402: the API answers with a 402 and a price, the MCP server signs a small USDC payment on Base, and you're only charged when a usable answer comes back. More on the Search and Extract pages.
Step 1: Install Agent Framework
python -m venv .venv && source .venv/bin/activate
pip install "agent-framework==1.26.0"
Agent Framework needs Python 3.11 or newer. The agent-framework meta-package pulls in the core package, the OpenAI client and the mcp SDK, so MCPStdioTool works without extra installs. If you want a smaller footprint, install agent-framework-core plus mcp and the one provider package you use (for example agent-framework-openai).
You also need Node.js 20 or newer, because the MCP server runs with npx.
Step 2: Connect the AgentSearch MCP server
MCPStdioTool takes a command and a separate args list, and starts the server as a stdio subprocess. Use it as an async context manager so the subprocess is cleaned up when you're done:
import asyncio
from agent_framework import MCPStdioTool
async def main():
async with MCPStdioTool(
name="agentsearch",
command="npx",
args=["-y", "@agentsearchhq/agentsearch-mcp"],
request_timeout=60,
) as web:
print(sorted(f.name for f in web.functions))
asyncio.run(main())
When we ran this, it printed all eight tools:
['agentsearch_extract', 'agentsearch_news_search', 'agentsearch_render',
'agentsearch_review_lookup', 'agentsearch_review_submit', 'agentsearch_screenshot',
'agentsearch_search_and_read', 'agentsearch_web_search']
name is required and labels the server in logs and traces. request_timeout is in seconds. The default is 30, and a generous value gives npx room on the first run, when it downloads the package. Unlike some frameworks, command is just the executable. Put the package name in args, not in the command string.
Step 3: Give the agent only the right tools
Eight tools is more than a research agent needs, and every tool description goes into the model's context. allowed_tools keeps only the ones you name:
WEB_TOOLS = ["agentsearch_web_search", "agentsearch_extract", "agentsearch_render"]
async with MCPStdioTool(
name="agentsearch",
command="npx",
args=["-y", "@agentsearchhq/agentsearch-mcp"],
allowed_tools=WEB_TOOLS,
request_timeout=60,
) as web:
print(sorted(f.name for f in web.functions))
# ['agentsearch_extract', 'agentsearch_render', 'agentsearch_web_search']
Names must match the server's exactly, and they all start with agentsearch_. An empty list ([]) exposes no tools at all, so leave allowed_tools out (or set it to None) if you want everything. There's also approval_mode="always_require" if you want a human to approve each tool call.
Step 4: A full Agent Framework agent with web search
Pass the connected tool straight into Agent(tools=...):
import asyncio
from agent_framework import Agent, MCPStdioTool
from agent_framework.openai import OpenAIChatClient
WEB_TOOLS = ["agentsearch_web_search", "agentsearch_extract", "agentsearch_render"]
async def main():
async with MCPStdioTool(
name="agentsearch",
command="npx",
args=["-y", "@agentsearchhq/agentsearch-mcp"],
allowed_tools=WEB_TOOLS,
request_timeout=60,
) as web:
agent = Agent(
client=OpenAIChatClient(model="gpt-5.4-mini"), # reads OPENAI_API_KEY
name="researcher",
instructions=(
"Use agentsearch_web_search for anything recent or factual. "
"If a snippet isn't enough, read the page with agentsearch_extract. "
"Use agentsearch_render only when extract comes back empty. "
"Cite the URLs you used."
),
tools=web,
)
result = await agent.run(
"What changed in the latest Microsoft Agent Framework release? Cite sources."
)
print(result.text)
asyncio.run(main())
Each MCP tool becomes an Agent Framework FunctionTool with the server's own name, description and JSON schema, so the model sees the same arguments the server documents (query, max_results, freshness, include_domains and more for search; url and max_chars for extract). Keep the agent inside the async with block: once the block exits, the MCP subprocess is gone.
We built this exact agent and confirmed it holds the three allowed tools. The agent.run call is the part we didn't run. It needs your model key, and any Agent Framework chat client that supports tool calling (Azure OpenAI, Foundry, Anthropic, Ollama and others) works in place of OpenAIChatClient.
Search, then read: no model in the loop
Sometimes you don't want a model deciding anything. You just want the top hit for a query, as markdown. MCPStdioTool.call_tool calls a tool directly. It returns a list of Content items, and the first item's text is the tool's JSON:
import asyncio, json
from agent_framework import MCPStdioTool
async def search_then_read(query: str) -> str:
async with MCPStdioTool(
name="agentsearch",
command="npx",
args=["-y", "@agentsearchhq/agentsearch-mcp"],
allowed_tools=["agentsearch_web_search", "agentsearch_extract"],
request_timeout=60,
) as web:
hits = await web.call_tool(
"agentsearch_web_search", query=query, max_results=3
)
results = json.loads(hits[0].text)["results"]
top_url = results[0]["url"]
page = await web.call_tool(
"agentsearch_extract", url=top_url, max_chars=4000
)
return json.loads(page[0].text)["markdown"]
print(asyncio.run(search_then_read("microsoft agent framework python MCPStdioTool"))[:500])
This is the part we ran end to end. The search for "microsoft agent framework python MCPStdioTool" came back with three results. The top one was the agent_framework.MCPStdioTool reference page on Microsoft Learn, and the extract call returned that page's title and markdown. Each result also has title, content, domain and published_date, so you can pick a URL by domain instead of the first.
One gotcha we hit: call_tool does not return a plain string. Calling json.loads(hits) raises TypeError: the JSON object must be str ... not list. Use hits[0].text.
You only pay to read the page you picked. If you'd rather get hits and page text in a single call, the server also has agentsearch_search_and_read ($0.005 per paid call). Add it to allowed_tools if you want it.
When to use Render for JavaScript pages
agentsearch_extract fetches the page HTML and turns it into markdown. That covers docs, blogs, READMEs and most articles. Single-page apps, dashboards and some pricing pages ship an empty shell and fill it in with JavaScript, so extract comes back with little or no text.
That's what agentsearch_render is for. It loads the page in a real browser, waits for the content, and returns the rendered markdown. It's slower, so the Step 4 instructions only use it when extract comes back empty. You get 3 free renders a day per IP without a wallet. After that it's pay per call. See Render for details.
Going past the free tier: pay per call with x402
When the 25 free searches are used up, add a wallet. Use a new, dedicated wallet holding a few dollars of USDC on Base, never your main one. The MCP server reads these environment variables:
| Variable | What it does |
|---|---|
AGENTSEARCH_WALLET_PRIVATE_KEY |
Key of the dedicated wallet. Turns on paid extract and render. |
AGENTSEARCH_MODE=paid |
Also makes search paid ($0.003 per call). A wallet key alone keeps search on the free tier. |
AGENTSEARCH_MAX_TOTAL_ATOMIC |
Spend cap per server session in USDC atomic units (default 1000000, which is $1.00). |
AGENTSEARCH_MAX_PER_CALL_ATOMIC |
Optional lower cap per call. |
One detail: MCPStdioTool uses the MCP SDK's stdio client, which does not forward your whole shell environment to the server. It starts from a minimal safe set (HOME, PATH, USER and a few others) and merges in whatever you pass as env. So pass the wallet variables explicitly:
import os
from agent_framework import MCPStdioTool
web = MCPStdioTool(
name="agentsearch",
command="npx",
args=["-y", "@agentsearchhq/agentsearch-mcp"],
allowed_tools=["agentsearch_web_search", "agentsearch_extract", "agentsearch_render"],
env={
"AGENTSEARCH_WALLET_PRIVATE_KEY": os.environ["AGENTSEARCH_WALLET_PRIVATE_KEY"],
"AGENTSEARCH_MODE": "paid",
"AGENTSEARCH_MAX_TOTAL_ATOMIC": "200000", # $0.20 hard cap per session
},
request_timeout=60,
)
Live prices on November 27, 2026: search $0.003, news $0.003, extract $0.002, search-and-read $0.005, all paid in USDC over x402 on Base. No signup, no API key, no minimums. Calls are only charged when a usable answer comes back. We checked the variable names against the package README. We didn't run a paid call for this post.
Troubleshooting
TypeError: the JSON object must be str ... not list. call_tool returns a list of Content items. Parse result[0].text, not the list.
The agent has no tools. Check the names in allowed_tools against Step 2's output. A name that doesn't match is simply left out, and [] exposes nothing.
npx: not found. Install Node.js 20+ and make sure it's on the PATH your Python process sees.
Timeouts on the first run. npx downloads the package the first time. Raise request_timeout, or install it globally (npm i -g @agentsearchhq/agentsearch-mcp) and use command="agentsearch-mcp" with no args.
MCPDeprecationWarning: ping is removed. We saw this warning on connect with mcp 2.3.0. It's harmless; the tools load and run normally.
HTTP 429 from search, extract or render. You've used the free allowance: the 25 lifetime searches for your IP, or the daily extract (5) and render (3) trial. Add a wallet as shown above to keep going.
Wallet set but search still free. That's expected. Search only switches to paid with AGENTSEARCH_MODE=paid. Also check you passed the variables through env=, because they aren't forwarded automatically.
FAQ
Does Microsoft Agent Framework web search need an API key?
Not with this setup. The AgentSearch MCP server gives you 25 free searches per IP in total with no key, account or wallet, then you pay per call over x402.
Does this work with Azure OpenAI or other models?
Yes. The MCP tool doesn't care which model drives the agent. Swap OpenAIChatClient for any Agent Framework chat client that supports tool calling, such as Azure OpenAI, Foundry, Anthropic or Ollama.
Related guides
- How to add web search to an Agno agent
- How to add web search to a Pydantic AI agent
- How to add web search to an OpenAI Agents SDK agent
Get started
pip install "agent-framework==1.26.0"
Then point MCPStdioTool at npx -y @agentsearchhq/agentsearch-mcp, allow the three web tools, and hand it to your Agent. You get 25 free searches per IP in total with no key, then $0.003 per paid search.
More from the blog
- How to Add Web Search to an Agno Agent (Free Tier, No API Key)
- How to Add Web Search to a Pydantic AI Agent (Free, No API Key)
- How to Add Web Search to an OpenAI Agents SDK Agent (No API Key)
Service pages: Web Search API · Web Extract API · Web Render API