diff --git a/python/samples/concepts/mcp/README.md b/python/samples/concepts/mcp/README.md index a5233fbb2249..56e53ec7b77b 100644 --- a/python/samples/concepts/mcp/README.md +++ b/python/samples/concepts/mcp/README.md @@ -12,14 +12,38 @@ Those can then be used with function calling in a chat or agent. ## Server types -There are two types of servers, Stdio and Sse based. The sample shows how to use the Stdio based server, which get's run locally, in this case by using [npx](https://docs.npmjs.com/cli/v8/commands/npx). +The samples support Stdio, SSE, and Streamable HTTP transports. A Stdio server runs locally, for example by using [npx](https://docs.npmjs.com/cli/v8/commands/npx). Some other common runners are [uvx](https://docs.astral.sh/uv/guides/tools/), for python servers and [docker](https://www.docker.com/), for containerized servers. -The code shown works the same for a Sse server, only then a MCPSsePlugin needs to be used instead of the MCPStdioPlugin. For Streamable HTTP server, MCPStreamableHttpPlugin can be used. +The code shown works the same for an SSE server, only then a MCPSsePlugin needs to be used instead of the MCPStdioPlugin. For Streamable HTTP server, MCPStreamableHttpPlugin can be used. The reverse, using Semantic Kernel as a server, can be found in the [demos/mcp_server](../../demos/mcp_server/) folder. +### Connecting to a remote Streamable HTTP server + +`MCPStreamableHttpPlugin` connects directly to a hosted server without a local server process. For example, [Parallel Search MCP](https://docs.parallel.ai/integrations/mcp/search-mcp) provides `web_search` and `web_fetch` without a Parallel account or API key. Anonymous access is rate limited. + +After installing Semantic Kernel as described below, use this inside an async function: + +```python +from semantic_kernel import Kernel +from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin + +async with MCPStreamableHttpPlugin( + name="ParallelSearch", + url="https://search.parallel.ai/mcp", + load_prompts=False, +) as mcp_plugin: + kernel = Kernel() + plugin = kernel.add_plugin(mcp_plugin) + print(sorted(plugin.functions)) +``` + +This discovers the server's tools. To let an agent use them, pass `plugins=[plugin]` to the agent and invoke it inside the context manager, as in [the HTTP sample](agent_with_http_mcp_plugin.py). That sample's Azure configuration is still required when using its agent. Omit the plugin from the agent to disable access. + +An agent with these tools may call them during its work. Search queries, requested URLs, and any supplied objectives or context are sent to Parallel when tools run. + ## Running the samples 1. Depending on the sample you want to run: