Skip to content
AgentSearch

How to Add Free Web Search to Semantic Kernel (Python) with MCP

Semantic Kernel is Microsoft's open-source SDK for wiring language models to your own code. In Python you build a Kernel, add plugins (groups of functions the model can call), and let a ChatCompletionAgent or a chat service decide when to call them. Plenty of production apps already run on it. What it doesn't come with is a cheap, keyless way to reach the live web. This guide adds Semantic Kernel web search with the SDK's built-in MCPStdioPlugin 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 of extract (5 a day per IP) and pay-per-call pricing after that.

Starting a brand-new agent project? Microsoft now positions Microsoft Agent Framework as the successor to Semantic Kernel's agent features, and we have a separate guide for it. This post is for the many codebases that already use Semantic Kernel and just need web search added.

What we actually ran (November 27, 2026): semantic-kernel 1.47.0 (the latest on PyPI) with mcp 1.30.0 on Python 3.13, and @agentsearchhq/agentsearch-mcp 1.8.7 on Node 24. MCPStdioPlugin loaded all eight AgentSearch tools as kernel functions. We made one real free search and one free-trial extract through kernel.invoke, and we built the ChatCompletionAgent below against that plugin and checked which functions its filter exposes. We did not run a model call; that needs your own model key.

What the agent gets (and what it costs)

The AgentSearch MCP server exposes eight tools. For research agents, 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_search_and_read Search plus the page text of the top hits, in one call 10 free calls per IP in total (never resets), then $0.005 per call

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. The other tools cover news, JavaScript-heavy pages (Web Render), screenshots and a free service review board. More on the Search, Extract and Search + Read pages.

Step 1: Install Semantic Kernel

You need Python 3.11 or newer (Semantic Kernel's minimum) and Node.js 20 or newer, because the MCP server runs with npx.

python -m venv .venv && source .venv/bin/activate
pip install "semantic-kernel[mcp]"

The quotes matter in zsh. In 1.47.0 the mcp package is already a core dependency, so the extra is just a safe way to ask for it; older releases needed it.

Step 2: Load AgentSearch as a plugin

MCPStdioPlugin starts the server as a subprocess, connects over stdio and turns every MCP tool into a kernel function. Use it as an async context manager so the server is started and stopped for you:

import asyncio
from semantic_kernel import Kernel
from semantic_kernel.connectors.mcp import MCPStdioPlugin

async def main():
    async with MCPStdioPlugin(
        name="AgentSearch",
        description="Live web search and page reading",
        command="npx",
        args=["-y", "@agentsearchhq/agentsearch-mcp"],
        request_timeout=60,
    ) as agentsearch:
        kernel = Kernel()
        kernel.add_plugin(agentsearch)
        for fn in kernel.get_plugin("AgentSearch").functions.values():
            print(fn.fully_qualified_name, [p.name for p in fn.parameters][:6])

asyncio.run(main())

This is what it printed for us (in about three seconds, with the package already in the npm cache):

AgentSearch-agentsearch_extract ['url', 'formats', 'max_chars', 'include_links']
AgentSearch-agentsearch_news_search ['query', 'max_results', 'freshness', 'date_from', 'date_to', 'country']
AgentSearch-agentsearch_render ['url', 'formats', 'max_chars', 'screenshot', 'screenshot_format', 'full_page']
AgentSearch-agentsearch_review_lookup ['task', 'service_id', 'max_price_usd', 'network', 'limit', 'include_down']
AgentSearch-agentsearch_review_submit ['service_id', 'success', 'task', 'latency_ms', 'quality', 'price_paid_usd']
AgentSearch-agentsearch_screenshot ['url', 'format', 'full_page', 'viewport']
AgentSearch-agentsearch_search_and_read ['query', 'num_results', 'max_results', 'max_chars', 'render_fallback', 'freshness']
AgentSearch-agentsearch_web_search ['query', 'max_results', 'freshness', 'date_from', 'date_to', 'country']

Two things to notice. The function names are PluginName-tool_name, joined with a hyphen. And each tool's JSON schema becomes the function's parameters, so the model sees the same arguments and descriptions it would in any MCP client. request_timeout is in seconds.

Step 3: Search, then read (no model in the loop)

You can call the tools yourself with kernel.invoke. This is handy for tests, scripts and pipelines where you don't want a model deciding anything:

import asyncio, json
from semantic_kernel import Kernel
from semantic_kernel.connectors.mcp import MCPStdioPlugin

async def main():
    async with MCPStdioPlugin(
        name="AgentSearch",
        command="npx",
        args=["-y", "@agentsearchhq/agentsearch-mcp"],
        request_timeout=60,
    ) as agentsearch:
        kernel = Kernel()
        kernel.add_plugin(agentsearch)

        result = await kernel.invoke(
            plugin_name="AgentSearch",
            function_name="agentsearch_web_search",
            query="Semantic Kernel Python MCPStdioPlugin",
            max_results=3,
        )
        data = json.loads(str(result.value[0]))
        for hit in data["results"]:
            print(hit["title"], hit["url"])

        page = await kernel.invoke(
            plugin_name="AgentSearch",
            function_name="agentsearch_extract",
            url=data["results"][0]["url"],
            max_chars=1500,
        )
        print(str(page.value[0])[:800])

asyncio.run(main())

result.value is a list of content items, not a string. The first one is a TextContent holding the tool's JSON, and str() gives you that text. Our real search returned three hits: Microsoft's DevBlogs post announcing MCP support in Semantic Kernel for Python, a Medium walkthrough of MCPStdioPlugin, and the MCP agent sample in the Semantic Kernel GitHub repo. Each hit has title, url, content (the snippet), domain and published_date. Then agentsearch_extract fetched the DevBlogs page as markdown on the free extract trial.

Pass the plugin to a ChatCompletionAgent and the model can call the tools on its own. ChatCompletionAgent uses FunctionChoiceBehavior.Auto() by default. We add a filter so the model only sees search and extract, not all eight tools:

import asyncio
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.connectors.mcp import MCPStdioPlugin
from semantic_kernel.functions import KernelArguments

async def main():
    async with MCPStdioPlugin(
        name="AgentSearch",
        command="npx",
        args=["-y", "@agentsearchhq/agentsearch-mcp"],
        request_timeout=60,
    ) as agentsearch:
        settings = OpenAIChatPromptExecutionSettings()
        settings.function_choice_behavior = FunctionChoiceBehavior.Auto(
            filters={"included_functions": [
                "AgentSearch-agentsearch_web_search",
                "AgentSearch-agentsearch_extract",
            ]}
        )
        agent = ChatCompletionAgent(
            service=OpenAIChatCompletion(ai_model_id="gpt-4o-mini"),  # reads OPENAI_API_KEY
            name="Researcher",
            instructions="Search the web before answering. Cite the URLs you used.",
            plugins=[agentsearch],
            arguments=KernelArguments(settings=settings),
        )
        response = await agent.get_response(
            messages="What changed in the latest Semantic Kernel Python release? Cite sources."
        )
        print(response)

asyncio.run(main())

We built this exact agent against the live plugin and asked the kernel which functions the filter exposes. The answer was AgentSearch-agentsearch_extract and AgentSearch-agentsearch_web_search, out of eight loaded. We stopped before get_response, because that's the step that calls your model. Any Semantic Kernel chat service that supports function calling works the same way (Azure OpenAI, Ollama and the rest); swap the service and its matching settings class.

Keep the whole agent run inside the async with block. The plugin only works while its server process is alive.

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 the other paid tools.
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.

MCPStdioPlugin hands env to the MCP SDK's stdio client, which does not forward your whole shell environment. It starts the server with a short list of safe variables (HOME, PATH, USER and a few others) and merges in whatever you pass. So pass the wallet variables explicitly:

import os
from semantic_kernel.connectors.mcp import MCPStdioPlugin

agentsearch = MCPStdioPlugin(
    name="AgentSearch",
    command="npx",
    args=["-y", "@agentsearchhq/agentsearch-mcp"],
    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 to AgentSearch's own API at api.agentsearchhq.com. 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 and the env merge against the installed MCP SDK. We didn't run a paid call for this post.

Gotchas we hit

The plugin name can't have a space. With MCPStdioPlugin(name="Agent Search", ...) the server connected fine, but kernel.add_plugin then failed with FunctionInitializationError: KernelFunction failed to initialize: Failed to create KernelFunctionMetadata. The error doesn't mention the name. Plugin names must match ^[0-9A-Za-z_]+$ (no spaces, no hyphens). AgentSearch works.

Calls after the async with block fail. When we called kernel.invoke after leaving the block, we got KernelInvokeException, caused by MCP server not connected, please call connect() before using this method. The kernel still lists the functions, but the server is gone. Keep the agent inside the block, or call await agentsearch.connect() yourself and await agentsearch.close() when you're done.

Filters use the hyphenated full name. included_functions wants AgentSearch-agentsearch_web_search, not agentsearch_web_search. You can also filter a whole plugin with {"included_plugins": ["AgentSearch"]}.

Troubleshooting

npx: not found or Failed to connect to the MCP server. Install Node.js 20+ and make sure npx is on the PATH your Python process sees. Or install the package globally (npm i -g @agentsearchhq/agentsearch-mcp) and use command="agentsearch-mcp" with no args.

Timeouts on the first run. npx downloads the package the first time. Raise request_timeout (seconds) or install the package globally.

TypeError: the JSON object must be str ... not list. kernel.invoke returns a FunctionResult whose value is a list. Parse str(result.value[0]).

HTTP 429 from search or extract. You've used the free allowance: the 25 lifetime searches for your IP, the 10 lifetime search-and-read calls, or the daily extract trial (5). 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 Semantic Kernel 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. You still need whatever key your chat model uses.

Should I use Semantic Kernel or Microsoft Agent Framework?

If your app already runs on Semantic Kernel, MCPStdioPlugin adds web search without a migration. For a new agent project, Microsoft points people to Agent Framework, which has its own MCPStdioTool; our Agent Framework guide covers that setup with the same MCP server.

Get started

from semantic_kernel.connectors.mcp import MCPStdioPlugin

async with MCPStdioPlugin(
    name="AgentSearch",
    command="npx",
    args=["-y", "@agentsearchhq/agentsearch-mcp"],
) as agentsearch:
    kernel.add_plugin(agentsearch)

Add the plugin to your kernel or agent and ask it to search. You get 25 free searches per IP in total with no key, then $0.003 per paid search.

More from the blog

Service pages: Web Search API · Web Extract API · Search + Read API · Web Render API