Large Language Models (LLMs) remain static in functionality after training, and extending their capabilities requires integration with external data, computation, and services. The Model Context Protocol (MCP) has emerged as a standard interface for such extensions, but current implementations rely solely on semantic matching between users' requests and server function descriptions, which makes current deployments and simulation testbeds fragile under latency fluctuations or server failures. We address this gap by enhancing MCP tool routing algorithms with real-time awareness of network and server status. To provide a controlled test environment for development and evaluation, we construct a heterogeneous experimental platform, namely Network-aware MCP (NetMCP), which offers five representative network states and build a benchmark for latency sequence generation and MCP server datasets. On top of NetMCP platform, we analyze latency sequences and propose a Semantic-Oriented and Network-Aware Routing (SONAR) algorithm, which jointly optimizes semantic similarity and network Quality of Service (QoS) metrics for adaptive tool routing. Results show that SONAR consistently improves task success rate and reduces completion time and failure number compared with semantic-only, LLM-based baselines, demonstrating the value of network-aware design for production-scale LLM systems. The code for NetMCP is available at https://github.com/NICE-HKU/NetMCP.
翻译:大型语言模型(LLM)在训练后功能保持静态,扩展其能力需要与外部数据、计算和服务进行集成。模型上下文协议(MCP)已成为此类扩展的标准接口,但现有实现仅依赖于用户请求与服务器功能描述之间的语义匹配,这导致当前部署和模拟测试平台在延迟波动或服务器故障时表现脆弱。我们通过增强MCP工具路由算法,使其具备对网络和服务器状态的实时感知能力,以弥补这一不足。为提供一个可控的开发与评估测试环境,我们构建了一个异构实验平台——网络感知MCP(NetMCP),该平台提供五种代表性网络状态,并构建了用于延迟序列生成和MCP服务器数据集的基准。在NetMCP平台之上,我们分析了延迟序列,并提出了一种语义导向与网络感知路由(SONAR)算法,该算法联合优化语义相似度和网络服务质量(QoS)指标,以实现自适应工具路由。实验结果表明,与仅基于语义的基线方法和基于LLM的基线方法相比,SONAR算法持续提高了任务成功率,并减少了完成时间和失败次数,这证明了网络感知设计对于生产级LLM系统的价值。NetMCP的代码可在 https://github.com/NICE-HKU/NetMCP 获取。