Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / paths-filter (push) Waiting to run
dotnet-build-and-test / dotnet-build-and-test (Debug, windows-latest, net9.0) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, ubuntu-latest, net10.0) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test (Release, integration, true, windows-latest, net472) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test (Release, ubuntu-latest, net8.0) (push) Blocked by required conditions
dotnet-build-and-test / dotnet-build-and-test-check (push) Blocked by required conditions
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:
- Open a terminal in the Agent_Step10_AsMcpTool project directory.
- Run the
npx @modelcontextprotocol/inspector dotnet runcommand to start the MCP Inspector. Make sure you have node.js and npm installed.npx @modelcontextprotocol/inspector dotnet run - 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 - Open a web browser and navigate to the URL displayed in the terminal. If not opened automatically, this will open the MCP Inspector interface.
- In the MCP Inspector interface, add the following environment variables to allow your MCP server to access Azure AI Foundry Project to create and run the agent:
- AZURE_FOUNDRY_PROJECT_ENDPOINT = https://your-resource.openai.azure.com/ # Replace with your Azure AI Foundry Project endpoint
- AZURE_FOUNDRY_PROJECT_DEPLOYMENT_NAME = gpt-4o-mini # Replace with your model deployment name
- Find and click the
Connectbutton in the MCP Inspector interface to connect to the MCP server. - As soon as the connection is established, open the
Toolstab in the MCP Inspector interface and select theJokertool from the list. - Specify your prompt as a value for the
queryargument, for example:Tell me a joke about a pirateand click theRun Toolbutton to run the tool. - 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!'.