Zero‑Code Upgrade of Legacy APIs to MCP Protocol with Nacos MCP Registry

The article explains how Nacos, acting as an MCP Registry, can transform existing service APIs into MCP‑compatible interfaces without code changes, detailing the integration with Higress, the underlying tool/list exposure, protocol conversion, deployment steps, and a weather‑query demo that showcases the end‑to‑end workflow.

Alibaba Middleware
Alibaba Middleware
Alibaba Middleware
Zero‑Code Upgrade of Legacy APIs to MCP Protocol with Nacos MCP Registry

The rapid expansion of the Model Center Protocol (MCP) ecosystem—adopted by companies such as Cursor, Windsurf, Cline, OpenAI, Baidu Maps, and Amap—has created strong demand for solutions that let legacy services expose MCP interfaces without costly refactoring.

Why Zero‑Code MCP Integration Matters

Legacy applications must expose their APIs to MCP servers, which traditionally incurs both time and manpower overhead. Enterprises therefore seek open‑source or commercial approaches that minimize effort while accelerating MCP adoption.

Nacos as MCP Registry

Nacos serves as the control plane for MCP, managing tool metadata and converting existing APIs into MCP‑compatible definitions. By registering service addresses in Nacos and adding interface descriptions, the system can dynamically generate MCP Server protocols via the Higress AI gateway.

Core Implementation Principles

Tool/List Exposure : Higress proxies a tool/list endpoint that returns a list of Tools derived from Nacos‑stored service descriptions. Each service’s interfaces are mapped to a unique Tool name, and the aggregated list is presented to MCP clients.

Protocol Conversion : MCP JSON‑RPC calls (e.g., tool/call) are parsed by Higress, which constructs corresponding HTTP requests based on configured parameter mappings, paths, and backend addresses, then wraps the backend response back into the MCP format.

Thus, legacy services only need to add interface metadata in Nacos; no code changes are required.

Advantages of Using Nacos for MCP

Rapid, zero‑code construction of MCP Servers.

Dynamic, real‑time propagation of MCP descriptions, Tools, and Prompts.

Versioned history of MCP information for diff comparison and rollback.

Gradual (gray) rollout of MCP updates.

Built‑in encryption for sensitive credentials.

Automatic JSON‑to‑XML conversion for model‑friendly responses.

Scalable service management, health checks, load balancing, and discovery for growing MCP services.

Step‑by‑Step Deployment Guide

1. Deploy Nacos

export NACOS_AUTH_TOKEN=YOUR_BASE64_TOKEN</code>
<code>export NACOS_AUTH_IDENTITY_VALUE=YOUR_IDENTITY</code>
<code>docker run -td -e PREFER_HOST_MODE=hostname -e MODE=standalone -e NACOS_AUTH_IDENTITY_KEY=serverIdentity -e NACOS_AUTH_IDENTITY_VALUE=${NACOS_AUTH_IDENTITY_VALUE} -e NACOS_AUTH_TOKEN=${NACOS_AUTH_TOKEN} -p 8848:8848 -p 9848:9848 nacos/nacos-server

2. Deploy Higress

Install Docker.

Install Kind (local Kubernetes) for AMD64 or ARM64.

Create a local cluster: kind create cluster Install hgctl via

curl -Ls https://raw.githubusercontent.com/alibaba/higress/main/tools/hack/get-hgctl.sh | bash

Deploy Higress locally: hgctl install --set profile=local-k8s Install kubectl and connect to the cluster.

Run a Redis container for Higress state storage: docker run --name higress-redis -d redis Edit the Higress ConfigMap to enable MCP Server and point to Nacos (replace {local_ip} with the host IP):

apiVersion: v1</code>
<code>data:</code>
<code>  higress: |-</code>
<code>    mcpServer:</code>
<code>      sse_path_suffix: /sse</code>
<code>      enable: true</code>
<code>      redis:</code>
<code>        address: {local_ip}:6379</code>
<code>      match_list:</code>
<code>        - match_rule_domain: "*"</code>
<code>          match_rule_path: /registry</code>
<code>          match_rule_type: "prefix"</code>
<code>      servers:</code>
<code>        - name: nacos-registry</code>
<code>          type: nacos-mcp-registry</code>
<code>          path: /registry</code>
<code>          config:</code>
<code>            serverAddr: {local_ip}</code>
<code>            namespace: ""</code>
<code>            serviceMatcher:</code>
<code>              amap: ".*"</code>
<code>              ip: ".*"</code>
<code>    downstream:</code>
<code>      connectionBufferLimits: 32768</code>
<code>      http2:</code>
<code>        initialConnectionWindowSize: 1048576</code>
<code>        initialStreamWindowSize: 65535</code>
<code>        maxConcurrentStreams: 100</code>
<code>      idleTimeout: 180</code>
<code>      maxRequestHeadersKb: 60</code>
<code>      routeTimeout: 0</code>
<code>    upstream:</code>
<code>      connectionBufferLimits: 10485760</code>
<code>      idleTimeout: 10

3. Register Legacy Services in Nacos

Example: Register Amap (high‑definition map) HTTP API as a service named amap in group amap:

curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=amap&groupName=amap&ip=restapi.amap.com&port=80&ephemeral=false'

Verify the instance count becomes 1 via the Nacos console.

4. Create MCP Tool Descriptions in Nacos

In the Nacos configuration center, add a new configuration with DataId amap-mcp-tools.json and group amap:

{
  "protocol": "http",
  "tools": [
    {
      "name": "get_weather",
      "description": "get weather",
      "inputSchema": {"type": "object","properties": {"city": {"type": "string","description": "city adcode"}}}
    },
    {
      "name": "get_adcode",
      "description": "get adcode via address",
      "inputSchema": {"type": "object","properties": {"address": {"type": "string","description": "address"}}}
    },
    {
      "name": "get_address_via_ip",
      "description": "get address via ip",
      "inputSchema": {"type": "object","properties": {"ip": {"type": "string","description": "ip address"}}}
    }
  ],
  "toolsMeta": {
    "get_weather": {"credentialRef": "amap-key.json","InvokeContext": {"path": "/v3/weather/weatherInfo","method": "GET"}},
    "get_adcode": {"credentialRef": "amap-key.json","InvokeContext": {"path": "/v3/geocode/geo","method": "GET"}},
    "get_address_via_ip": {"credentialRef": "amap-key.json","InvokeContext": {"path": "/v3/ip","method": "GET"}}
  }
}

Also create a credential file amap-key.json containing the Amap API key:

{
  "type": "fixed-query-token",
  "credentialsMap": {"key": "key","value": "YOUR_AMAP_API_KEY"}
}

5. Register an IP‑Info Service (Optional)

Register ipinfo.io as a service named ip in group ip and add a corresponding MCP tool configuration ( ip-mcp-tools.json) that exposes get_current_ip_address.

6. Configure Cursor to Use the MCP Server

{
  "mcpServers": {
    "nacos-registry": {"url": "http://localhost/registry/sse"}
  }
}

After the configuration, the Agent can retrieve the list of Tools exposed by Higress + Nacos.

Demo: Weather Query via MCP

The demo runs an Agent that first obtains the host’s outbound IP, resolves the IP to a province/city, fetches the corresponding adcode, and finally calls get_weather to retrieve the current weather. All interactions happen through the MCP Server without any modification to the original Amap HTTP API.

Conclusion

By combining Nacos and Higress, legacy services can be exposed as MCP‑compatible Tools with zero code changes, dramatically lowering migration cost. Current limitations include the manual creation of interface descriptions; future work will focus on automating description generation and pruning large Tool lists to reduce token consumption for LLMs.

Architecture diagram
Architecture diagram
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeAIMCPNacosService RegistryHigressZero-Code Integration
Alibaba Middleware
Written by

Alibaba Middleware

Aliware Alibaba Middleware Official Account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.