
远程MCP Azure容器应用
HTTP-SSE在Azure容器应用上运行远程MCP服务器
在Azure容器应用上运行远程MCP服务器
This is a quick start guide that provides the basic building blocks to set up a remote Model Context Protocol (MCP) server using Azure Container Apps. The MCP server is built using Node.js and TypeScript, and it can be used to run various tools and services in a serverless environment.
You can run these commands from the VSCode Terminal
git clone https://github.com/azure-samples/mcp-container-ts.git
azd auth login
azd up
https://<env-name>.<container-id>.<region>.azurecontainerapps.io
mcp.json
file or manually adding it as described in the previous section:{ "servers": { "mcp-server-sse-remote": { "type": "sse", "url": "https://<your-app-name>.<region>.azurecontainerapps.io/sse" } } }
[!NOTE] The URL for the MCP server will be different for each deployment. Make sure to update the URL in the
mcp.json
file or in your MCP client configuration accordingly.
azd down
The Model Context Protocol (MCP) is a protocol that allows different AI models and tools to communicate with each other. It provides a standardized way for models to share information and collaborate on tasks. The MCP server acts as a bridge between different models and tools, allowing them to work together seamlessly.
Below is the architecture diagram for a typical MCP server setup:
[!IMPORTANT] (*) This guide implements only the SSE MCP server. The MCP host and clients are not provided. If you are looking for a complete solution, with a custom MCP host, client and both HTTP and SSE MCP servers please check out this other repository.
You have a few other options besides azd up locally for getting started with this template. The quickest way to get started is GitHub Codespaces, since it will setup all the tools for you, but you can also set it up locally.
You can run this template virtually by using GitHub Codespaces. The button will open a web-based VS Code instance in your browser:
Open the template (this may take several minutes):
Open a terminal window
Continue with the deploying steps
[!NOTE] If you run the mcp server inside of GitHub Codespaces, make sure to change the port visibility to Public: Click on "PORTS" tabs → right-click on the opened port (3000 by default) → Port visibility → Public.
A related option is VS Code Dev Containers, which will open the project in your local VS Code using the Dev Containers extension:
Start Docker Desktop (install it if not already installed)
Open the project:
Open a terminal window
Start the server
npm start
If you prefer to run the MCP server locally, you can do so by following these steps:
You need to have the following tools installed on your local machine:
git clone https://github.com/Azure-Samples/mcp-container-ts cd mcp-container-ts
Open the project folder
Install dependencies
npm install
npm start
[!NOTE] When the applications starts, the server will create an in-memory SQLite database. This database is used to store the state of the tools and their interactions with the MCP server.
The quickest way to connect to the MCP server is the use the provided mcp.json configuration file to set up the MCP server in your VS Code environment. This configuration file contains the necessary settings for the MCP server, including the URL and transport type.
{ "servers": { "mcp-server-sse": { "type": "sse", "url": "http://localhost:3000/sse" } } }
Once you have this file opened, you can click on the "start" inlined action button that will connect the MCP server and fetch the available tools.
http://localhost:3000/sse
I need to send an email to Dan, please add that to my todo list.
npm run inspect
http://localhost:3000/sse