How to Transform REST APIs into MCP Services with Higress, Nacos, and Spring AI
This guide walks through setting up a Docker network, deploying Higress and Redis, configuring MCP server parameters, registering services in Nacos, converting REST APIs to MCP, and using Spring AI Alibaba for automatic registration and exposure, demonstrating end‑to‑end cloud‑native service integration.
Environment preparation
Create an isolated Docker network for all components:
docker network create mcpDeploy Higress
Run the all‑in‑one Higress image, expose the management and data ports, and attach it to the mcp network:
docker run -d --rm --name higress-ai -v ${PWD}:/data \
-p 8001:8001 -p 8080:8080 -p 8443:8443 \
--network mcp \
higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/all-in-one:latestDeploy Redis
Redis stores MCP server state. Deploy it on the same network:
docker run -d --rm --name higress-redis -p 6379:6379 \
--network mcp \
higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/redis-stack-server:7.4.0-v3Configure MCP Server in Higress
Edit the ConfigMap that Higress reads (e.g. ./configmaps/higress-config.yaml) to enable the MCP server and point it to Redis:
apiVersion: v1
kind: ConfigMap
metadata:
name: higress-config
namespace: higress-system
data:
higress: |-
mcpServer:
sse_path_suffix: /sse
enable: true
redis:
address: higress-redis:6379
downstream: {}On non‑Linux hosts the ConfigMap changes may not be applied immediately; restart the higress-ai container to force a reload.
Deploy Nacos (standalone)
Run a single‑node Nacos instance and expose its management ports:
docker run --name nacos \
-e MODE=standalone \
-e NACOS_AUTH_TOKEN=your_token_base64 \
-e NACOS_AUTH_IDENTITY_KEY=your_key \
-e NACOS_AUTH_IDENTITY_VALUE=your_value \
-p 8081:8080 -p 8848:8848 -p 9848:9848 \
--network mcp -d \
nacos-registry.cn-hangzhou.cr.aliyuncs.com/nacos/nacos-server:v3.0.1Convert a REST API to an MCP service
In the Nacos console, create an MCP Server under the “MCP Registry” section. Add a Tool named get_weather with the following request template:
{
"requestTemplate": {
"url": "/v3/weather/weatherInfo?key=yourkey",
"argsToUrlParam": true,
"method": "GET"
}
}Publish the tool as the latest version. The service becomes reachable through Higress via the SSE endpoint, for example:
http://{HOST}:8080/mcp/amap/sseDynamic configuration with Nacos
Starting with Nacos 3.0.1, MCP templates can reference Nacos configuration items, allowing runtime updates without redeploy.
Create a ConfigMap named amap_key in the data group:
{
"data": "your_key"
}Reference this key inside the MCP template (e.g. ${amap_key}). Updating the ConfigMap at runtime changes the value used by the MCP service, enabling token rotation or other parameter adjustments on the fly.
Spring AI Alibaba integration
Clone the Spring AI Alibaba examples repository and run the Nacos MCP example, which automatically registers an MCP service in Nacos:
git clone https://github.com/springaialibaba/spring-ai-alibaba-examples.git
cd spring-ai-alibaba-examples/spring-ai-alibaba-mcp-example/spring-ai-alibaba-mcp-nacos-example/server/mcp-nacos-registry-example
# Edit src/main/resources/application.yml to set your Nacos username and password
mvn spring-boot:runThe application registers the MCP service; Higress discovers it and creates transparent proxy rules, so the service can be accessed through Higress without code changes.
Verification
1. Access the SSE endpoint to confirm the service works.
2. Modify the amap_key ConfigMap to an invalid value and re‑access the endpoint; the request should fail, demonstrating that dynamic configuration changes are applied immediately.
3. Observe Higress logs or use a client to verify that the proxy rules are generated automatically for the registered MCP service.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
