Edit

Share via


Work with Azure AI Foundry Agent Service and MCP server tools in Visual Studio Code (preview)

In this article, you learn how to add and use Model Context Protocol (MCP) tools with Azure AI agents by using the Azure AI Foundry for Visual Studio Code extension.

After you build an agent in Azure AI Foundry Agent Service by using this Visual Studio Code (VS Code) extension, you can add MCP tools to your agent.

Using or building an MCP server allows your agent to:

  • Access up-to-date information from your APIs and services.
  • Retrieve relevant context to enhance the quality of responses from your AI models.

Agents combine AI models with tools to access and interact with your data.

Azure AI Foundry developers can stay productive by developing, testing, and deploying MCP tool-calling agents in the familiar environment of VS Code.

Important

Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

Create an Azure AI agent within the designer view

To create an Azure AI agent, follow the steps in Create and edit Azure AI agents within the designer view.

Add an existing MCP server tool to the AI agent

After you create your agent, you can add tools to it, including MCP tools. For more information about available tools, see Tools for Azure AI agents.

You can bring multiple remote MCP servers by adding them as tools. For each tool, you need to provide a unique Server Label value within the same agent and a Server URL value that points to the remote MCP server.

Warning

The remote MCP servers that you use with the MCP tool in this article are not from Microsoft. Microsoft doesn't test or verify these servers. For details, see Considerations for using non-Microsoft services and servers.

To add an existing MCP server tool to your AI agent, follow these steps:

  1. In the designer, in the upper-right corner of the TOOL section, select the Add tool button. In the dropdown list, select the MCP Server tool.

  2. Find the remote MCP server that you want to connect to, such as the GitHub MCP server. Create or update an Azure AI Foundry agent with an MCP tool by using the following information:

    1. Server URL: The URL of the MCP server; for example, https://gitmcp.io/Azure/azure-rest-api-specs.

    2. Server Label: A unique identifier of this MCP server to the agent; for example, fetch_rest_api_docs.

    Screenshot of the dialog for creating an MCP tool.

  3. In the Allowed tools dropdown list, choose which tools the MCP server can use.

    Screenshot of the list of allowed tools in the dialog for creating an MCP tool.

  4. After you enter the required information, select the Create tool button.

Create an Azure AI agent on Azure AI Foundry

After you add an MCP tool, you can create an agent directly on Azure AI Foundry by using the following steps:

  1. In the designer, select the Create Agent on Azure AI Foundry button.

    Screenshot of the agent designer with the button for creating an agent on Azure AI Foundry highlighted.

  2. In VS Code, refresh the Azure Resources view. The deployed agent appears in the Agents subsection.

    Screenshot of a deployed agent in the Azure Resources view.

View the details of a deployed AI agent

Selecting the deployed agent opens the AGENT PERFERENCES pane in a view-only mode. You can:

  • Select the Edit Agent button to view the agent designer and the .yaml definition of the agent for editing.
  • Select the Open Code File button to create a sample code file that uses the agent.
  • Select the Open Playground button to open the agent playground.

Screenshot of the pane for agent preferences with the Edit Agent, Open Code File, and Open Playground buttons highlighted.

Edit and update the deployed AI agent

  1. On the AGENT PERFERENCES pane, select the Edit Agent button. The agent designer opens with the agent's .yaml file.

  2. Edit the agent's configuration, such as the model, tools, and instructions.

  3. After you finish editing, select the Update Agent on Azure AI Foundry button to save your changes.

Screenshot of the pane for agent preferences with the Update Agent on Azure AI Foundry button highlighted.

Interact with agents by using the MCP server tool in the agent playground

  1. Right-click your deployed agent that has an MCP Server tool, and then select the Open Playground option. This action starts a thread with your agent so that you can send messages.

  2. On the Agent Playground pane, enter a prompt such as Give me an example for creating a container app and send it.

  3. Select the authentication method for the MCP server tool and proceed.

    Screenshot of the MCP server tool's authentication prompt in the agent playground.

  4. Select the approval preference for the MCP server tool and proceed.

    Screenshot of the MCP server tool's approval preference in the agent playground.

  5. If you chose Ask every time for your approval preference, you need to approve or reject the tool call.

    Screenshot of the MCP server tool's approval prompt in the agent playground.

  6. The agent uses the model and the MCP server tools that you configured in the agent designer to retrieve the information. The source of the information appears in the section for agent annotations.

    Screenshot of the agent playground with agent annotations highlighted in Visual Studio Code after use of the MCP server tool.

Clean up resources

The Azure resources that you created in this article are billed to your Azure subscription. If you don't expect to need these resources in the future, delete them to avoid incurring more charges.

Delete your agents

Tip

Because you can customize the left pane in the Azure AI Foundry portal, you might see different items than shown in these steps. If you don't see what you're looking for, select ... More at the bottom of the left pane.

  1. In the Azure AI Foundry portal, on the left menu, select Agents.

  2. Select the agent that you want to delete, and then select Delete.

    Screenshot of the Azure AI Foundry portal with the Delete command for a selected agent.

Delete your models

  1. In VS Code, refresh the Azure Resources view. Expand the Models subsection to display the list of deployed models.

  2. Right-click the deployed model that you want to delete, and then select Delete.

    Screenshot of the shortcut menu with the Delete command for a selected model.

Delete your connected tools

  1. Open the Azure portal.

  2. Select the Azure resource group that contains the tool.

  3. Select the Delete button.