Skip to content

Commit 0eaa638

Browse files
authored
Merge pull request #46016 from dotnet/main
Merge main into live
2 parents 04e4f8a + af9bcd9 commit 0eaa638

File tree

32 files changed

+278
-440
lines changed

32 files changed

+278
-440
lines changed

.openpublishing.redirection.csharp.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,12 +4042,12 @@
40424042
},
40434043
{
40444044
"source_path_from_root": "/docs/csharp/quick-starts/interpolated-strings-local.md",
4045-
"redirect_url": "/dotnet/csharp/tutorials/exploration/interpolated-strings-local",
4046-
"redirect_document_id": true
4045+
"redirect_url": "/dotnet/csharp/tutorials/string-interpolation"
40474046
},
40484047
{
4049-
"source_path_from_root": "/docs/csharp/quick-starts/interpolated-strings.md",
4050-
"redirect_url": "/dotnet/csharp/tutorials/exploration/interpolated-strings"
4048+
"source_path_from_root": "/docs/csharp/quick-starts/interpolated-strings.yml",
4049+
"redirect_url": "/dotnet/csharp/tutorials/string-interpolation",
4050+
"redirect_document_id": true
40514051
},
40524052
{
40534053
"source_path_from_root": "/docs/csharp/quick-starts/introduction-to-classes.md",
@@ -4060,7 +4060,7 @@
40604060
},
40614061
{
40624062
"source_path_from_root": "/docs/csharp/quick-starts/local-environment.md",
4063-
"redirect_url": "/dotnet/csharp/tour-of-csharp/tutorials",
4063+
"redirect_url": "/dotnet/csharp/tour-of-csharp/tutorials/",
40644064
"redirect_document_id": true
40654065
},
40664066
{
@@ -4208,6 +4208,14 @@
42084208
"source_path_from_root": "/docs/csharp/tutorials/exploration/top-level-statements.md",
42094209
"redirect_url": "/dotnet/csharp/tutorials/top-level-statements"
42104210
},
4211+
{
4212+
"source_path_from_root": "/docs/csharp/tutorials/exploration/interpolated-strings-local.md",
4213+
"redirect_url": "/dotnet/csharp/tutorials/string-interpolation"
4214+
},
4215+
{
4216+
"source_path_from_root": "/docs/csharp/tutorials/exploration/interpolated-strings.yml",
4217+
"redirect_url": "/dotnet/csharp/tutorials/string-interpolation"
4218+
},
42114219
{
42124220
"source_path_from_root": "/docs/csharp/tutorials/generate-consume-asynchronous-stream.md",
42134221
"redirect_url": "/dotnet/csharp/asynchronous-programming/generate-consume-asynchronous-stream"
@@ -4242,11 +4250,11 @@
42424250
},
42434251
{
42444252
"source_path_from_root": "/docs/csharp/tutorials/intro-to-csharp/interpolated-strings-local.md",
4245-
"redirect_url": "/dotnet/csharp/tutorials/exploration/interpolated-strings-local"
4253+
"redirect_url": "/dotnet/csharp/tutorials/interpolated-strings"
42464254
},
42474255
{
42484256
"source_path_from_root": "/docs/csharp/tutorials/intro-to-csharp/interpolated-strings.yml",
4249-
"redirect_url": "/dotnet/csharp/tutorials/exploration/interpolated-strings"
4257+
"redirect_url": "/dotnet/csharp/tutorials/interpolated-strings"
42504258
},
42514259
{
42524260
"source_path_from_root": "/docs/csharp/tutorials/intro-to-csharp/introduction-to-classes.md",

docs/ai/get-started-mcp.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Get started with .NET AI and MCP
3+
description: Learn about .NET AI and MCP key concepts and development resources to get started building MCP clients and servers
4+
ms.date: 04/29/2025
5+
ms.topic: overview
6+
ms.custom: devx-track-dotnet, devx-track-dotnet-ai
7+
author: alexwolfmsft
8+
ms.author: alexwolf
9+
# CustomerIntent: As a .NET developer new to OpenAI, I want deploy and use sample code to interact to learn from the sample code to summarize text.
10+
---
11+
12+
# Get started with .NET AI and the Model Context Protocol
13+
14+
The Model Context Protocol (MCP) is an open protocol designed to standardize integrations between AI apps and external tools and data sources. By using MCP, developers can enhance the capabilities of AI models, enabling them to produce more accurate, relevant, and context-aware responses.
15+
16+
For example, using MCP, you can connect your LLM to resources such as:
17+
18+
- Document databases or storage services.
19+
- Web APIs that expose business data or logic.
20+
- Tools that manage files or performing local tasks on a user's device.
21+
22+
Many Microsoft products already support MCP, including:
23+
24+
- [Copilot Studio](https://www.microsoft.com/microsoft-copilot/blog/copilot-studio/introducing-model-context-protocol-mcp-in-copilot-studio-simplified-integration-with-ai-apps-and-agents/)
25+
- [Visual Studio Code GitHub Copilot agent mode](https://code.visualstudio.com/blogs/2025/02/24/introducing-copilot-agent-mode)
26+
- [Semantic Kernel](https://devblogs.microsoft.com/semantic-kernel/integrating-model-context-protocol-tools-with-semantic-kernel-a-step-by-step-guide/).
27+
28+
You can use the [MCP C# SDK](#develop-with-the-mcp-c-sdk) to quickly create your own MCP integrations and switch between different AI models without significant code changes.
29+
30+
### MCP client-server architecture
31+
32+
MCP uses a client-server architecture that enables an AI-powered app (the host) to connect to multiple MCP servers through MCP clients:
33+
34+
- **MCP Hosts**: AI tools, code editors, or other software that enhance their AI models using contextual resources through MCP. For example, GitHub Copilot in Visual Studio Code can act as an MCP host and use MCP clients and servers to expand its capabilities.
35+
- **MCP Clients**: Clients used by the host application to connect to MCP servers to retrieve contextual data.
36+
- **MCP Servers**: Services that expose capabilities to clients through MCP. For example, an MCP server might provide an abstraction over a REST API or local data source to provide business data to the AI model.
37+
38+
The following diagram illustrates this architecture:
39+
40+
:::image type="content" source="media/mcp/model-context-protocol-architecture-diagram.png" alt-text="A diagram showing the architecture pattern of MCP, including hosts, clients, and servers.":::
41+
42+
MCP client and server can exchange a set of standard messages:
43+
44+
| Message | Description |
45+
|---------------------|-------------|
46+
| `InitializeRequest` | This request is sent by the client to the server when it first connects, asking it to begin initialization. |
47+
|`ListToolsRequest` | Sent by the client to request a list of tools the server has. |
48+
|`CallToolRequest` | Used by the client to invoke a tool provided by the server. |
49+
|`ListResourcesRequest` | Sent by the client to request a list of available server resources. |
50+
|`ReadResourceRequest` | Sent by the client to the server to read a specific resource URI. |
51+
|`ListPromptsRequest` | Sent by the client to request a list of available prompts and prompt templates from the server. |
52+
|`GetPromptRequest` | Used by the client to get a prompt provided by the server. |
53+
|`PingRequest` | A ping, issued by either the server or the client, to check that the other party is still alive. |
54+
|`CreateMessageRequest` | A request by the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it. |
55+
|`SetLevelRequest` | A request by the client to the server, to enable or adjust logging. |
56+
57+
## Develop with the MCP C# SDK
58+
59+
As a .NET developer, you can use MCP by creating MCP clients and servers to enhance your apps with custom integrations. MCP reduces the complexity involved in connecting an AI model to various tools, services, and data sources.
60+
61+
The official [MCP C# SDK](https://github.com/modelcontextprotocol/csharp-sdk) is available through NuGet and enables you to build MCP clients and servers for .NET apps and libraries. The SDK is maintained through collaboration between Microsoft, Anthropic, and the MCP open protocol organization.
62+
63+
To get started, add the MCP C# SDK to your project:
64+
65+
```dotnetcli
66+
dotnet add package ModelContextProtocol --prerelease
67+
```
68+
69+
Instead of building unique connectors for each integration point, you can often leverage or reference prebuilt integrations from various providers such as GitHub and Docker:
70+
71+
- [Available MPC clients](https://modelcontextprotocol.io/clients)
72+
- [Available MCP servers](https://modelcontextprotocol.io/examples)
73+
74+
### Integration with Microsoft.Extensions.AI
75+
76+
The MCP C# SDK depends on the [Microsoft.Extensions.AI libraries](/dotnet/ai/ai-extensions) to handle various AI interactions and tasks. These extension libraries provides core types and abstractions for working with AI services, so developers can focus on coding against conceptual AI capabilities rather than specific platforms or provider implementations.
77+
78+
View the MCP C# SDK dependencies on the [NuGet package page](https://www.nuget.org/packages/ModelContextProtocol/0.1.0-preview.11).
79+
80+
## More .NET MCP development resources
81+
82+
Various tools, services, and learning resources are available in the .NET and Azure ecosystems to help you build MCP clients and servers or integrate with existing MCP servers.
83+
84+
Get started with the following development tools:
85+
86+
- [Semantic Kernel](/semantic-kernel/concepts/plugins/adding-mcp-plugins) allows you to add plugins for MCP servers. Semantic Kernel supports both local MCP servers through standard I/O and remote servers that connect through SSE over HTTPS.
87+
- [Azure Functions remote MCP servers](https://devblogs.microsoft.com/dotnet/build-mcp-remote-servers-with-azure-functions/) combine MCP standards with the flexible architecture of Azure Functions. Visit the [Remote MCP functions sample repository](https://aka.ms/cadotnet/mcp/functions/remote-sample) for code examples.
88+
- [Azure MCP Server](https://github.com/Azure/azure-mcp) implements the MCP specification to seamlessly connect AI agents with key Azure services like Azure Storage, Cosmos DB, and more.
89+
90+
Learn more about .NET and MCP using these resources:
91+
92+
- [Microsoft partners with Anthropic to create official C# SDK for Model Context Protocol](https://devblogs.microsoft.com/blog/microsoft-partners-with-anthropic-to-create-official-c-sdk-for-model-context-protocol)
93+
- [Build a Model Context Protocol (MCP) server in C#](https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/)
94+
- [MCP C# SDK README](https://github.com/modelcontextprotocol/csharp-sdk/blob/main/README.md)
95+
96+
## Related content
97+
98+
- [Overview of the .NET + AI ecosystem](/dotnet/ai/dotnet-ai-ecosystem)
99+
- [Microsoft.Extensions.AI](/dotnet/ai/ai-extensions)
100+
- [Semantic Kernel overview for .NET](/dotnet/ai/semantic-kernel-dotnet-overview)

docs/ai/index.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ landingContent:
2121
# Card
2222
- title: Get started
2323
linkLists:
24-
- linkListType: get-started
24+
- linkListType: overview
2525
links:
2626
- text: Develop .NET apps with AI features
2727
url: overview.md
28-
- text: Connect to and prompt an AI model
29-
url: quickstarts/prompt-model.md
3028
- text: Microsoft.Extensions.AI libraries
3129
url: microsoft-extensions-ai.md
30+
- linkListType: get-started
31+
links:
32+
- text: Connect to and prompt an AI model
33+
url: quickstarts/prompt-model.md
3234
- text: Build an Azure AI chat app
33-
url: quickstarts/get-started-openai.md
34-
- text: Summarize text using an Azure OpenAI chat app
35-
url: quickstarts/quickstart-openai-summarize-text.md
35+
url: quickstarts/build-chat-app.md
3636
- text: Generate images using Azure AI
37-
url: quickstarts/quickstart-openai-generate-images.md
37+
url: quickstarts/generate-images.md
3838

3939
# Card
4040
- title: Essential concepts
243 KB
Loading

docs/ai/quickstarts/evaluate-ai-response.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ ms.custom: devx-track-dotnet, devx-track-dotnet-ai
1111
In this quickstart, you create an MSTest app to evaluate the chat response of an OpenAI model. The test app uses the [Microsoft.Extensions.AI.Evaluation](https://www.nuget.org/packages/Microsoft.Extensions.AI.Evaluation) libraries.
1212

1313
> [!NOTE]
14-
> This quickstart demonstrates the simplest usage of the evaluation API. Notably, it doesn't demonstrate use of the [response caching](../conceptual/evaluation-libraries.md#cached-responses) and [reporting](../conceptual/evaluation-libraries.md#reporting) functionality, which are important if you're authoring unit tests that run as part of an "offline" evaluation pipeline. The scenario shown in this quickstart is suitable in use cases such as "online" evaluation of AI responses within production code and logging scores to telemetry, where caching and reporting aren't relevant. For a tutorial that demonstrates the caching and reporting functionality, see [Tutorial: Evaluate a model's response with response caching and reporting](../tutorials/evaluate-with-reporting.md)
14+
>
15+
> - The `Microsoft.Extensions.AI.Evaluation` library is currently in Preview.
16+
> - This quickstart demonstrates the simplest usage of the evaluation API. Notably, it doesn't demonstrate use of the [response caching](../conceptual/evaluation-libraries.md#cached-responses) and [reporting](../conceptual/evaluation-libraries.md#reporting) functionality, which are important if you're authoring unit tests that run as part of an "offline" evaluation pipeline. The scenario shown in this quickstart is suitable in use cases such as "online" evaluation of AI responses within production code and logging scores to telemetry, where caching and reporting aren't relevant. For a tutorial that demonstrates the caching and reporting functionality, see [Tutorial: Evaluate a model's response with response caching and reporting](../tutorials/evaluate-with-reporting.md)
1517
1618
## Prerequisites
1719

docs/ai/quickstarts/generate-images.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Complete the following steps to create a .NET console app to connect to an AI mo
9898
9999
## Add the app code
100100
101-
1. In the **Program.cs** file, add the following code to connect and authenticate to the AI model.
101+
1. In the `Program.cs` file, add the following code to connect and authenticate to the AI model.
102102
103103
:::zone target="docs" pivot="azure-openai"
104104
@@ -117,12 +117,12 @@ Complete the following steps to create a .NET console app to connect to an AI mo
117117
118118
The preceding code:
119119
120-
- Reads essential configuration values from the project user secrets to connect to the AI model
121-
- Creates an `ImageClient` to connect to the AI model
122-
- Sends a prompt to the model that describes the desired image
123-
- Prints the URL of the generated image to the console output
120+
- Reads essential configuration values from the project user secrets to connect to the AI model.
121+
- Creates an `OpenAI.Images.ImageClient` to connect to the AI model.
122+
- Sends a prompt to the model that describes the desired image.
123+
- Prints the URL of the generated image to the console output.
124124
125-
1. Use the `dotnet run` command to run the app:
125+
1. Run the app:
126126
127127
```dotnetcli
128128
dotnet run

docs/ai/quickstarts/includes/clone-sample-repo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.date: 07/03/2024
55
ms.topic: include
66
---
77

8-
## Clone the sample repository
8+
## (Optional) Clone the sample repository
99

1010
You can create your own app using the steps in the sections ahead, or you can clone the GitHub repository that contains the completed sample apps for all of the quickstarts. If you plan to use Azure OpenAI, the sample repo is also structured as an Azure Developer CLI template that can provision an Azure OpenAI resource for you.
1111

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
## Create the AI service
22

3-
# [Azure Developer CLI](#tab/azd)
4-
5-
[!INCLUDE [deploy-azd](deploy-azd.md)]
6-
7-
# [Azure CLI](#tab/azure-cli)
3+
# [Azure Portal or Azure CLI](#tab/azure-cli)
84

9-
1. To provision an Azure OpenAI service and model using the Azure CLI, complete the steps in the [Create and deploy an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource?pivots=cli) article.
5+
1. To provision an Azure OpenAI service and model, complete the steps in the [Create and deploy an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource) article.
106

117
1. From a terminal or command prompt, navigate to the root of your project directory.
128

@@ -18,18 +14,8 @@
1814
dotnet user-secrets set AZURE_OPENAI_GPT_NAME <your-azure-openai-model-name>
1915
```
2016

21-
# [Azure Portal](#tab/azure-portal)
22-
23-
1. To provision an Azure OpenAI service and model using the Azure portal, complete the steps in the [Create and deploy an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource?pivots=web-portal) article.
24-
25-
1. From a terminal or command prompt, navigate to the root of your project directory.
26-
27-
1. Run the following commands to configure your Azure OpenAI endpoint and model name for the sample app:
17+
# [Azure Developer CLI](#tab/azd)
2818

29-
```bash
30-
dotnet user-secrets init
31-
dotnet user-secrets set AZURE_OPENAI_ENDPOINT <your-openai-key>
32-
dotnet user-secrets set AZURE_OPENAI_GPT_NAME <your-azure-openai-model-name>
33-
```
19+
[!INCLUDE [deploy-azd](deploy-azd.md)]
3420

3521
---

0 commit comments

Comments
 (0)