Featured image of post Using Model Context Protocol in agents - Streamable HTTP support in Copilot Studio

Using Model Context Protocol in agents - Streamable HTTP support in Copilot Studio

In this post, we'll see how to use the Model Context Protocol (MCP) with Copilot Studio using the Streamable HTTP transport layer

In a post I published a while ago, we explored the first preliminary support for the Model Context Protocol (MCP) in Copilot Studio. Thanks to this integration, we can empower agents to use tools and services exposed through the MCP protocol. Since then, however, Copilot Studio has evolved and, during Microsoft Build, the team officially launched the feature in Public Preview by adding a set of new capabilities that simplify the integration of MCP tools.

Let’s explore these changes!

Goodbye SSE, welcome Streamable HTTP

In previous posts, we explored how MCP supports different transport layers to manage communication between the client and server. Copilot Studio, being a platform running in the cloud, supported only SSE, which is based on HTTP. The other transport layer, called stdio, is based on a standard input/output stream and, as such, is suitable only for scenarios in which both the client and server are running in a local environment.

However, SSE is being deprecated for security reasons and has been replaced by another transport layer, still based on HTTP but much more efficient and secure: Streamable HTTP. Copilot Studio now supports this new transport layer, which has an extra advantage: we no longer need to apply the workaround we used to make SSE work with Copilot Studio, which was providing a custom MCP mapping to inject the full URL into the layer implementation.

Let’s see how we can update our MCP server to support the new Streamable HTTP transport layer.

Using Streamable HTTP in C#

The good news is that, if you’re using C# and .NET to implement your MCP server, you just need to upgrade the MCP NuGet package to the latest version which, at the time of writing, is 0.2.0-preview.3. Thanks to this updated package, the code we have already written to implement our Employee Vacations MCP server will automatically support both SSE and Streamable HTTP, thanks to the WithHttpTransport() extension method::

1
2
3
4
builder.Services
    .AddMcpServer()
    .WithHttpTransport()
    .WithToolsFromAssembly();

The second step is to delete the MapAbsoluteEndpointUriMcp() method we implemented to customize the MCP mapping. We no longer need it; we can just use the standard mapping by calling the app.MapMcp() method before app.Run():

1
2
3
app.MapMcp();

app.Run();

Now, if you run your MCP server after these changes and open your browser to the server URL (which, by default, is http://localhost:5248), you will see two things:

  • The old /sse endpoint (http://localhost:5248/sse) is still working to maintain backward compatibility with existing clients and it will return a message like this:
1
2
event: endpoint
data: /message?sessionId=DzQJIVL6sa65HiL3u1kx4Q
  • The Streamable HTTP layer is available at the root endpoint (so just calling the base URL http://localhost:5248) and it will return a JSON response like this:
1
{"error":{"code":-32001,"message":"Session not found"},"id":"","jsonrpc":"2.0"}

Now our MCP server officially supports the new Streamable HTTP transport layer, and we can use it with Copilot Studio.

Using Streamable HTTP in Copilot Studio

To use the new Streamable HTTP transport layer in Copilot Studio, we need to use again the custom connector strategy we have learned in the previous post. However, this time, we won’t have to manually provide the OpenAPI specification because the Power Platform offers a built-in template we can use.

First, let’s go to the Power Platform portal and, following the same instructions we have seen in the previous post, open the Custom Connectors section. The direct URL is https://make.powerapps.com/environments/<guid>/customconnectors, where <guid> is the ID of your environment.

Now click on New custom connector at the top right corner and, this time, select Import from GitHub. Now select the following options from the pop-up dialog:

  • Connector Type: Custom
  • Branch: Dev
  • Connector: MCP-Streamable-HTTP

Add a new MCP server with Streamable HTTP protocol

Click Continue to start the configuration of the new connector. This time, you won’t have to change anything, except the Host, which must point to the URL of your MCP server. If you’re running it locally, you will need to use the port forwarding feature of Visual Studio Code to expose the server to the Internet, like we have explained in the previous post.

Another small change to make is in the Base URL field, which by default is set to /mcp. The C# MCP SDK actually exposes it at the root, so you must replace it with / (just a single slash).

The options to customize to set up your MCP server

That’s it! Click on Create connector to create the new custom connector.

Using the new MCP connector in Copilot Studio

Now we can use the new MCP connector in Copilot Studio. The process didn’t change from the previous post, so we can follow the same steps. Pick up your agent and, under the Tools section, click on Add tool. Click on the Model Context Protocol label and you will see the new MCP connector you’ve just created. Click on it to add it to your agent.

Add a MCP Server as a tool to an agent

Copilot Studio has added a useful new feature that lets you check if the connection with the MCP server is working properly even without performing any queries. Once the tool has been added to your agent, click on it. You will land on the detail page, with a section called Tools that queries the MCP server to get the list of available tools. If everything is working properly, you will see the list of tools exposed by your MCP server, as shown in the following screenshot:

The list of tools in Copilot Studio

To further test the connection, you can also use the Test your agent panel on the right and write a prompt that requires the use of one of the available tools to get a response, such as the following::

1
Give me the list of employees and their vacation days left

Wrapping up

In this post, we have seen how to switch our MCP server from the old SSE transport layer to the new Streamable HTTP one, which provides better security and performance and is now officially supported by Copilot Studio. This change greatly simplifies the integration of MCP tools in Copilot Studio, as we no longer need to provide a custom mapping implementation or manually provide the OpenAPI specification for our custom connector, since we can use a new template offered by the Power Platform.

You can find the updated MCP sample code on GitHub.

Built with Hugo
Theme Stack designed by Jimmy