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
# Getting Started with Remote MCP Servers using Azure Functions (Java)
18
18
19
-
This quick-start shows how to build and deploy a **remote MCP server** with Azure Functions (Java).
20
-
You can run it locally for debugging, then ship it to the cloud with `azd up` in minutes.
21
-
The server is secured by design (system keys + HTTPS), supports OAuth via EasyAuth or API Management, and can be isolated inside a VNet.
19
+
This is a quickstart template to easily build and deploy custom remote MCP servers to the cloud using Azure Functions. You can clone/restore/run on your local machine with debugging, and `azd up` to have it in the cloud in a couple minutes.
22
20
23
-
[Watch the overview video.](https://www.youtube.com/watch?v=U9DsLcP5vEk)
24
-
---
21
+
The MCP server is configured with [built-in authentication](https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization) using Microsoft Entra as the identity provider.
25
22
26
-
## Prerequisites
23
+
You can also use [API Management](https://learn.microsoft.com/azure/api-management/secure-mcp-servers) to secure the server, as well as network isolation using VNET.
27
24
28
-
| Purpose | Tool | Notes |
29
-
|---------|------|-------|
30
-
|**Java build + run**| JDK 17 (or newer) | Java 8 runtime still works but JDK 17 is recommended. |
31
-
|**Local Functions runtime**|[Azure Functions Core Tools v4](https://learn.microsoft.com/azure/azure-functions/functions-run-local) ≥ `4.0.7030`| Used by `mvn azure-functions:run`. |
|**Blob Storage emulator**|[Docker](https://www.docker.com/) to run **Azurite**| Needed only when running locally with `UseDevelopmentStorage=true`. |
25
+
If you're looking for this sample in more languages check out the [.NET/C#](https://github.com/Azure-Samples/remote-mcp-functions-dotnet), [Node.js/TypeScript](https://github.com/Azure-Samples/remote-mcp-functions-typescript) and [Python](https://github.com/Azure-Samples/remote-mcp-functions-python) samples.
35
26
36
-
---
27
+
[](https://codespaces.new/Azure-Samples/remote-mcp-functions-java)
37
28
38
-
## Prepare your local environment
29
+
## Samples
39
30
40
-
> **Why Azurite?**
41
-
> The `SaveSnippet` / `GetSnippet` tools persist snippets in Azure Blob Storage.
42
-
> Azurite emulates that storage account on your dev machine.
31
+
| Sample | Description |
32
+
|--------|-------------|
33
+
|[**FunctionsMcpTool**](samples/FunctionsMcpTool/)| MCP tools with Azure Blob Storage - say hello, save and retrieve code snippets. |
34
+
|[**McpWeatherApp**](samples/McpWeatherApp/)| MCP Apps - a weather tool with an interactive UI (MCP resource + metadata). |
43
35
44
-
```bash
45
-
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
46
-
mcr.microsoft.com/azure-storage/azurite
47
-
````
36
+
## Prerequisites
48
37
49
-
If you prefer the Azurite **VS Code extension**, run **“Azurite: Start”** from the command palette instead.
+[Visual Studio Code](https://code.visualstudio.com/) + [Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) (recommended)
50
43
51
-
---
44
+
## Run and test locally
52
45
53
-
## Run the MCP server locally
46
+
### FunctionsMcpTool
54
47
55
-
```bash
56
-
# 1 – Build the project
57
-
mvn clean package
48
+
> **Requires [Azurite](https://learn.microsoft.com/azure/storage/common/storage-use-azurite)** for local blob storage. Start it with `docker run -d -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite` or use the Azurite VS Code extension.
58
49
59
-
# 2 – Start the Functions host (via Maven wrapper)
50
+
```
51
+
cd samples/FunctionsMcpTool
52
+
mvn clean package
60
53
mvn azure-functions:run
61
54
```
62
55
63
-
The SSE endpoint will be available at:
56
+
Open **.vscode/mcp.json**, click **Start** above *local-mcp-function*, then try prompts in Copilot agent mode:
|**HelloWorld**|[`src/main/java/com/function/HelloWorld.java`](./src/main/java/com/function/HelloWorld.java)| Logs an argument then prints “Hello World”. |
After deployment finishes, open **.vscode/mcp.json** and click **Start** above *remote-mcp-function*. You'll be prompted for `functionapp-name` (find it in your azd command output or `/.azure/*/.env` file). You'll also be prompted to authenticate with Microsoft - click **Allow** and login with your Azure subscription email.
200
128
201
-
<details>
202
-
<summary>Click to expand</summary>
129
+
> [!TIP]
130
+
> Successful connect shows the number of tools the server has. You can see more details on the interactions between VS Code and server by clicking on **More... -> Show Output** above the server name.
203
131
204
-
### MCP Tool Trigger
132
+
##Redeploy and clean up
205
133
206
-
```java
207
-
@McpToolTrigger(
208
-
toolName="saveSnippets",
209
-
description="Saves a text snippet to your snippets collection.",
+ Add [API Management](https://github.com/Azure-Samples/remote-mcp-apim-functions-python) to your MCP server
147
+
+ Enable VNET using `VNET_ENABLED=true` flag
148
+
+ Learn more about [related MCP efforts from Microsoft](https://github.com/microsoft/mcp/tree/main/Resources)
248
149
249
-
## Next Steps
150
+
## Troubleshooting
250
151
251
-
* Front your MCP server with **API Management** for fine-grained policies.
252
-
* Add **EasyAuth** to use your favourite OAuth provider (including Entra ID).
253
-
* Toggle VNet integration via `VNET_ENABLED=true` for network isolation.
254
-
* Explore the [Model Context Protocol](https://github.com/modelcontextprotocol) ecosystem for more tools.
152
+
| Problem | Solution |
153
+
|---------|----------|
154
+
| Connection refused | Ensure Azurite is running (`docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite`) |
155
+
| API version not supported by Azurite | Pull the latest Azurite image (`docker pull mcr.microsoft.com/azure-storage/azurite`) then restart Azurite and the app |
156
+
|`mvn clean package` fails | Ensure JDK 17+ is on your PATH (`java -version`) |
0 commit comments