Cloud Native 11 min read

How Nacos MCP Router Simplifies AI Agent Tool Integration and Cuts Token Costs

This article explains the challenges AI agents face when using numerous MCP servers, introduces Nacos MCP Router as a smart, secure, and token‑efficient solution, details its architecture, smart‑routing and proxy modes, and provides step‑by‑step deployment instructions on a cloud‑native platform.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How Nacos MCP Router Simplifies AI Agent Tool Integration and Cuts Token Costs

Background

Since the MCP protocol was released, AI agents can invoke many external tools, but users face three practical problems:

Complex service selection and configuration : Thousands of MCP servers exist and must be manually selected and configured for each task.

Excessive token consumption : Registering many MCP servers forces the agent to send full tool descriptions to the large model, inflating token usage, inference cost, and latency.

Security and trust concerns : Community‑provided, locally deployed MCP servers may contain vulnerabilities or data‑leak risks, and there is no authoritative security assessment.

Nacos MCP Router

The open‑source Nacos MCP Router is a standard MCP server that, based on a task’s semantic description and keywords, intelligently selects the most appropriate MCP servers from the Nacos MCP Registry and presents these candidates to the large model for decision‑making.

Eliminates the need for users to manually configure multiple MCP servers; a single Router endpoint handles all routing.

Reduces token usage because the agent initially sends only Router’s lightweight tool description; Router returns only the tool descriptions relevant to the current task.

Converts insecure stdio ‑based MCP servers into safer SSE or streamable HTTP protocols and runs them inside Docker containers, isolating resources and preventing data‑leak paths.

Architecture Overview

Router operates as a standard MCP server and uses the Nacos MCP Registry as its data source.

Architecture diagram
Architecture diagram

Router Working Modes

Smart Routing Mode (full‑function): automatic discovery, intelligent filtering, tool proxy, protocol conversion, security authentication, and dynamic debugging.

Proxy Mode (sub‑function set): protocol conversion, tool proxy, security authentication, and dynamic debugging.

Smart Routing Mode

In this mode Router exposes three MCP tools: search_mcp_server: intelligently selects MCP servers based on task description and keywords. add_mcp_server: initializes a specified MCP server (handling stdio or SSE/streamable HTTP protocols accordingly). use_mcp_tool: forwards a tool request to the chosen MCP server.

Workflow:

Router starts and loads the MCP server list from the Nacos MCP Registry into a vector database.

When an AI agent creates a session, it receives the three Router tools.

The agent calls search_mcp_server with the task description; Router returns the top‑5 matching MCP servers.

The agent selects a server and calls add_mcp_server to initialize it.

Router initializes the target server and returns its tool list.

The agent finally calls use_mcp_tool to invoke the desired tool; Router proxies the request and returns the result.

Proxy Mode

Proxy mode converts insecure stdio MCP servers into safe streamable HTTP services and runs them in isolated Docker containers.

Proxy mode diagram
Proxy mode diagram

Deployment

Router and its dependent Nacos cluster are packaged as Helm charts for one‑click deployment on a cloud‑native platform.

git clone https://github.com/nacos-group/nacos-mcp-router.git</code>
<code>cd nacos-mcp-router/helm</code>
<code>bash randomize_values.sh</code>
<code>helm install nacos-mcp-router . -n nacos-mcp --create-namespace

After the Helm release finishes, a three‑node cluster (Nacos, MySQL, Router) is created.

Example Kubernetes manifest for deploying a fetch MCP server in proxy mode:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: fetch-mcp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fetch-mcp
  template:
    metadata:
      labels:
        app: fetch-mcp
    spec:
      containers:
        - name: fetch-mcp
          image: "nacos/nacos-mcp-router:latest"
          env:
            - name: TRANSPORT_TYPE
              value: streamable_http
            - name: MODE
              value: "proxy"
            - name: PROXED_MCP_NAME
              value: "fetch"
            - name: PROXED_MCP_SERVER_CONFIG
              value: '{"mcpServers":{"fetch":{"command":"uvx","args":["mcp-server-fetch"]}}}'
            - name: AUTO_REGISTER_TOOLS
              value: "false"
---
apiVersion: v1
kind: Service
metadata:
  name: fetch-mcp
spec:
  type: ClusterIP
  selector:
    app: fetch-mcp
  ports:
    - name: http
      port: 8000
      targetPort: 8000

Apply the manifest with: kubectl apply -f fetch-mcp.yaml -n nacos-mcp After deployment, the fetch service appears in the Nacos console and can be accessed via the Router’s public address.

Future Plans

Security : unified authentication and authorization for MCP tools.

Stability : rate‑limiting, observability, and fault‑tolerance for tool calls.

Intelligence : virtual MCP construction, improved tool selection, and retrieval accuracy.

Project repository:

https://github.com/nacos-group/nacos-mcp-router
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.

MCPDeploymentRouterAI Agent
Alibaba Cloud Native
Written by

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.

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.