-
Notifications
You must be signed in to change notification settings - Fork 6k
Mcp overview and development resources #45972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1a7987d
initial commit
alexwolfmsft 1bd9174
updates
alexwolfmsft 9b15450
updates
alexwolfmsft ac9fb06
toc fix
alexwolfmsft 279a446
Fix link
alexwolfmsft 6b40678
consolidate intro
alexwolfmsft 4361751
fix
alexwolfmsft 5ed12f7
fix link
alexwolfmsft d31cc5f
Fix lint
alexwolfmsft 34960d7
fix PR issues
alexwolfmsft 018e0fd
Apply suggestions from code review
alexwolfmsft 474c6d4
feedback fixes
alexwolfmsft ba24a71
build fixes
alexwolfmsft 17740b0
Apply suggestions from code review
alexwolfmsft bfe6b99
fix link
alexwolfmsft ee20e3e
fix topic
alexwolfmsft 37946cd
removed unusued doc
alexwolfmsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
title: Get started with .NET AI and MCP | ||
description: Learn about .NET AI and MCP key concepts and development resources to get started building MCP clients and servers | ||
ms.date: 04/29/2025 | ||
ms.topic: overview | ||
ms.custom: devx-track-dotnet, devx-track-dotnet-ai | ||
author: alexwolfmsft | ||
ms.author: alexwolf | ||
# 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. | ||
--- | ||
|
||
# Get started with .NET AI and the Model Context Protocol | ||
|
||
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. | ||
|
||
For example, using MCP, you can connect your LLM to resources such as: | ||
|
||
- Document databases or storage services. | ||
- Web APIs that expose business data or logic. | ||
- Tools that manage files or performing local tasks on a user's device. | ||
|
||
Many Microsoft products already support MCP, including: | ||
|
||
- [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/) | ||
- [Visual Studio Code GitHub Copilot agent mode](https://code.visualstudio.com/blogs/2025/02/24/introducing-copilot-agent-mode) | ||
- [Semantic Kernel](https://devblogs.microsoft.com/semantic-kernel/integrating-model-context-protocol-tools-with-semantic-kernel-a-step-by-step-guide/). | ||
|
||
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. | ||
|
||
### MCP client-server architecture | ||
|
||
MCP uses a client-server architecture that enables an AI-powered app (the host) to connect to multiple MCP servers through MCP clients: | ||
|
||
- **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. | ||
- **MCP Clients**: Clients used by the host application to connect to MCP servers to retrieve contextual data. | ||
- **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. | ||
|
||
The following diagram illustrates this architecture: | ||
|
||
:::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."::: | ||
|
||
MCP client and server can exchange a set of standard messages: | ||
|
||
| Message | Description | | ||
|---------------------|-------------| | ||
| `InitializeRequest` | This request is sent by the client to the server when it first connects, asking it to begin initialization. | | ||
|`ListToolsRequest` | Sent by the client to request a list of tools the server has. | | ||
|`CallToolRequest` | Used by the client to invoke a tool provided by the server. | | ||
|`ListResourcesRequest` | Sent by the client to request a list of available server resources. | | ||
|`ReadResourceRequest` | Sent by the client to the server to read a specific resource URI. | | ||
|`ListPromptsRequest` | Sent by the client to request a list of available prompts and prompt templates from the server. | | ||
|`GetPromptRequest` | Used by the client to get a prompt provided by the server. | | ||
|`PingRequest` | A ping, issued by either the server or the client, to check that the other party is still alive. | | ||
|`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. | | ||
|`SetLevelRequest` | A request by the client to the server, to enable or adjust logging. | | ||
|
||
## Develop with the MCP C# SDK | ||
|
||
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. | ||
|
||
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. | ||
|
||
To get started, add the MCP C# SDK to your project: | ||
|
||
```dotnetcli | ||
dotnet add package ModelContextProtocol --prerelease | ||
``` | ||
|
||
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: | ||
|
||
- [Available MPC clients](https://modelcontextprotocol.io/clients) | ||
- [Available MCP servers](https://modelcontextprotocol.io/examples) | ||
|
||
### Integration with Microsoft.Extensions.AI | ||
|
||
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. | ||
|
||
View the MCP C# SDK dependencies on the [NuGet package page](https://www.nuget.org/packages/ModelContextProtocol/0.1.0-preview.11). | ||
|
||
## More .NET MCP development resources | ||
|
||
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. | ||
|
||
Get started with the following development tools: | ||
|
||
- [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. | ||
- [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. | ||
- [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. | ||
|
||
Learn more about .NET and MCP using these resources: | ||
|
||
- [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) | ||
- [Build a Model Context Protocol (MCP) server in C#](https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/) | ||
- [MCP C# SDK README](https://github.com/modelcontextprotocol/csharp-sdk/blob/main/README.md) | ||
|
||
## Related content | ||
|
||
- [Overview of the .NET + AI ecosystem](/dotnet/ai/dotnet-ai-ecosystem) | ||
- [Microsoft.Extensions.AI](/dotnet/ai/ai-extensions) | ||
- [Semantic Kernel overview for .NET](/dotnet/ai/semantic-kernel-dotnet-overview) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.