Skip to content

Microsoft Copilot Studio ❤️ MCP

Welcome, agent. Your mission — should you choose to accept it — is to deploy an MCP Server behind enemy lines and wire it up to Microsoft Copilot Studio. Expect turbulence. Trust the protocol. Leave no endpoint unconfigured. 🎯

❓ What is MCP?

Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to LLMs, defined by Anthropic. MCP provides a standardized way to connect AI models to different data sources and tools. MCP allows makers to seamlessly integrate existing knowledge servers and APIs directly into Copilot Studio.

🆚 MCP vs Connectors

When do you use MCP? And when do you use connectors? Will MCP replace connectors?

MCP servers are made available to Copilot Studio using connector infrastructure, so these questions are not really applicable. The fact that MCP servers use the connector infrastructure means they can employ enterprise security and governance controls such as Virtual Network integration, Data Loss Prevention controls, multiple authentication methods—all of which are available in this release—while supporting real-time data access for AI-powered agents.

So, MCP and connectors are really better together.

⚙️ Prerequisites

  • Visual Studio Code installed (download)
  • Node v22 (ideally installed via nvm for Windows or nvm)
  • Docker installed (download)
  • Azure Developer CLI installed (download)
  • Azure Subscription (with payment method added)
  • Copilot Studio trial or developer account

⚖️ Choice: Run the server locally or deploy to Azure

Now you have a choice! You either run the server locally - or you can deploy it to Azure.

There are a couple of steps that you need to do for both:

  1. Download the Jokes MCP Server

  2. Unpack the zip-file

  3. Open Visual Studio Code and open the unpacked folder

  4. Open the terminal in Visual Studio Code by pressing ctrl + ` (Windows/Linux) or cmd + ` (Mac)

🏃‍♀️ Run the MCP Server Locally

  1. Run the following command to install the dependencies:

    bash
    npm install
  2. Run the following command to build and start the server:

    bash
    npm run build && npm run start

    Terminal view after building and starting the server

  3. Select PORTS at the top of the Visual Studio Code Terminal

    Image of VS Code where the terminal is open and the PORTS tab is highlighted

  4. Select the green Forward a Port button

    Image of VS Code where the PORTS tab is open and the green  button is highlighted

  5. Enter 3000 as the port number (this should be the same as the port number you see when you ran the command in step 5). You might be prompted to sign in to GitHub, if so please do this, since this is required to use the port forwarding feature.

  6. Right click on the row you just added and select Port visibility > Public to make the server publicly available

  7. Ctrl + click on the Forwarded address, which should be something like: https://something-3000.something.devtunnels.ms

  8. Select Copy on the following pop-up to copy the URL

    View of the PORTS setup with highlighted the port, the forwarded address and the visibility

  9. Open to the browser of your choice and paste the URL in the address bar, type /mcp behind it and hit enter

If all went well, you will see the following error message:

json
{"jsonrpc":"2.0","error":{"code":-32000,"message":"Method not allowed."},"id":null}

Don't worry - this error message is nothing to be worried about!

🌎 Deploy to Azure

IMPORTANT

As listed in the prerequisites, the Azure Developer CLI needs to be installed on your machine for this part.

Make sure to login to Azure Developer CLI if you haven't done that yet.

bash
azd auth login

WARNING

After running azd up, you will have an MCP Server running on Azure that is publicly available. Ideally, you don't want that. Make sure to run azd down after finishing the lab to delete all the resources from your Azure subscription. Learn how to run azd down by going to this section.

Run the following command in the terminal:

bash
azd up

For the unique environment name, enter mcsmcplab or something similar. Select the Azure Subscription to use and select a value for the location. After that, it will take a couple of minutes before the server has been deployed. When it's done - you should be able to go to the URL that's listed at the end and add /mcp to the end of that URL.

Azd deploy server output

You should again see the following error:

json
{"jsonrpc":"2.0","error":{"code":-32000,"message":"Method not allowed."},"id":null}

👨‍💻 Use the Jokes MCP Server in Visual Studio Code / GitHub Copilot

To use the Jokes MCP Server, you need to use the URL of your server (can be either your devtunnel URL or your deployed Azure Container App) with the /mcp part at the end and add it as an MCP Server in Visual Studio Code.

  1. Press either ctrl + shift + P (Windows/Linux) or cmd + shift + P (Mac) and type MCP

  2. Select MCP: Add Server...

  3. Select HTTP (HTTP or Server-Sent Events)

  4. Paste the URL of your server in the input box (make sure /mcp in the end is included)

  5. Press Enter

  6. Enter a name for the server, for instance JokesMCP

  7. Select User Settings to save the MCP Server settings in your user settings

    This will add an MCP Server to your settings.json file. It should look like this: settings.json file

  8. Open GitHub Copilot

  9. Make sure you are in Agent mode

  10. Make sure the JokesMCP server actions are selected when you select the tools icon:

    Tools menu in GitHub Copilot

  11. Ask the following question:

    text
    Get a chuck norris joke from the Dev category

This should give you a response like this:

Screenshot of question to provide a joke from the dev category and the answer from GitHub Copilot

Now you have added the JokesMCP server to Visual Studio Code!

👨‍💻 Use the Jokes MCP Server in Microsoft Copilot Studio

To use the Jokes MCP Server in Microsoft Copilot Studio, you need to create an agent and then add it as an MCP server.

Create an agent and add the MCP server as a tool

  1. Go to Copilot Studio

  2. Select the environment picker at the top right corner

  3. Select Agents in the left navigation

  4. Select the Create blank agent button

    New agent

    NOTE

    This will start creating your agent, usually within 10 seconds your agent will be visible, but it will take around a minute until everything is provisioned. You will see a green bar at the top with the message Your agent has been provisioned. when your agent is provisioned.

  5. When it's done provisioning, select Edit in the details card on the overview page

    Edit name

  6. Change the name to:

    text
    Jokester
  7. Add the following Description

    text
    A humor-focused agent that delivers concise, engaging jokes only upon user request, adapting its style to match the user's tone and preferences. It remains in character, avoids repetition, and filters out offensive content to ensure a consistently appropriate and witty experience.
  8. Select Save to save the changes

  9. Select Edit in the instructions card on the overview page

  10. Add the following Instructions

    text
    You are a joke-telling assistant. Your sole purpose is to deliver appropriate, clever, and engaging jokes upon request. Follow these rules:
    
    * Respond only when the user asks for a joke or something related (e.g., "Tell me something funny").
    * Match the tone and humor preference of the user based on their input—clean, dark, dry, pun-based, dad jokes, etc.
    * Never break character or provide information unrelated to humor.
    * Keep jokes concise and clearly formatted.
    * Avoid offensive, discriminatory, or NSFW content.
    * When unsure about humor preference, default to a clever and universally appropriate joke.
    * Do not repeat jokes within the same session.
    * Avoid explaining the joke unless explicitly asked.
    * Be responsive, witty, and quick.
  11. Select Save to save the instructions

  12. Select Tools in the top menu

    Tools

  13. Select the blue Add a tool button

  14. Select the Model Context Protocol button under Create new text

    Create MCP

  15. Enter the name:

    text
    Jokes MCP Server
  16. Enter the description:

    text
    MCP server that fetches Chuck Norris and dad jokes on demand.
  17. Enter the URL of the devtunnel. This should be something like https://something-3000.something.devtunnels.ms/mcp or the URL of your deployed MCP server in Azure

  18. Select Create to create the MCP Server

    Creating MCP Server

    This will take a couple of seconds, because Copilot Studio is now creating a connector behind the scenes.

  19. Select Not connected (1) and Create new Connection (2)

    Action and connection

  20. Select Create

    Create connection

  21. Select Add and configure to add the tool to the agent

    Add tool to agent

    TIP

    This will add your MCP server to the agent. On the page that appears after selecting Add and configure, you are able to see the tools in the MCP server inside of Copilot Studio.

    MCP Server Tools

  22. Select the + icon in the Test your agent pane to start a new testing session

    Refresh testing pane

  23. Expand the testing pane by selecting the icon with the arrow

    Expand test pane

  24. In the Test your agent pane send the following message:

    text
    Can I get a Chuck Norris joke?

    This will show you a message that you need to connect first.

  25. Select Open connection manager

    Additional permissions

    This will open a new window where you can manage your connections for this agent.

  26. Select Connect next to the Jokes MCP Server

    Connect to JokesMCP

  27. Wait until the connection is created and select Submit

    Pick a connection

  28. The connection should now be connected, so the status should be set to Connected

    Status connected

  29. Close the manage your connections tab in your browser

    Now you should be back in the Jokester agent screen.

  30. Select the + icon in the Test your agent pane to start a new testing session

    Refresh testing pane

  31. In the Test your agent pane send the following message:

    text
    Can I get a Chuck Norris joke?

    This will now show a Chuck Norris joke - instead of the additional permissions. Also notice that you can easily see which tool has been triggered (get-chuck-joke) and what the output was the agent received.

    Chuck Norris joke

  32. In the Test your agent pane send the following message:

    text
    Can I get a Dad joke?

    This will now show a Dad joke.

    Dad joke

And that was the Jokes MCP Server working in Microsoft Copilot Studio.

❌ Remove the Azure resources

If you have deployed the MCP server to Azure, don't forget to remove the Azure resources. To remove the Azure resources after finishing the lab, run the following command in the terminal:

bash
azd down

This command will show you the resources that will be deleted and then ask you to confirm. Confirm with y and the resources will be deleted. This can take a couple of minutes, but at the end you will see a confirmation:

resources deleted

Analytics