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.
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.
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.
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-namespaceAfter 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: 8000Apply 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-routerSigned-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.
