Files
agent-framework/dotnet/samples/02-agents/Agents/Agent_Step07_AsMcpTool
Roger BarretoandGitHub b0613a8ceb .NET: Bump Azure.AI.Projects to 2.0.0 GA (#5060)
* Bump Azure.AI.Projects to 2.0.0 GA

- Update Azure.AI.Projects from 2.0.0-beta.2 to 2.0.0 in CPM
- Update Azure.Identity from 1.19.0 to 1.20.0 (transitive dep)
- Update System.ClientModel from 1.9.0 to 1.10.0 (transitive dep)
- Rename types per Azure.AI.Projects.Agents 2.0.0 breaking changes:
  - AgentVersion -> ProjectsAgentVersion
  - AgentRecord -> ProjectsAgentRecord
  - AgentDefinition -> ProjectsAgentDefinition
  - AgentVersionCreationOptions -> ProjectsAgentVersionCreationOptions
  - PromptAgentDefinition -> DeclarativeAgentDefinition
  - AgentTool -> ProjectsAgentTool
  - AgentsClient -> AgentAdministrationClient
  - .Agents property -> .AgentAdministrationClient
- Add using Azure.AI.Projects.Memory namespace (types moved)
- Update AGENTS.md with BOM and output capture conventions

* Address PR review feedback

- Rename AIProjectClient parameter to aiProjectClient in AsChatClientAgent overloads
- Fix XML doc: ProjectsAgentTool namespace from Azure.AI.Projects.OpenAI to Azure.AI.Projects.Agents
- Rename test method to reflect DeclarativeAgentDefinition terminology
2026-04-02 14:02:29 +00:00
..

This sample demonstrates how to expose an existing AI agent as an MCP tool.

Run the sample

To run the sample, please use one of the following MCP clients: https://modelcontextprotocol.io/clients

Alternatively, use the QuickstartClient sample from this repository: https://github.com/modelcontextprotocol/csharp-sdk/tree/main/samples/QuickstartClient

Run the sample using MCP Inspector

To use the MCP Inspector, follow these steps:

  1. Open a terminal in the Agent_Step07_AsMcpTool project directory.
  2. Run the npx @modelcontextprotocol/inspector dotnet run --framework net10.0 command to start the MCP Inspector. Make sure you have node.js and npm installed.
    npx @modelcontextprotocol/inspector dotnet run --framework net10.0
    
  3. When the inspector is running, it will display a URL in the terminal, like this:
    MCP Inspector is up and running at http://127.0.0.1:6274
    
  4. Open a web browser and navigate to the URL displayed in the terminal. If not opened automatically, this will open the MCP Inspector interface.
  5. In the MCP Inspector interface, add the following environment variables to allow your MCP server to access Microsoft Foundry Project to create and run the agent:
    • AZURE_AI_PROJECT_ENDPOINT = https://your-resource.openai.azure.com/ # Replace with your Microsoft Foundry Project endpoint
    • AZURE_AI_MODEL_DEPLOYMENT_NAME = gpt-4o-mini # Replace with your model deployment name
  6. Find and click the Connect button in the MCP Inspector interface to connect to the MCP server.
  7. As soon as the connection is established, open the Tools tab in the MCP Inspector interface and select the Joker tool from the list.
  8. Specify your prompt as a value for the query argument, for example: Tell me a joke about a pirate and click the Run Tool button to run the tool.
  9. The agent will process the request and return a response in accordance with the provided instructions that instruct it to always start each joke with 'Aye aye, captain!'.