You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 04-PracticalImplementation/README.md
+68-22Lines changed: 68 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# Practical Implementation
2
2
3
+
Practical implementation is where the power of the Model Context Protocol (MCP) becomes tangible. While understanding the theory and architecture behind MCP is important, the real value emerges when you apply these concepts to build, test, and deploy solutions that solve real-world problems. This chapter bridges the gap between conceptual knowledge and hands-on development, guiding you through the process of bringing MCP-based applications to life.
4
+
5
+
Whether you are developing intelligent assistants, integrating AI into business workflows, or building custom tools for data processing, MCP provides a flexible foundation. Its language-agnostic design and official SDKs for popular programming languages make it accessible to a wide range of developers. By leveraging these SDKs, you can quickly prototype, iterate, and scale your solutions across different platforms and environments.
6
+
7
+
In the following sections, you'll find practical examples, sample code, and deployment strategies that demonstrate how to implement MCP in C#, Java, TypeScript, JavaScript, and Python. You'll also learn how to debug and test your MCP servers, manage APIs, and deploy solutions to the cloud using Azure. These hands-on resources are designed to accelerate your learning and help you confidently build robust, production-ready MCP applications.
8
+
3
9
## Overview
4
10
5
11
This lesson focuses on practical aspects of MCP implementation across multiple programming languages. We'll explore how to use MCP SDKs in C#, Java, TypeScript, JavaScript, and Python to build robust applications, debug and test MCP servers, and create reusable resources, prompts, and tools.
@@ -39,31 +45,31 @@ The repository includes sample implementations in the following languages:
39
45
40
46
Each sample demonstrates key MCP concepts and implementation patterns for that specific language and ecosystem.
41
47
42
-
###Core Server Features
48
+
## Core Server Features
43
49
44
50
MCP servers can implement any combination of these features:
45
51
46
-
####Resources
52
+
### Resources
47
53
Resources provide context and data for the user or AI model to use:
48
54
- Document repositories
49
55
- Knowledge bases
50
56
- Structured data sources
51
57
- File systems
52
58
53
-
####Prompts
59
+
### Prompts
54
60
Prompts are templated messages and workflows for users:
55
61
- Pre-defined conversation templates
56
62
- Guided interaction patterns
57
63
- Specialized dialogue structures
58
64
59
-
####Tools
65
+
### Tools
60
66
Tools are functions for the AI model to execute:
61
67
- Data processing utilities
62
68
- External API integrations
63
69
- Computational capabilities
64
70
- Search functionality
65
71
66
-
####Sample Implementations
72
+
## Sample Implementations: C#
67
73
68
74
The official C# SDK repository contains several sample implementations demonstrating different aspects of MCP:
69
75
@@ -73,7 +79,6 @@ The official C# SDK repository contains several sample implementations demonstra
73
79
-**ASP.NET Integration**: Examples demonstrating integration with ASP.NET Core
74
80
-**Tool Implementation Patterns**: Various patterns for implementing tools with different complexity levels
75
81
76
-
### C# .NET Implementation
77
82
The MCP C# SDK is in preview and APIs may change. We will continuously update this blog as the SDK evolves.
78
83
79
84
### Key Features
@@ -82,11 +87,12 @@ The MCP C# SDK is in preview and APIs may change. We will continuously update th
82
87
- Building your [first MCP Server](https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/).
83
88
84
89
For complete C# implementation samples, visit the [official C# SDK samples repository](https://github.com/modelcontextprotocol/csharp-sdk)
85
-
### Java Implementation
90
+
91
+
## Sample implementation: Java Implementation
86
92
87
93
The Java SDK offers robust MCP implementation options with enterprise-grade features.
88
94
89
-
####Key Features
95
+
### Key Features
90
96
91
97
- Spring Framework integration
92
98
- Strong type safety
@@ -95,11 +101,11 @@ The Java SDK offers robust MCP implementation options with enterprise-grade feat
95
101
96
102
For a complete Java implementation sample, see [MCPSample.java](samples/java/MCPSample.java) in the samples directory.
The JavaScript SDK provides a lightweight and flexible approach to MCP implementation.
101
107
102
-
####Key Features
108
+
### Key Features
103
109
104
110
- Node.js and browser support
105
111
- Promise-based API
@@ -108,11 +114,11 @@ The JavaScript SDK provides a lightweight and flexible approach to MCP implement
108
114
109
115
For a complete JavaScript implementation sample, see [mcp_sample.js](samples/javascript/mcp_sample.js) in the samples directory.
110
116
111
-
###Python Implementation
117
+
##Sample implementation: Python Implementation
112
118
113
119
The Python SDK offers a Pythonic approach to MCP implementation with excellent ML framework integrations.
114
120
115
-
####Key Features
121
+
### Key Features
116
122
117
123
- Async/await support with asyncio
118
124
- Flask and FastAPI integration
@@ -121,19 +127,51 @@ The Python SDK offers a Pythonic approach to MCP implementation with excellent M
121
127
122
128
For a complete Python implementation sample, see [mcp_sample.py](samples/python/mcp_sample.py) in the samples directory.
123
129
124
-
### API Management
130
+
## API management
131
+
132
+
Azure API Management is a great answer to how we can secure MCP Servers. The idea is to put an Azure API Management instance in front of your MCP Server and let it handle features you're likely to want like:
133
+
134
+
- rate limiting
135
+
- token management
136
+
- monitoring
137
+
- load balancing
138
+
- security
139
+
140
+
### Azure Sample
141
+
142
+
Here's an Azure Sample doing exactly that, i.e [creating an MCP Server and securing it with Azure API Management])(https://github.com/Azure-Samples/remote-mcp-apim-functions-python).
143
+
144
+
See how the authorization flow happens in below image:
Let's have a look at the authorization flow more in detail:
129
157
130
-
This sample implements the latest [MCP Authorization specification](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization#2-10-third-party-authorization-flow)
Learn more about the [MCP Authorization specification](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization#2-10-third-party-authorization-flow)
134
163
135
164
## Deploy Remote MCP Server to Azure
136
165
166
+
Let's see if we can deploy the sample we mentioned earlier:
* If you are using Azure CLI, run `az provider register --namespace Microsoft.App --wait`.
139
177
* If you are using Azure PowerShell, run `Register-AzResourceProvider -ProviderNamespace Microsoft.App`. Then run `(Get-AzResourceProvider -ProviderNamespace Microsoft.App).RegistrationState` after some time to check if the registration is complete.
@@ -144,14 +182,20 @@ This is a Sequence Diagram
144
182
azd up
145
183
```
146
184
147
-
### MCP Inspector
185
+
This commands should deploy all the cloud resources on Azure
186
+
187
+
### Testing your server with MCP Inspector
148
188
149
189
1. In a **new terminal window**, install and run MCP Inspector
150
190
151
191
```shell
152
192
npx @modelcontextprotocol/inspector
153
193
```
154
194
195
+
You should see an interface similar to:
196
+
197
+

198
+
155
199
1. CTRL click to load the MCP Inspector web app from the URL displayed by the app (e.g. http://127.0.0.1:6274/#resources)
156
200
1. Set the transport type to `SSE`
157
201
1. Set the URL to your running API Management SSE endpoint displayed after `azd up` and **Connect**:
@@ -162,7 +206,9 @@ This is a Sequence Diagram
162
206
163
207
5. **List Tools**. Click on a tool and **Run Tool**.
164
208
165
-
### Implementations and Deployment
209
+
If all the steps have worked, you should now be connected to the MCP server and you've been able to call a tool.
210
+
211
+
## MCP servers for Azure
166
212
167
213
[Remote-mcp-functions](https://github.com/Azure-Samples/remote-mcp-functions-dotnet): This set of repositories are quickstart template for building and deploying custom remote MCP (Model Context Protocol) servers using Azure Functions with Python, C# .NET or Node/TypeScript.
168
214
@@ -172,7 +218,8 @@ The Samples provides a complete solution that allows developers to:
172
218
- Deploy to Azure: Easily deploy to the cloud with a simple azd up command
173
219
- Connect from clients: Connect to the MCP server from various clients including VS Code's Copilot agent mode and the MCP Inspector tool
174
220
175
-
#### Key Features:
221
+
### Key Features:
222
+
176
223
- Security by design: The MCP server is secured using keys and HTTPS
177
224
- Authentication options: Supports OAuth using built-in auth and/or API Management
0 commit comments